diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-06-21 04:26:50 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-06-21 04:26:50 +0200 |
commit | c039b643fa3bc25cfc41511c881992e80ca9b1de (patch) | |
tree | 9b11f9b957318ba1513c84d4cac2c3cd928d4c51 /src | |
parent | 71aae2510862a4db08395079a37e1d3ddb9df5ce (diff) | |
download | JRummikub-c039b643fa3bc25cfc41511c881992e80ca9b1de.tar JRummikub-c039b643fa3bc25cfc41511c881992e80ca9b1de.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/jrummikub/view/impl/LoginPanel.java | 24 |
1 files changed, 17 insertions, 7 deletions
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())); + } } |