JAL-1517 update copyright to version 2.8.2
[jalview.git] / src / jalview / gui / MenuChooser.java
1 package jalview.gui;
2
3 import java.awt.BorderLayout;
4 import java.awt.Color;
5 import java.awt.event.ActionEvent;
6 import java.awt.event.ActionListener;
7
8 import javax.swing.JButton;
9 import javax.swing.JFrame;
10 import javax.swing.JLabel;
11 import javax.swing.JPanel;
12
13 public class MenuChooser implements ActionListener
14 {
15   public static boolean protein;
16
17   private JFrame choosemenu = new JFrame("Animation");
18
19   private JButton bouton = new JButton("bouton 1");
20
21   private JButton bouton2 = new JButton("bouton 2");
22
23   private JPanel container = new JPanel();
24
25   private JLabel label = new JLabel("Le JLabel");
26
27   public MenuChooser()
28   {
29
30     choosemenu.setSize(300, 300);
31     choosemenu.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
32     choosemenu.setLocationRelativeTo(null);
33
34     container.setBackground(Color.white);
35     container.setLayout(new BorderLayout());
36
37     // On ajoute notre Fenetre à la liste des auditeurs de notre Bouton
38     bouton.addActionListener(this);
39     bouton2.addActionListener(this);
40
41     JPanel south = new JPanel();
42     south.add(bouton);
43     south.add(bouton2);
44     container.add(south, BorderLayout.SOUTH);
45
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
49     // classe JLabel
50     label.setHorizontalAlignment(JLabel.CENTER);
51
52     container.add(label, BorderLayout.NORTH);
53
54     choosemenu.setContentPane(container);
55     choosemenu.setVisible(true);
56
57   }
58
59   // ...
60
61   // *******************************************************************************
62   // LA VOILAAAAAAAAAAAAAA
63   // *******************************************************************************
64   /**
65    * C'est la méthode qui sera appelée lors d'un clic sur notre bouton
66    */
67   public void actionPerformed(ActionEvent arg0)
68   {
69
70     if (arg0.getSource() == bouton)
71       protein = false;
72     label.setText("RNA menu");
73
74     if (arg0.getSource() == bouton2)
75       label.setText("Protein menu");
76     protein = true;
77   }
78
79 }