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
| public class Interface extends Frame implements ActionListener{
private static final long serialVersionUID = 1L;
private JDesktopPane jDesktopPane = null;
private JTextField jTextField = null;
private JButton jButton = null;
private JLabel jLabel = null;
private JLabel jLabel1 = null;
public Interface() {
super();
initialize();
}
private void initialize() {
this.setSize(300, 200);
this.setTitle("IP Validator");
this.setResizable(false);
this.add(getJDesktopPane());
}
private JDesktopPane getJDesktopPane() {
jDesktopPane = new JDesktopPane();
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(20, 12, 263, 17));
jLabel.setText("Enter a IP Adress and click on button for");
jDesktopPane.add(jLabel1, null);
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(20, 28, 263, 16));
jLabel1.setText("checking if the IP is correct.");
jDesktopPane.add(jLabel, null);
jDesktopPane.add(getJTextField(), null);
jDesktopPane.add(getJButton(), null);
return jDesktopPane;
}
/**
* This method initializes jTextField
*/
private JTextField getJTextField() {
jTextField = new JTextField();
jTextField.setBounds(new Rectangle(20, 71, 166, 26));
return jTextField;
}
/**
* This method initializes jButton
*/
private JButton getJButton() {
jButton = new JButton();
jButton.setBounds(new Rectangle(20, 102, 95, 24));
jButton.setText("Check IP");
return jButton;
}
public void actionPerformed(ActionEvent e) {
if(e.getSource() == jButton){//Si l'action émane bien du bouton
System.out.println("checked");
}
}
} |
Partager