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
This commit is contained in:
Matthias Schiffer 2011-06-21 04:26:50 +02:00
parent 71aae25108
commit c039b643fa

View file

@ -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()));
}
}