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
|
public class InterfaceGraphique extends Thread {
private JFrame fenetre;
public JPanel panel;
private static final int hauteur = 600;
private static final int largeur = 800;
public InterfaceGraphique () {
this.fenetre = new JFrame("Tests CheckBox");
panel = new JPanel();
this.fenetre.add(panel);
this.fenetre.setMinimumSize(new Dimension(largeur + 3, hauteur + 53));
this.fenetre.setLocationRelativeTo(null);
this.fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
protected void setVisible(boolean b) {
this.fenetre.setVisible(b);
}
public void run () {
InterfaceGraphique ig = new InterfaceGraphique();
ig.setVisible(true);
}
public static void main(String[] args) {
InterfaceGraphique ig = new InterfaceGraphique();
ig.start();
ig.panel.add(new JCheckBox("test2"));
ig.panel.repaint();
System.out.println(ig.panel.getComponentCount());
}
} |
Partager