Solution.You forgot to put 4 braces at the end of the file
javax.swing.JPasswordField;
importjavax.swing.JTextField;
importjavax.swing.JFrame;
importjavax.swing.JButton;
importjava.awt.FlowLayout;
importjava.awt.event.ActionListener;
importjava.awt.event.ActionEvent;
publicclass Frame extends JFrame{
privateJButton login;
privateJTextField user;
privateJPasswordField pass;
publicFrame(){
super("Login");
setLayout(newFlowLayout());
user = newJTextField(15);
add(user);
pass = newJPasswordField(15);
add(pass);
login = newJButton("Login");
add(login);
login.addActionListener(new ButtonListener());
}
public class ButtonListener implements ActionListener{
publicvoid actionPerformed(ActionEvent event) {
if(user.getText().trim().length()== 0 || pass.getText.equals().length() == 0){
JOptionPane.showMessageDialog(null,"Please fill out both of the text-boxes");
}
}
}
}
Comments
Leave a comment