diff options
Diffstat (limited to 'enigma-swing/src/main/java/cuchaz')
3 files changed, 15 insertions, 12 deletions
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/dialog/AbstractDialog.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/dialog/AbstractDialog.java index a4d8e1f5..b179eac1 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/dialog/AbstractDialog.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/dialog/AbstractDialog.java | |||
| @@ -8,6 +8,7 @@ import javax.swing.JDialog; | |||
| 8 | import javax.swing.JLabel; | 8 | import javax.swing.JLabel; |
| 9 | import javax.swing.JPanel; | 9 | import javax.swing.JPanel; |
| 10 | 10 | ||
| 11 | import cuchaz.enigma.gui.util.ScaleUtil; | ||
| 11 | import cuchaz.enigma.utils.I18n; | 12 | import cuchaz.enigma.utils.I18n; |
| 12 | import cuchaz.enigma.utils.Pair; | 13 | import cuchaz.enigma.utils.Pair; |
| 13 | import cuchaz.enigma.utils.validation.ValidationContext; | 14 | import cuchaz.enigma.utils.validation.ValidationContext; |
| @@ -34,7 +35,7 @@ public abstract class AbstractDialog extends JDialog { | |||
| 34 | Component component = entry.b; | 35 | Component component = entry.b; |
| 35 | 36 | ||
| 36 | c.gridy = i; | 37 | c.gridy = i; |
| 37 | c.insets = new Insets(4, 4, 4, 4); | 38 | c.insets = ScaleUtil.getInsets(4, 4, 4, 4); |
| 38 | 39 | ||
| 39 | c.gridx = 0; | 40 | c.gridx = 0; |
| 40 | c.weightx = 0.0; | 41 | c.weightx = 0.0; |
| @@ -49,19 +50,13 @@ public abstract class AbstractDialog extends JDialog { | |||
| 49 | inputContainer.add(component, c); | 50 | inputContainer.add(component, c); |
| 50 | } | 51 | } |
| 51 | contentPane.add(inputContainer, BorderLayout.CENTER); | 52 | contentPane.add(inputContainer, BorderLayout.CENTER); |
| 52 | Container buttonContainer = new JPanel(new GridBagLayout()); | 53 | Container buttonContainer = new JPanel(new FlowLayout(FlowLayout.RIGHT, ScaleUtil.scale(4), ScaleUtil.scale(4))); |
| 53 | c = new GridBagConstraints(); | ||
| 54 | c.weightx = 1.0; | ||
| 55 | c.insets = new Insets(4, 4, 4, 4); | ||
| 56 | c.anchor = GridBagConstraints.LINE_END; | ||
| 57 | JButton connectButton = new JButton(I18n.translate(confirmAction)); | 54 | JButton connectButton = new JButton(I18n.translate(confirmAction)); |
| 58 | connectButton.addActionListener(event -> confirm()); | 55 | connectButton.addActionListener(event -> confirm()); |
| 59 | buttonContainer.add(connectButton, c); | 56 | buttonContainer.add(connectButton); |
| 60 | c.weightx = 0.0; | ||
| 61 | c.anchor = GridBagConstraints.CENTER; | ||
| 62 | JButton abortButton = new JButton(I18n.translate(cancelAction)); | 57 | JButton abortButton = new JButton(I18n.translate(cancelAction)); |
| 63 | abortButton.addActionListener(event -> cancel()); | 58 | abortButton.addActionListener(event -> cancel()); |
| 64 | buttonContainer.add(abortButton, c); | 59 | buttonContainer.add(abortButton); |
| 65 | contentPane.add(buttonContainer, BorderLayout.SOUTH); | 60 | contentPane.add(buttonContainer, BorderLayout.SOUTH); |
| 66 | 61 | ||
| 67 | pack(); | 62 | pack(); |
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/dialog/ConnectToServerDialog.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/dialog/ConnectToServerDialog.java index 79b0c4e0..d78e5654 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/dialog/ConnectToServerDialog.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/dialog/ConnectToServerDialog.java | |||
| @@ -11,6 +11,7 @@ import javax.swing.JPasswordField; | |||
| 11 | import javax.swing.JTextField; | 11 | import javax.swing.JTextField; |
| 12 | 12 | ||
| 13 | import cuchaz.enigma.gui.elements.ValidatableTextField; | 13 | import cuchaz.enigma.gui.elements.ValidatableTextField; |
| 14 | import cuchaz.enigma.gui.util.ScaleUtil; | ||
| 14 | import cuchaz.enigma.network.EnigmaServer; | 15 | import cuchaz.enigma.network.EnigmaServer; |
| 15 | import cuchaz.enigma.utils.Pair; | 16 | import cuchaz.enigma.utils.Pair; |
| 16 | import cuchaz.enigma.utils.ServerAddress; | 17 | import cuchaz.enigma.utils.ServerAddress; |
| @@ -25,7 +26,10 @@ public class ConnectToServerDialog extends AbstractDialog { | |||
| 25 | public ConnectToServerDialog(Frame owner) { | 26 | public ConnectToServerDialog(Frame owner) { |
| 26 | super(owner, "prompt.connect.title", "prompt.connect.confirm", "prompt.cancel"); | 27 | super(owner, "prompt.connect.title", "prompt.connect.confirm", "prompt.cancel"); |
| 27 | 28 | ||
| 28 | setSize(new Dimension(400, 185)); | 29 | Dimension preferredSize = getPreferredSize(); |
| 30 | preferredSize.width = ScaleUtil.scale(400); | ||
| 31 | setPreferredSize(preferredSize); | ||
| 32 | pack(); | ||
| 29 | setLocationRelativeTo(owner); | 33 | setLocationRelativeTo(owner); |
| 30 | } | 34 | } |
| 31 | 35 | ||
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/dialog/CreateServerDialog.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/dialog/CreateServerDialog.java index f2bc7dbe..ddd3bc37 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/dialog/CreateServerDialog.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/dialog/CreateServerDialog.java | |||
| @@ -8,6 +8,7 @@ import java.util.List; | |||
| 8 | 8 | ||
| 9 | import cuchaz.enigma.gui.elements.ValidatablePasswordField; | 9 | import cuchaz.enigma.gui.elements.ValidatablePasswordField; |
| 10 | import cuchaz.enigma.gui.elements.ValidatableTextField; | 10 | import cuchaz.enigma.gui.elements.ValidatableTextField; |
| 11 | import cuchaz.enigma.gui.util.ScaleUtil; | ||
| 11 | import cuchaz.enigma.network.EnigmaServer; | 12 | import cuchaz.enigma.network.EnigmaServer; |
| 12 | import cuchaz.enigma.utils.Pair; | 13 | import cuchaz.enigma.utils.Pair; |
| 13 | import cuchaz.enigma.utils.validation.Message; | 14 | import cuchaz.enigma.utils.validation.Message; |
| @@ -21,7 +22,10 @@ public class CreateServerDialog extends AbstractDialog { | |||
| 21 | public CreateServerDialog(Frame owner) { | 22 | public CreateServerDialog(Frame owner) { |
| 22 | super(owner, "prompt.create_server.title", "prompt.create_server.confirm", "prompt.cancel"); | 23 | super(owner, "prompt.create_server.title", "prompt.create_server.confirm", "prompt.cancel"); |
| 23 | 24 | ||
| 24 | setSize(new Dimension(400, 150)); | 25 | Dimension preferredSize = getPreferredSize(); |
| 26 | preferredSize.width = ScaleUtil.scale(400); | ||
| 27 | setPreferredSize(preferredSize); | ||
| 28 | pack(); | ||
| 25 | setLocationRelativeTo(owner); | 29 | setLocationRelativeTo(owner); |
| 26 | } | 30 | } |
| 27 | 31 | ||