Skip to content

Commit

Permalink
Fix Weather Island layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Cesshi committed May 29, 2024
1 parent 02ffe3b commit 5021f82
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public WeatherCard(String title, String value, String unit) {
GridBagConstraints constraints = new GridBagConstraints();
constraints.gridx = 0;
constraints.gridy = 0;
constraints.insets = new Insets(3, 4, 3, 4);
constraints.insets = new Insets(3, 3, 3, 3);
add(titleLabel, constraints);

constraints.gridy++;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/edu/project/components/WeatherInfo.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package edu.project.components;

import java.awt.Font;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import edu.project.Context;
import java.awt.BorderLayout;
Expand All @@ -11,6 +13,7 @@ public class WeatherInfo extends JPanel {
public WeatherInfo(Context context) {
setLayout(new BorderLayout());
setOpaque(false);
setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));

JPanel leftPanel = new JPanel();
leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.Y_AXIS));
Expand Down
36 changes: 27 additions & 9 deletions src/main/java/edu/project/components/WeatherIsland.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package edu.project.components;

import java.awt.FlowLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JPanel;

import com.formdev.flatlaf.FlatClientProperties;
Expand All @@ -13,20 +15,36 @@

import edu.project.components.weathercards.WeatherGroup;

import java.awt.BorderLayout;

public class WeatherIsland extends JPanel {
public WeatherIsland(Context context) {
putClientProperty(FlatClientProperties.STYLE,
"background: tint(@background,50%); border: 8,8,8,8,shade(@background,10%),,16");
setOpaque(false);

setLayout(new FlowLayout(FlowLayout.CENTER));

WeatherInfo weatherInfo = new WeatherInfo(context);

add(weatherInfo);
add(new WeatherGroup());
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

WeatherInfo weatherInfo = new WeatherInfo(context);

// Maximize Width and Minimize Height
weatherInfo.setMaximumSize(
new Dimension(
weatherInfo.getMaximumSize().width,
weatherInfo.getPreferredSize().height));

add(weatherInfo);

add(Box.createVerticalStrut(8));

WeatherGroup weatherGroup = new WeatherGroup();

// Maximize Width and Minimize Height
weatherGroup.setMaximumSize(
new Dimension(
weatherGroup.getMaximumSize().width,
weatherGroup.getPreferredSize().height));

add(weatherGroup);

}

@Override
Expand Down

0 comments on commit 5021f82

Please sign in to comment.