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
|
package test;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JCheckBox ;
import java.awt.GridLayout ;
class TestGridLayout extends JDialog
{
private static final long serialVersionUID = 1L;
public TestGridLayout(JFrame ow)
{
super(ow, true);
}
private void créerBoites()
{
getContentPane().setLayout(null);
this.setSize(800,456);
JPanel MonPanneau = new JPanel() ;
MonPanneau.setBounds(42, 69, 700, 262);
GridLayout layout = new GridLayout(10,2);
MonPanneau.setLayout(layout);
int j=0;
for (int i=0; i< 18 ;i++)
{
++j;
JCheckBox chk = new JCheckBox((String) "Ligne ajoutée = " + j);
MonPanneau.add(chk);
JLabel blanc = new JLabel("Num = " + j);
MonPanneau.add(blanc);
}
getContentPane().add(MonPanneau);
this.setLocationRelativeTo(null);
setVisible(true);
}
public static void main(String[] args)
{
new TestGridLayout(new JFrame()).créerBoites();
}
} |
Partager