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
| import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class frame extends JFrame{
private JButton login;
private JTextField user;
private JPasswordField pass;
public frame(){
super("LOgin page");
setVisible(true);
setSize(200, 200);
setLayout(new FlowLayout());
user = new JTextField(22);
add(user);
pass = new JPasswordField(22);
add(pass);
login = new JButton("Login");
add(login);
login.addActionListener(new ButtonListener());
}
public class ButtonListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent evt) {
// TODO Auto-generated method stub
if(user.getText().trim().length() == 0 || pass.getText().length() == 0){
JOptionPane.showMessageDialog(null, "Aucune entre na eté detecté");
}else{
if(user.getText().equals("cool") && pass.getText().equals("cool"))
{
fenetre fen = new fenetre();
}else{
JOptionPane.showMessageDialog(null, "Incorrect");
}
}
} |
Partager