2022-01-27 19:19:09 +01:00
|
|
|
import java.awt.BorderLayout;
|
|
|
|
import java.awt.FlowLayout;
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
|
|
|
|
import javax.swing.JButton;
|
|
|
|
import javax.swing.JDialog;
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
import javax.swing.border.EmptyBorder;
|
|
|
|
import javax.swing.JTextField;
|
|
|
|
import javax.swing.BoxLayout;
|
|
|
|
import javax.swing.JLabel;
|
|
|
|
import javax.swing.JPasswordField;
|
|
|
|
|
|
|
|
public class LoginGUI extends JDialog implements ActionListener {
|
|
|
|
|
|
|
|
private MyMail app;
|
|
|
|
|
|
|
|
private final JPanel contentPanel = new JPanel();
|
|
|
|
private JTextField address;
|
|
|
|
private JTextField user;
|
|
|
|
private JPasswordField pw;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Launch the application.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create the dialog.
|
|
|
|
*/
|
|
|
|
public LoginGUI(MyMail app) {
|
|
|
|
this.app = app;
|
|
|
|
setTitle("Login");
|
|
|
|
setBounds(100, 100, 251, 220);
|
|
|
|
setLocationRelativeTo(null);
|
|
|
|
getContentPane().setLayout(new BorderLayout());
|
2022-01-31 13:00:00 +01:00
|
|
|
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
2022-01-27 19:19:09 +01:00
|
|
|
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
|
|
|
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
|
|
|
contentPanel.setLayout(null);
|
|
|
|
{
|
|
|
|
address = new JTextField();
|
|
|
|
address.setBounds(10, 26, 215, 20);
|
|
|
|
contentPanel.add(address);
|
|
|
|
address.setColumns(10);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
user = new JTextField();
|
|
|
|
user.setBounds(10, 72, 215, 20);
|
|
|
|
contentPanel.add(user);
|
|
|
|
user.setColumns(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
JLabel lblNewLabel = new JLabel("Server Address");
|
|
|
|
lblNewLabel.setBounds(10, 11, 414, 14);
|
|
|
|
contentPanel.add(lblNewLabel);
|
|
|
|
|
|
|
|
JLabel lblNewLabel_1 = new JLabel("Username");
|
|
|
|
lblNewLabel_1.setBounds(10, 57, 414, 14);
|
|
|
|
contentPanel.add(lblNewLabel_1);
|
|
|
|
|
|
|
|
JLabel lblNewLabel_2 = new JLabel("Password");
|
|
|
|
lblNewLabel_2.setBounds(10, 103, 414, 14);
|
|
|
|
contentPanel.add(lblNewLabel_2);
|
|
|
|
|
|
|
|
pw = new JPasswordField();
|
|
|
|
pw.setBounds(10, 118, 215, 20);
|
|
|
|
contentPanel.add(pw);
|
|
|
|
{
|
|
|
|
JPanel buttonPane = new JPanel();
|
|
|
|
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
|
|
|
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
|
|
|
{
|
|
|
|
JButton okButton = new JButton("OK");
|
|
|
|
okButton.setActionCommand("OK");
|
|
|
|
okButton.addActionListener(this);
|
|
|
|
buttonPane.add(okButton);
|
|
|
|
getRootPane().setDefaultButton(okButton);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
JButton cancelButton = new JButton("Cancel");
|
|
|
|
cancelButton.setActionCommand("Cancel");
|
|
|
|
cancelButton.addActionListener(this);
|
|
|
|
buttonPane.add(cancelButton);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setVisible(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
if (e.getActionCommand().equals("OK")) {
|
|
|
|
app.start(address.getText(), 110, user.getText(), new String(pw.getPassword()));
|
|
|
|
} else if (e.getActionCommand().equals("Cancel")) {
|
2022-01-31 13:00:00 +01:00
|
|
|
dispose();
|
2022-01-27 19:19:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|