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
| public class Panneau extends JPanel implements ActionListener
{
public Panneau()
{
//une requete permettant choisir aleatoirement une question dans bdd
String[] tab = {"question", "reponse", ...}; //je stocke cela dans un tableau
JButton[] bout = new JButton[tab.length];
for(int i = 0; i < bout.length; i++)
{
bout[i] = new JButton(tab[i]);
bout[i].addActionListenner(this);
}
}
public void actionPerformed(ActionEvent event)
{
for(int i = 0; i < bout.length; i++)
{
if(bout[i].getText() == reponse)
{
Panneau pan = new Panneau();
// le probleme j'arrive pas a acceder au ci dessous pour la rafraichir
//Fenetre.getContentPane().removeAll();
//Fenetre.getContentPane().add(pan);
}
}
}
} |