Hi all. Iv made an personal organiser application in netbeans and Id like to password it for extra marks. Iv been using my textbook and written the following code, which compiles fine, but i dont know how to use it. What id like it to do is ask for a username and password when the program is first run, it dosent really matter if it isnt the right password as long as it looks like it works! Heres the code iv done so far. If anyone could help id be really greatful!
public class TestApp implements ActionListener {
JTextField textField;
public void actionPerformed(ActionEvent e) {
JButton button = (JButton)e.getSource();
String ac = button.getActionCommand();
if(ac.equals("log in"))
System.out.println("logging in..." + textField.getText());
}
private JPanel getContent() {
textField = new JTextField(12);
JButton logIn = new JButton("log in");
logIn.setActionCommand("log in");
logIn.addActionListener(this);
JPanel p = new JPanel();
p.add(new JLabel("name:"));
p.add(textField);
JPanel panel = new JPanel(new BorderLayout());
panel.add(new JLabel("sign in", JLabel.CENTER), "North");
panel.add(p, "Center");
p = new JPanel();
p.add(logIn);
panel.add(p, "South");
return panel;
}
}