3 import java.awt.BorderLayout;
5 import java.awt.event.ActionEvent;
6 import java.awt.event.ActionListener;
8 import javax.swing.JButton;
9 import javax.swing.JFrame;
10 import javax.swing.JLabel;
11 import javax.swing.JPanel;
13 public class MenuChooser implements ActionListener
15 public static boolean protein;
17 private JFrame choosemenu = new JFrame("Animation");
19 private JButton bouton = new JButton("bouton 1");
21 private JButton bouton2 = new JButton("bouton 2");
23 private JPanel container = new JPanel();
25 private JLabel label = new JLabel("Le JLabel");
30 choosemenu.setSize(300, 300);
31 choosemenu.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
32 choosemenu.setLocationRelativeTo(null);
34 container.setBackground(Color.white);
35 container.setLayout(new BorderLayout());
37 // On ajoute notre Fenetre à la liste des auditeurs de notre Bouton
38 bouton.addActionListener(this);
39 bouton2.addActionListener(this);
41 JPanel south = new JPanel();
44 container.add(south, BorderLayout.SOUTH);
46 // On change la couleur de police
47 label.setForeground(Color.blue);
48 // Et on change l'alignement du texte grâce aux attributs static de la
50 label.setHorizontalAlignment(JLabel.CENTER);
52 container.add(label, BorderLayout.NORTH);
54 choosemenu.setContentPane(container);
55 choosemenu.setVisible(true);
61 // *******************************************************************************
62 // LA VOILAAAAAAAAAAAAAA
63 // *******************************************************************************
65 * C'est la méthode qui sera appelée lors d'un clic sur notre bouton
67 public void actionPerformed(ActionEvent arg0)
70 if (arg0.getSource() == bouton)
72 label.setText("RNA menu");
74 if (arg0.getSource() == bouton2)
75 label.setText("Protein menu");