From 648941706d7365a573f6180f434977b77fb0be86 Mon Sep 17 00:00:00 2001 From: lantzelot-swe Date: Fri, 12 Feb 2021 11:13:58 +0100 Subject: [PATCH] fix: Moves config fields to top, UI adjustments --- .../se/lantz/gui/CombinedJoystickPanel.java | 29 ++++++--- src/main/java/se/lantz/gui/InfoPanel.java | 2 +- src/main/java/se/lantz/gui/JoystickPanel.java | 31 +++++----- src/main/java/se/lantz/gui/SystemPanel.java | 60 +++++++++++-------- 4 files changed, 72 insertions(+), 50 deletions(-) diff --git a/src/main/java/se/lantz/gui/CombinedJoystickPanel.java b/src/main/java/se/lantz/gui/CombinedJoystickPanel.java index d4de980..1392980 100644 --- a/src/main/java/se/lantz/gui/CombinedJoystickPanel.java +++ b/src/main/java/se/lantz/gui/CombinedJoystickPanel.java @@ -1,16 +1,18 @@ package se.lantz.gui; -import javax.swing.JPanel; - -import se.lantz.model.MainViewModel; - -import java.awt.GridBagLayout; +import java.awt.Dimension; import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; import java.awt.Insets; import java.beans.Beans; +import javax.swing.JPanel; +import javax.swing.JSeparator; +import javax.swing.SwingConstants; import javax.swing.border.TitledBorder; +import se.lantz.model.MainViewModel; + public class CombinedJoystickPanel extends JPanel { private JoystickPanel port1Panel; @@ -26,16 +28,25 @@ public class CombinedJoystickPanel extends JPanel GridBagConstraints gbc_port1Panel = new GridBagConstraints(); gbc_port1Panel.weighty = 1.0; gbc_port1Panel.anchor = GridBagConstraints.NORTHWEST; - gbc_port1Panel.insets = new Insets(0, 0, 0, 5); + gbc_port1Panel.insets = new Insets(0, 0, 0, 0); gbc_port1Panel.gridx = 0; gbc_port1Panel.gridy = 0; gbc_port1Panel.fill = GridBagConstraints.VERTICAL; add(getPort1Panel(), gbc_port1Panel); + + GridBagConstraints gbc_separator = new GridBagConstraints(); + gbc_separator.weighty = 1.0; + gbc_separator.anchor = GridBagConstraints.NORTH; + gbc_separator.gridx = 1; + gbc_separator.gridy = 0; + gbc_separator.fill = GridBagConstraints.VERTICAL; + JSeparator separator = new JSeparator(SwingConstants.VERTICAL); + separator.setPreferredSize(new Dimension(1,1)); + add(separator, gbc_separator); + GridBagConstraints gbc_port2Panel = new GridBagConstraints(); - gbc_port2Panel.weighty = 1.0; - gbc_port2Panel.weightx = 1.0; gbc_port2Panel.anchor = GridBagConstraints.NORTHWEST; - gbc_port2Panel.gridx = 1; + gbc_port2Panel.gridx = 2; gbc_port2Panel.gridy = 0; gbc_port2Panel.fill = GridBagConstraints.VERTICAL; add(getPort2Panel(), gbc_port2Panel); diff --git a/src/main/java/se/lantz/gui/InfoPanel.java b/src/main/java/se/lantz/gui/InfoPanel.java index cd9cc8a..dd405d5 100644 --- a/src/main/java/se/lantz/gui/InfoPanel.java +++ b/src/main/java/se/lantz/gui/InfoPanel.java @@ -137,7 +137,7 @@ public class InfoPanel extends JPanel descriptionTabbedPane.addTab("es", null, getDescriptionEsPanel(), null); descriptionTabbedPane.addTab("it", null, getDescriptionItPanel(), null); GridBagConstraints gbc_descriptionTabbedPane = new GridBagConstraints(); - gbc_descriptionTabbedPane.insets = new Insets(0, 5, 10, 0); + gbc_descriptionTabbedPane.insets = new Insets(0, 5, 9, 0); gbc_descriptionTabbedPane.gridwidth = 2; gbc_descriptionTabbedPane.weighty = 1.0; gbc_descriptionTabbedPane.fill = GridBagConstraints.BOTH; diff --git a/src/main/java/se/lantz/gui/JoystickPanel.java b/src/main/java/se/lantz/gui/JoystickPanel.java index 98e6724..a14e07a 100644 --- a/src/main/java/se/lantz/gui/JoystickPanel.java +++ b/src/main/java/se/lantz/gui/JoystickPanel.java @@ -44,7 +44,7 @@ public class JoystickPanel extends JPanel this.model = model; this.setPreferredSize(new Dimension(390, 510)); this.setMinimumSize(new Dimension(390, 510)); - setBorder(new TitledBorder(null, "Port " + portnumber, TitledBorder.LEADING, TitledBorder.TOP, null, null)); +// setBorder(new TitledBorder(null, "Port " + portnumber, TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWeights = new double[] { 0.0, 1.0, 0.0 }; @@ -53,9 +53,9 @@ public class JoystickPanel extends JPanel gbc_primaryJoyCheckBox.weightx = 1.0; gbc_primaryJoyCheckBox.gridwidth = 3; gbc_primaryJoyCheckBox.anchor = GridBagConstraints.WEST; - gbc_primaryJoyCheckBox.insets = new Insets(0, 5, 5, 0); + gbc_primaryJoyCheckBox.insets = new Insets(5, 0, 5, 0); gbc_primaryJoyCheckBox.gridx = 0; - gbc_primaryJoyCheckBox.gridy = 0; + gbc_primaryJoyCheckBox.gridy = 1; add(getPrimaryJoyCheckBox(), gbc_primaryJoyCheckBox); GridBagConstraints gbc_joystickStickPanel = new GridBagConstraints(); gbc_joystickStickPanel.weightx = 1.0; @@ -63,13 +63,13 @@ public class JoystickPanel extends JPanel gbc_joystickStickPanel.insets = new Insets(0, 0, 5, 0); gbc_joystickStickPanel.fill = GridBagConstraints.BOTH; gbc_joystickStickPanel.gridx = 0; - gbc_joystickStickPanel.gridy = 1; + gbc_joystickStickPanel.gridy = 2; add(getJoystickStickPanel(), gbc_joystickStickPanel); GridBagConstraints gbc_leftFireComboBox = new GridBagConstraints(); gbc_leftFireComboBox.anchor = GridBagConstraints.WEST; gbc_leftFireComboBox.insets = new Insets(45, 5, 5, 5); gbc_leftFireComboBox.gridx = 0; - gbc_leftFireComboBox.gridy = 2; + gbc_leftFireComboBox.gridy = 3; add(getLeftFireComboBox(), gbc_leftFireComboBox); GridBagConstraints gbc_imageLabel = new GridBagConstraints(); gbc_imageLabel.gridheight = 3; @@ -77,40 +77,41 @@ public class JoystickPanel extends JPanel gbc_imageLabel.fill = GridBagConstraints.BOTH; gbc_imageLabel.insets = new Insets(0, 0, 5, 5); gbc_imageLabel.gridx = 1; - gbc_imageLabel.gridy = 2; + gbc_imageLabel.gridy = 3; add(getImageLabel(), gbc_imageLabel); GridBagConstraints gbc_rightFireComboBox = new GridBagConstraints(); gbc_rightFireComboBox.anchor = GridBagConstraints.EAST; gbc_rightFireComboBox.insets = new Insets(45, 0, 5, 5); gbc_rightFireComboBox.gridx = 2; - gbc_rightFireComboBox.gridy = 2; + gbc_rightFireComboBox.gridy = 3; add(getRightFireComboBox(), gbc_rightFireComboBox); GridBagConstraints gbc_tlComboBox = new GridBagConstraints(); gbc_tlComboBox.anchor = GridBagConstraints.WEST; gbc_tlComboBox.insets = new Insets(30, 5, 5, 5); gbc_tlComboBox.gridx = 0; - gbc_tlComboBox.gridy = 3; + gbc_tlComboBox.gridy = 4; add(getTlComboBox(), gbc_tlComboBox); GridBagConstraints gbc_trComboBox = new GridBagConstraints(); gbc_trComboBox.anchor = GridBagConstraints.EAST; gbc_trComboBox.insets = new Insets(30, 0, 5, 5); gbc_trComboBox.gridx = 2; - gbc_trComboBox.gridy = 3; + gbc_trComboBox.gridy = 4; add(getTrComboBox(), gbc_trComboBox); GridBagConstraints gbc_joystickBottomPanel = new GridBagConstraints(); + gbc_joystickBottomPanel.weighty = 1.0; gbc_joystickBottomPanel.insets = new Insets(0, 0, 5, 0); gbc_joystickBottomPanel.gridwidth = 3; gbc_joystickBottomPanel.fill = GridBagConstraints.BOTH; gbc_joystickBottomPanel.gridx = 0; - gbc_joystickBottomPanel.gridy = 5; + gbc_joystickBottomPanel.gridy = 6; add(getJoystickBottomPanel(), gbc_joystickBottomPanel); GridBagConstraints gbc_configPanel = new GridBagConstraints(); gbc_configPanel.anchor = GridBagConstraints.NORTH; - gbc_configPanel.weighty = 1.0; + gbc_configPanel.weighty = 0.0; gbc_configPanel.fill = GridBagConstraints.HORIZONTAL; gbc_configPanel.gridx = 0; gbc_configPanel.gridwidth = 3; - gbc_configPanel.gridy = 6; + gbc_configPanel.gridy = 0; add(getConfigPanel(), gbc_configPanel); if (!Beans.isDesignTime()) { @@ -245,7 +246,7 @@ public class JoystickPanel extends JPanel { if (configLabel == null) { - configLabel = new JLabel("Config:"); + configLabel = new JLabel("Port " + portnumber + ":"); } return configLabel; } @@ -292,12 +293,12 @@ public class JoystickPanel extends JPanel configPanel.setLayout(gbl_configPanel); GridBagConstraints gbc_configLabel = new GridBagConstraints(); gbc_configLabel.anchor = GridBagConstraints.WEST; - gbc_configLabel.insets = new Insets(0, 5, 0, 5); + gbc_configLabel.insets = new Insets(4, 5, 0, 5); gbc_configLabel.gridx = 0; gbc_configLabel.gridy = 0; configPanel.add(getConfigLabel(), gbc_configLabel); GridBagConstraints gbc_configTextField = new GridBagConstraints(); - gbc_configTextField.insets = new Insets(0, 0, 0, 5); + gbc_configTextField.insets = new Insets(3, 0, 0, 5); gbc_configTextField.fill = GridBagConstraints.HORIZONTAL; gbc_configTextField.weightx = 1.0; gbc_configTextField.anchor = GridBagConstraints.NORTHWEST; diff --git a/src/main/java/se/lantz/gui/SystemPanel.java b/src/main/java/se/lantz/gui/SystemPanel.java index 132d3ed..8202497 100644 --- a/src/main/java/se/lantz/gui/SystemPanel.java +++ b/src/main/java/se/lantz/gui/SystemPanel.java @@ -68,6 +68,7 @@ public class SystemPanel extends JPanel private JCheckBox reu512kRadioButton; private JCheckBox reu2mbRadioButton; private JCheckBox reu16mbRadioButton; + private JLabel dummyLabel; public SystemPanel(SystemModel model) { @@ -80,48 +81,54 @@ public class SystemPanel extends JPanel gbc_radioPanel.insets = new Insets(0, 0, 5, 0); gbc_radioPanel.fill = GridBagConstraints.BOTH; gbc_radioPanel.gridx = 0; - gbc_radioPanel.gridy = 0; + gbc_radioPanel.gridy = 1; add(getRadioPanel(), gbc_radioPanel); GridBagConstraints gbc_typePanel = new GridBagConstraints(); gbc_typePanel.weightx = 0.5; - gbc_typePanel.insets = new Insets(0, 5, 5, 0); + gbc_typePanel.insets = new Insets(0, 5, 5, 5); gbc_typePanel.fill = GridBagConstraints.BOTH; gbc_typePanel.gridx = 0; - gbc_typePanel.gridy = 1; + gbc_typePanel.gridy = 2; add(getTypePanel(), gbc_typePanel); GridBagConstraints gbc_drivePanel = new GridBagConstraints(); - gbc_drivePanel.insets = new Insets(0, 0, 5, 5); + gbc_drivePanel.insets = new Insets(0, 0, 5, 0); gbc_drivePanel.weightx = 0.5; gbc_drivePanel.fill = GridBagConstraints.BOTH; gbc_drivePanel.gridx = 1; - gbc_drivePanel.gridy = 1; + gbc_drivePanel.gridy = 2; add(getDrivePanel(), gbc_drivePanel); GridBagConstraints gbc_displayPanel = new GridBagConstraints(); gbc_displayPanel.weightx = 1.0; - gbc_displayPanel.insets = new Insets(0, 5, 5, 5); + gbc_displayPanel.insets = new Insets(0, 5, 5, 0); gbc_displayPanel.gridwidth = 2; gbc_displayPanel.fill = GridBagConstraints.BOTH; gbc_displayPanel.gridx = 0; - gbc_displayPanel.gridy = 2; + gbc_displayPanel.gridy = 3; add(getDisplayPanel(), gbc_displayPanel); GridBagConstraints gbc_cardPanel = new GridBagConstraints(); gbc_cardPanel.weightx = 1.0; - gbc_cardPanel.insets = new Insets(0, 5, 5, 5); + gbc_cardPanel.insets = new Insets(0, 5, 5, 0); gbc_cardPanel.gridwidth = 2; gbc_cardPanel.fill = GridBagConstraints.BOTH; gbc_cardPanel.gridx = 0; - gbc_cardPanel.gridy = 3; + gbc_cardPanel.gridy = 4; add(getCardPanel(), gbc_cardPanel); GridBagConstraints gbc_configPanel = new GridBagConstraints(); - gbc_configPanel.weighty = 1.0; gbc_configPanel.anchor = GridBagConstraints.NORTH; gbc_configPanel.gridwidth = 2; gbc_configPanel.weightx = 1.0; - gbc_configPanel.insets = new Insets(0, 0, 0, 5); - gbc_configPanel.fill = GridBagConstraints.BOTH; + gbc_configPanel.insets = new Insets(0, 0, 0, 7); + gbc_configPanel.fill = GridBagConstraints.HORIZONTAL; gbc_configPanel.gridx = 0; - gbc_configPanel.gridy = 4; + gbc_configPanel.gridy = 0; add(getConfigPanel(), gbc_configPanel); + GridBagConstraints gbc_dummyLabel = new GridBagConstraints(); + gbc_dummyLabel.gridwidth = 2; + gbc_dummyLabel.weighty = 1.0; + gbc_dummyLabel.insets = new Insets(0, 0, 0, 0); + gbc_dummyLabel.gridx = 0; + gbc_dummyLabel.gridy = 5; + add(getDummyLabel(), gbc_dummyLabel); if (!Beans.isDesignTime()) { model.addPropertyChangeListener(e -> modelChanged()); @@ -439,19 +446,16 @@ public class SystemPanel extends JPanel GridBagLayout gbl_ramPanel = new GridBagLayout(); ramPanel.setLayout(gbl_ramPanel); GridBagConstraints gbc_bank0CheckBox = new GridBagConstraints(); - gbc_bank0CheckBox.weightx = 1.0; gbc_bank0CheckBox.anchor = GridBagConstraints.WEST; gbc_bank0CheckBox.gridx = 0; gbc_bank0CheckBox.gridy = 0; ramPanel.add(getBank0CheckBox(), gbc_bank0CheckBox); GridBagConstraints gbc_bank1CheckBox = new GridBagConstraints(); - gbc_bank1CheckBox.weightx = 1.0; gbc_bank1CheckBox.anchor = GridBagConstraints.WEST; gbc_bank1CheckBox.gridx = 0; gbc_bank1CheckBox.gridy = 1; ramPanel.add(getBank1CheckBox(), gbc_bank1CheckBox); GridBagConstraints gbc_bank2CheckBox = new GridBagConstraints(); - gbc_bank2CheckBox.weightx = 1.0; gbc_bank2CheckBox.anchor = GridBagConstraints.NORTHWEST; gbc_bank2CheckBox.gridx = 0; gbc_bank2CheckBox.gridy = 2; @@ -465,17 +469,17 @@ public class SystemPanel extends JPanel GridBagConstraints gbc_bank5CheckBox = new GridBagConstraints(); gbc_bank5CheckBox.weightx = 1.0; gbc_bank5CheckBox.anchor = GridBagConstraints.WEST; - gbc_bank5CheckBox.insets = new Insets(0, 0, 5, 0); gbc_bank5CheckBox.gridx = 1; gbc_bank5CheckBox.gridy = 1; ramPanel.add(getBank5CheckBox(), gbc_bank5CheckBox); GridBagConstraints gbc_ramLabel = new GridBagConstraints(); + gbc_ramLabel.gridwidth = 2; gbc_ramLabel.weighty = 1.0; - gbc_ramLabel.insets = new Insets(0, 5, 10, 5); + gbc_ramLabel.insets = new Insets(0, 5, 5, 5); gbc_ramLabel.anchor = GridBagConstraints.NORTHWEST; gbc_ramLabel.weightx = 1.0; - gbc_ramLabel.gridx = 1; - gbc_ramLabel.gridy = 2; + gbc_ramLabel.gridx = 0; + gbc_ramLabel.gridy = 3; ramPanel.add(getRamLabel(), gbc_ramLabel); } return ramPanel; @@ -489,10 +493,10 @@ public class SystemPanel extends JPanel GridBagLayout gbl_configPanel = new GridBagLayout(); configPanel.setLayout(gbl_configPanel); GridBagConstraints gbc_configLabel = new GridBagConstraints(); - gbc_configLabel.gridheight = 2; + gbc_configLabel.gridheight = 1; gbc_configLabel.weighty = 1.0; gbc_configLabel.anchor = GridBagConstraints.NORTHWEST; - gbc_configLabel.insets = new Insets(5, 5, 5, 5); + gbc_configLabel.insets = new Insets(5, 6, 5, 5); gbc_configLabel.gridx = 0; gbc_configLabel.gridy = 0; configPanel.add(getConfigLabel(), gbc_configLabel); @@ -905,7 +909,7 @@ public class SystemPanel extends JPanel { if (reu512kRadioButton == null) { - reu512kRadioButton = new JCheckBox("512K"); + reu512kRadioButton = new JCheckBox("512 Kb"); reu512kRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -923,7 +927,7 @@ public class SystemPanel extends JPanel { if (reu2mbRadioButton == null) { - reu2mbRadioButton = new JCheckBox("2Mb"); + reu2mbRadioButton = new JCheckBox("2 Mb"); reu2mbRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -941,7 +945,7 @@ public class SystemPanel extends JPanel { if (reu16mbRadioButton == null) { - reu16mbRadioButton = new JCheckBox("16Mb"); + reu16mbRadioButton = new JCheckBox("16 Mb"); reu16mbRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -954,4 +958,10 @@ public class SystemPanel extends JPanel } return reu16mbRadioButton; } + private JLabel getDummyLabel() { + if (dummyLabel == null) { + dummyLabel = new JLabel(""); + } + return dummyLabel; + } }