import javax.swing.*;
public class PanelLogin extends JPanel {
  private JTextField nom, mdp;
  public PanelLogin() {
    nom = new JTextField(15);
    mdp = new JTextField(8);
    add(new JLabel("Nom :"));
    add(nom);
    add(new JLabel("Mot de passe :"));
    add(mdp);
  }
  public boolean isOk() {
    return Utilisateur.verifier(nom.getText(), mdp.getText());
  }
}


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Fenetre extends JFrame {
  private JLabel label = new JLabel();
  private PanelLogin pl = new PanelLogin();
  public Fenetre() {
    Container cp = getContentPane();
    cp.add(pl, BorderLayout.NORTH);
    cp.add(label, BorderLayout.SOUTH);
    JButton afficher = new JButton("Afficher");
    cp.add(afficher, BorderLayout.EAST);
    afficher.addActionListener(
      new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          if (pl.isOk())
            label.setText("Correct");
          else
            label.setText("Incorrect");
          repaint();
        }
      });
    pack();
    setVisible(true);
  }
  public static void main(String[] args) {
    new Fenetre();
  }
}