From c039b643fa3bc25cfc41511c881992e80ca9b1de Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 21 Jun 2011 04:26:50 +0200 Subject: Allow logging in by pressing enter in login panel git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@539 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/view/impl/LoginPanel.java | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/jrummikub') diff --git a/src/jrummikub/view/impl/LoginPanel.java b/src/jrummikub/view/impl/LoginPanel.java index 5241896..4712630 100644 --- a/src/jrummikub/view/impl/LoginPanel.java +++ b/src/jrummikub/view/impl/LoginPanel.java @@ -40,25 +40,30 @@ class LoginPanel extends JPanel implements ILoginPanel { c.weightx = 1; c.weighty = 1; + ActionListener loginAction = new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + login(); + } + }; + userNameField = addInputRow("Benutzername:", new JTextField()); userNameField.setText("test1"); + userNameField.addActionListener(loginAction); serverNameField = addInputRow("Server:", new JTextField()); serverNameField.setText("universe-factory.net"); + serverNameField.addActionListener(loginAction); passwordField = addInputRow("Passwort:", new JPasswordField()); + passwordField.addActionListener(loginAction); channelNameField = addInputRow("Channel:", new JTextField()); channelNameField.setText("jrummikub@muc.universe-factory.net"); + channelNameField.addActionListener(loginAction); add(Box.createVerticalGlue(), c); c.gridwidth = 1; c.weighty = 0; JButton loginButton = new JButton("Login"); - loginButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent arg0) { - loginEvent.emit(new LoginData(userNameField.getText(), serverNameField - .getText(), passwordField.getText(), channelNameField.getText())); - } - }); + loginButton.addActionListener(loginAction); add(loginButton, c); c.weightx = 0; @@ -102,4 +107,9 @@ class LoginPanel extends JPanel implements ILoginPanel { add(textField, c); return textField; } + + private void login() { + loginEvent.emit(new LoginData(userNameField.getText(), serverNameField + .getText(), passwordField.getText(), channelNameField.getText())); + } } -- cgit v1.2.3