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
|
public class NouvellePartieSeulAction extends AbstractAction {
private FenetrePrincipale fenetre;
private JLabel label;
public NouvellePartieSeulAction(FenetrePrincipale fenetre, String texte){
super(texte);
this.fenetre = fenetre;
}
public void actionPerformed(ActionEvent e) {
fenetre.getContentPane().removeAll();
fenetre.getContentPane().add(buildContentPane());
fenetre.repaint();
}
private JPanel buildContentPane(){
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
panel.setBackground(Color.white);
label = new JLabel("Résultat!");
panel.add(label);
panel.setBounds(0, 0, 320, 100);
panel.revalidate();
return panel;
}
} |
Partager