Skip to content

Commit

Permalink
changed name and set the opake to false hhehehe
Browse files Browse the repository at this point in the history
  • Loading branch information
LoisChiles committed May 29, 2024
1 parent 4d96da8 commit a350abe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
18 changes: 9 additions & 9 deletions src/main/java/edu/project/components/TimeForecast.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ public TimeForecast(Context context) {
titlePanel.add(titleLabel, BorderLayout.NORTH);

JSeparator separator = new JSeparator(SwingConstants.HORIZONTAL);
separator.setForeground(Color.BLACK);
separator.setForeground(Color.GRAY);
titlePanel.add(separator, BorderLayout.SOUTH);

mainPanel.add(titlePanel, BorderLayout.NORTH);

contentPanel = new JPanel();
Expand Down Expand Up @@ -99,8 +98,8 @@ private void addForecastPanels() {
hourPanel.add(hourLabel);
hourForecastPanel.add(hourPanel, BorderLayout.NORTH);

JPanel separatorPanel = createSeparatorPanel(forecast.iconId);
hourForecastPanel.add(separatorPanel, BorderLayout.CENTER);
JPanel iconPanel = createIconPanel(forecast.iconId);
hourForecastPanel.add(iconPanel, BorderLayout.CENTER);

JPanel temperaturePanel = new JPanel();
temperaturePanel.setOpaque(false);
Expand All @@ -117,7 +116,7 @@ private void addForecastPanels() {
repaint();
}

private JPanel createSeparatorPanel(String iconId) {
private JPanel createIconPanel(String iconId) {
String iconUrl = "https://openweathermap.org/img/wn/" + iconId + "@2x.png";
BufferedImage image = null;

Expand All @@ -130,7 +129,7 @@ private JPanel createSeparatorPanel(String iconId) {

ImageIcon icon = new ImageIcon(image);

JPanel separatorPanel = new JPanel() {
JPanel iconPanel = new JPanel() {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Expand All @@ -142,9 +141,10 @@ protected void paintComponent(Graphics g) {
icon.paintIcon(this, g2d, x, y);
}
};
separatorPanel.setPreferredSize(new Dimension(40, 40));
separatorPanel.setMaximumSize(new Dimension(40, 40));
return separatorPanel;
iconPanel.setPreferredSize(new Dimension(40, 40));
iconPanel.setMaximumSize(new Dimension(40, 40));
iconPanel.setOpaque(false);
return iconPanel;
}

@Override
Expand Down
17 changes: 8 additions & 9 deletions src/main/java/edu/project/components/WeatherForecastPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import javax.imageio.ImageIO;
import javax.swing.*;

import com.formdev.flatlaf.FlatClientProperties;

import java.awt.*;
import java.awt.geom.RoundRectangle2D;
import java.awt.image.BufferedImage;
Expand Down Expand Up @@ -91,8 +89,8 @@ private void updateForecast(WeatherForecast5Data forecastData) {
String iconId = weatherList.get(i * 8).weather.get(0).icon;

// Add the separator panel with an image
JPanel separatorPanel = createSeparatorPanel(iconId);
dayForecastPanel.add(separatorPanel, BorderLayout.CENTER);
JPanel iconPanel = createiconPanel(iconId);
dayForecastPanel.add(iconPanel, BorderLayout.CENTER);

// Calculate the average temperature for the day, converting from Kelvin to
// Celsius
Expand All @@ -119,7 +117,7 @@ private void updateForecast(WeatherForecast5Data forecastData) {
repaint();
}

private JPanel createSeparatorPanel(String iconId) {
private JPanel createiconPanel(String iconId) {
// Base URL for weather icons
String iconUrl = "http://openweathermap.org/img/wn/" + iconId + "@2x.png";
BufferedImage image = null;
Expand All @@ -133,7 +131,7 @@ private JPanel createSeparatorPanel(String iconId) {

ImageIcon icon = new ImageIcon(image);

JPanel separatorPanel = new JPanel() {
JPanel iconPanel = new JPanel() {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Expand All @@ -146,9 +144,10 @@ protected void paintComponent(Graphics g) {
icon.paintIcon(this, g2d, x, y);
}
};
separatorPanel.setPreferredSize(new Dimension(40, 40));
separatorPanel.setMaximumSize(new Dimension(40, 40));
return separatorPanel;
iconPanel.setPreferredSize(new Dimension(40, 40));
iconPanel.setMaximumSize(new Dimension(40, 40));
iconPanel.setOpaque(false);
return iconPanel;
}

@Override
Expand Down

0 comments on commit a350abe

Please sign in to comment.