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
|
//***************** le region est******************************
private JPanel getJPanel3() {
if (jPanel3 == null) {
//JButton bout1 = new JButton();
//JButton bout2 = new JButton();
//JButton bout1 = new JButton();
//JButton bout2 = new JButton();
//JButton bout1 = new JButton();
//JButton bout2 = new JButton();
//JButton bout1 = new JButton();
//JButton bout2 = new JButton();
//JButton bout1 = new JButton();
//JButton bout2 = new JButton();
//JButton bout1 = new JButton();
//JButton bout2 = new JButton();
//JButton bout1 = new JButton();
//JButton bout2 = new JButton();
int w=4, h=4;
jPanel3 = new JPanel();
jPanel3.setSize(60, 60);
jPanel3.setLayout(new GridLayout(h, w));
JButton[][] bouton = new JButton[h][w];
for(int i=0; i<h; i++)
for( int j=0; j<w; j++)
{
// bouton[i][j].addActionListener((ActionListener) this);
jPanel3.add(bouton[i][j]=new JButton("case["+i+"]["+j+"]"));
bouton[i][j].addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
try {
String[] message = {"Producteur","vehicule","facteur"};
JOptionPane.showMessageDialog(null,
new JComboBox(message),
"Choisissez un agent", JOptionPane.PLAIN_MESSAGE);
if (message.equals("producteur")) {
//bouton[i][j].setVisible(false);
// bouton[i][j].setEnabled(false);
// a la ligne ci dessous l'erreur persiste ;(
bouton[i][j].setBackground(Color.RED);
}
}
catch (Exception any) {
any.printStackTrace();}
}});
}
//jPanel3.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
//jPanel3.add(bout1);
//jPanel3.add(bout2);
}
return jPanel3;
}
// public void actionPerformed(ActionEvent ae) {
// String[] message = {"Producteur","vehicule","facteur"};
// JOptionPane.showMessageDialog(null,
// new JComboBox(message),
// null, JOptionPane.PLAIN_MESSAGE);
//}
//**************fin region est***************************** |
Partager