JAL-1645 Version-Rel Version 2.9 Year-Rel 2015 Licensing glob
[jalview.git] / src / jalview / gui / MenuChooser.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9)
3  * Copyright (C) 2015 The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.gui;
22
23 import java.awt.BorderLayout;
24 import java.awt.Color;
25 import java.awt.event.ActionEvent;
26 import java.awt.event.ActionListener;
27
28 import javax.swing.JButton;
29 import javax.swing.JFrame;
30 import javax.swing.JLabel;
31 import javax.swing.JPanel;
32
33 public class MenuChooser implements ActionListener
34 {
35   public static boolean protein;
36
37   private JFrame choosemenu = new JFrame("Animation");
38
39   private JButton bouton = new JButton("bouton 1");
40
41   private JButton bouton2 = new JButton("bouton 2");
42
43   private JPanel container = new JPanel();
44
45   private JLabel label = new JLabel("Le JLabel");
46
47   public MenuChooser()
48   {
49
50     choosemenu.setSize(300, 300);
51     choosemenu.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
52     choosemenu.setLocationRelativeTo(null);
53
54     container.setBackground(Color.white);
55     container.setLayout(new BorderLayout());
56
57     // On ajoute notre Fenetre à la liste des auditeurs de notre Bouton
58     bouton.addActionListener(this);
59     bouton2.addActionListener(this);
60
61     JPanel south = new JPanel();
62     south.add(bouton);
63     south.add(bouton2);
64     container.add(south, BorderLayout.SOUTH);
65
66     // On change la couleur de police
67     label.setForeground(Color.blue);
68     // Et on change l'alignement du texte grâce aux attributs static de la
69     // classe JLabel
70     label.setHorizontalAlignment(JLabel.CENTER);
71
72     container.add(label, BorderLayout.NORTH);
73
74     choosemenu.setContentPane(container);
75     choosemenu.setVisible(true);
76
77   }
78
79   // ...
80
81   // *******************************************************************************
82   // LA VOILAAAAAAAAAAAAAA
83   // *******************************************************************************
84   /**
85    * C'est la méthode qui sera appelée lors d'un clic sur notre bouton
86    */
87   public void actionPerformed(ActionEvent arg0)
88   {
89
90     if (arg0.getSource() == bouton)
91       protein = false;
92     label.setText("RNA menu");
93
94     if (arg0.getSource() == bouton2)
95       label.setText("Protein menu");
96     protein = true;
97   }
98
99 }