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
| import javax.swing.*;
import java.awt.event.*;
public class MainFrame extends JFrame
implements ActionListener {
public MainFrame () {
super ();
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
setSize (500, 500);
final JPanel panel = new JPanel ();
m_statut = new JLabel ("Connexion en cours ...");
m_statut.setVisible (false);
panel.add (m_statut);
final JButton valider = new JButton ("Valider");
valider.addActionListener (this);
panel.add (valider);
getContentPane ().add (panel);
setVisible (true);
} // MainFrame ()
public void actionPerformed (final ActionEvent p_event) {
m_statut.setVisible (true);
repaint (); ////////////////////////////////////////////////////
getContentPane ().repaint (); //////////////////////////////////
m_statut.updateUI (); //////////////////////////////////////////
m_statut.repaint (); ///////////////////////////////////////////
m_statut.revalidate (); ////////////////////////////////////////
try {
Thread.sleep (2000); // Simulation de la connexion.
}
catch (InterruptedException p_exc) { p_exc.printStackTrace (); }
} // actionPerformed ()
private JLabel m_statut;
public static void main (String[] args) {
new MainFrame ();
} // main ()
} // MainFrame |
Partager