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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
| private JPanel createPanneau(){
//declarations
JPanel panneau = new JPanel();
panneau.setBorder(new LineBorder(Color.black));
//installer le gestionnaire
GridBagLayout g=new GridBagLayout();
panneau.setLayout(g);
//créer un objet de type GridBagConstraints
GridBagConstraints c=new GridBagConstraints();
//******************************************//
c.fill=GridBagConstraints.NONE;
c.weightx=1.0;
c.gridheight=1;
c.gridwidth=GridBagConstraints.REMAINDER;
c.gridx=0;
c.gridy=0;
c.anchor = GridBagConstraints.CENTER;
JLabel monLabel1 = new JLabel("Bienvenue");
monLabel1.setFont(new Font("Tahoma", Font.PLAIN, 25));
panneau.add(monLabel1);
g.setConstraints(monLabel1,c);
//******************************************//
//******************************************//
//réinitialisation
c.weightx=0.0;
c.weighty=1.0;
c.gridwidth=1;
c.gridheight=2; //sur 2 lignes
c.gridx=0;
c.gridy=1;
JLabel monLabel2 = new JLabel("Veuillez choisir les concepts que vous souhaitez mettre en évidence:");
panneau.add(monLabel2);
g.setConstraints(monLabel2,c);
//******************************************//
//******************************************//
//nouvelle réinitialisation
c.fill=GridBagConstraints.NONE;
//c.weighty=0.0;
//c.gridwidth=GridBagConstraints.RELATIVE;
c.gridx=1;
c.gridy=1;
c.gridwidth=1;
c.gridheight=2;
String[] columnNames = {"Concepts"};
Object[][] data = {
{"Concept1"},
{"Concept2"},
{"Concept3"}};
JTable maTable1 = new JTable(new MyTableModel(data, columnNames));
maTable1.setShowGrid(false);
JScrollPane scrollPane1 = new JScrollPane(maTable1);
JPanel pannel1 = new JPanel();
pannel1.add(scrollPane1);
panneau.add(pannel1);
g.setConstraints(pannel1,c);
//******************************************//
//******************************************//
c.fill=GridBagConstraints.NONE;
c.gridheight=1;
c.gridwidth=1;
c.gridheight=1;
c.gridx=2;
c.gridy=1;
c.anchor=GridBagConstraints.SOUTH;
JButton transfer1=new JButton(">>");
panneau.add(transfer1);
g.setConstraints(transfer1,c);
//******************************************//
//******************************************//
//nouvelle réinitialisation
c.fill=GridBagConstraints.NONE;
c.gridwidth=GridBagConstraints.REMAINDER;
c.gridheight=2; //sur 2 lignes
c.gridx=3;
c.gridy=1;
String[] columnNames2 = {"Concepts"};
Object[][] data2 = {};
JTable maTable2 = new JTable(new MyTableModel(data2, columnNames2));
maTable2.setShowGrid(false);
JScrollPane scrollPane2 = new JScrollPane(maTable2);
JPanel pannel2 = new JPanel();
pannel2.add(scrollPane2);
panneau.add(pannel2);
g.setConstraints(pannel2,c);
//******************************************//
//******************************************//
c.fill=GridBagConstraints.NONE;
c.gridheight=1;
c.gridheight=1;
c.gridx=2;
c.gridy=2;
c.anchor=GridBagConstraints.NORTH;
JButton transfer2=new JButton("<<");
panneau.add(transfer2);
g.setConstraints(transfer2,c);
//******************************************//
//******************************************//
//réinitialisation
c.weightx=0.0;
c.weighty=1.0;
c.gridwidth=1;
c.gridheight=2; //sur 2 lignes
c.gridx=0;
c.gridy=3;
JLabel monLabel3 = new JLabel("Veuillez choisir la période souhaitée:");
panneau.add(monLabel3);
g.setConstraints(monLabel3,c);
//******************************************//
//******************************************//
c.fill=GridBagConstraints.NONE;
c.gridheight=1;
c.gridwidth=GridBagConstraints.REMAINDER;
c.gridheight=1; //sur 2 lignes
c.gridx=1;
c.gridy=3;
JButton first=new JButton("First");
JPanel pannel3 = new JPanel();
pannel3.add(first);
panneau.add(pannel3);
g.setConstraints(pannel3,c);
//******************************************//
//******************************************//
c.fill=GridBagConstraints.NONE;
c.gridheight=1;
c.gridwidth=GridBagConstraints.REMAINDER;
c.gridheight=1;
c.gridx=1;
c.gridy=4;
JButton second=new JButton("second");
JPanel pannel4 = new JPanel();
pannel4.add(second);
panneau.add(pannel4);
g.setConstraints(pannel4,c);
//******************************************//
return panneau;
} |
Partager