From 6e211a01a1297934dc7268db4b924df5b9d39d88 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Thu, 13 Feb 2020 10:11:25 +0100 Subject: [PATCH] Fixed error message layout in LoginDialog Updated envoy-common dependency to v0.2-alpha in pom.xml --- pom.xml | 2 +- .../java/envoy/client/ui/LoginDialog.java | 31 ++++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index 6106227..e670832 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ com.github.informatik-ag-ngl envoy-common - f~advanced_login-SNAPSHOT + v0.2-alpha diff --git a/src/main/java/envoy/client/ui/LoginDialog.java b/src/main/java/envoy/client/ui/LoginDialog.java index 40991c6..09fd551 100644 --- a/src/main/java/envoy/client/ui/LoginDialog.java +++ b/src/main/java/envoy/client/ui/LoginDialog.java @@ -100,19 +100,9 @@ public class LoginDialog extends JDialog { }); // Listen to handshake rejections - EventBus.getInstance().register(HandshakeRejectionEvent.class, evt -> { - if (errorMessage != null) contentPanel.remove(errorMessage); - clearPasswordFields(); - errorMessage = new JLabel(evt.get()); - gbc_errorMessage = new GridBagConstraints(); - gbc_errorMessage.gridx = 2; - gbc_errorMessage.gridy = 0; - gbc_errorMessage.fill = GridBagConstraints.HORIZONTAL; - gbc_errorMessage.insets = new Insets(5, 5, 5, 5); - contentPanel.add(errorMessage, gbc_errorMessage); - contentPanel.revalidate(); - contentPanel.repaint(); - }); + EventBus.getInstance() + .register(HandshakeRejectionEvent.class, + evt -> { clearPasswordFields(); errorMessage.setVisible(true); errorMessage.setText(evt.get()); }); // Exit the application when the dialog is cancelled cancelButton.addActionListener(evt -> { logger.info("The login process has been cancelled. Exiting..."); System.exit(0); }); @@ -159,6 +149,7 @@ public class LoginDialog extends JDialog { private void initUi() { setSize(338, 123); setLocationRelativeTo(null); + setResizable(false); getContentPane().setLayout(new BorderLayout()); contentPanel = new JPanel(); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); @@ -217,6 +208,16 @@ public class LoginDialog extends JDialog { gbc_repeatPasswordField.gridx = 1; gbc_repeatPasswordField.gridy = 2; + errorMessage = new JLabel(); + gbc_errorMessage = new GridBagConstraints(); + gbc_errorMessage.gridx = 1; + gbc_errorMessage.gridy = 3; + gbc_errorMessage.fill = GridBagConstraints.HORIZONTAL; + gbc_errorMessage.insets = new Insets(5, 5, 5, 5); + errorMessage.setForeground(Color.RED); + errorMessage.setVisible(false); + contentPanel.add(errorMessage, gbc_errorMessage); + buttonPane = new JPanel(); registerText = new JTextPane(); @@ -233,14 +234,14 @@ public class LoginDialog extends JDialog { case ItemEvent.SELECTED: contentPanel.add(lblRepeatPassword, gbc_lblRepeatPassword); contentPanel.add(repeatPasswordField, gbc_repeatPasswordField); - setSize(338, 148); + setSize(338, 173); break; case ItemEvent.DESELECTED: if (repeatPasswordField.getParent() == contentPanel) { contentPanel.remove(lblRepeatPassword); contentPanel.remove(repeatPasswordField); - setSize(338, 123); + setSize(338, 148); } break; }