1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| public class Login extends JDialog {
private static final long serialVersionUID = 3958672121654763604L;
private static Login instance = new Login();
private static User theuser = null;
private JPanel jContentPane = null;
private JLabel jLabel1 = null;
private JButton jButton1 = null;
private JComboBox jComboBox1 = null;
public Login(){
super();
initialize();
}
public static Login getInstance(User user) {
theuser = user;
return instance;
}
private void initialize() {
this.setPreferredSize(new Dimension(300,200));
this.setResizable(false);
this.setModal(true);
this.setTitle("Login");
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.setContentPane(getJContentPane());
this.pack();
this.setVisible(true);
}
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(15, 19, 129, 16));
jLabel1.setText("Choisissez votre role :");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabel1, null);
jContentPane.add(getJButton1(), null);
jContentPane.add(getJComboBox1(), null);
}
return jContentPane;
}
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton();
jButton1.setBounds(new Rectangle(191, 130, 82, 30));
jButton1.setText("Quitter");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
}
return jButton1;
}
private JComboBox getJComboBox1() {
if (jComboBox1 == null) {
String[] roles = { "Trader", "Middle Office" };
jComboBox1 = new JComboBox(roles);
jComboBox1.setSelectedIndex(-1);
jComboBox1.setBounds(new Rectangle(15, 54, 142, 26));
jComboBox1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
theuser.setRole(jComboBox1.getSelectedItem().toString());
// System.out.print(jComboBox1.getSelectedItem().toString());
}
});
}
return jComboBox1;
}
} |
Partager