2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
21 package jalview.jbgui;
23 import jalview.util.MessageManager;
25 import java.awt.BorderLayout;
26 import java.awt.Color;
27 import java.awt.Dimension;
28 import java.awt.FlowLayout;
30 import java.awt.GridLayout;
31 import java.awt.event.ActionEvent;
32 import java.awt.event.ActionListener;
33 import java.awt.event.FocusAdapter;
34 import java.awt.event.FocusEvent;
35 import java.awt.event.MouseAdapter;
36 import java.awt.event.MouseEvent;
38 import javax.swing.JButton;
39 import javax.swing.JCheckBox;
40 import javax.swing.JLabel;
41 import javax.swing.JPanel;
42 import javax.swing.JSlider;
43 import javax.swing.JTextField;
44 import javax.swing.SwingConstants;
52 public class GSliderPanel extends JPanel
54 private static final Font VERDANA_11 = new java.awt.Font("Verdana", 0,
57 protected static final int FRAME_WIDTH = 420;
59 protected static final int FRAME_HEIGHT = 120;
61 // this is used for conservation colours, PID colours and redundancy threshold
62 protected JSlider slider = new JSlider();
64 protected JTextField valueField = new JTextField();
66 protected JLabel label = new JLabel();
68 protected JPanel southPanel = new JPanel();
70 protected JButton applyButton = new JButton();
72 protected JButton undoButton = new JButton();
74 protected JCheckBox allGroupsCheck = new JCheckBox();
77 * Creates a new GSliderPanel object.
91 * Constructs and lays out the controls
95 slider.setMajorTickSpacing(10);
96 slider.setMinorTickSpacing(1);
97 slider.setPaintTicks(true);
98 slider.setBackground(Color.white);
99 slider.setFont(VERDANA_11);
100 slider.setDoubleBuffered(true);
101 slider.addMouseListener(new MouseAdapter()
104 public void mouseReleased(MouseEvent e)
106 slider_mouseReleased(e);
109 valueField.setFont(VERDANA_11);
110 valueField.setMinimumSize(new Dimension(6, 14));
111 valueField.setPreferredSize(new Dimension(50, 12));
112 valueField.setText("");
113 valueField.setHorizontalAlignment(SwingConstants.CENTER);
114 valueField.addActionListener(new ActionListener()
117 public void actionPerformed(ActionEvent e)
119 valueField_actionPerformed();
122 valueField.addFocusListener(new FocusAdapter()
125 public void focusLost(FocusEvent e)
127 valueField_actionPerformed();
130 label.setFont(VERDANA_11);
131 label.setOpaque(false);
132 label.setHorizontalAlignment(SwingConstants.CENTER);
133 label.setText(MessageManager.getString("label.set_this_label_text"));
135 applyButton.setFont(VERDANA_11);
136 applyButton.setOpaque(false);
137 applyButton.setText(MessageManager.getString("action.apply"));
138 applyButton.addActionListener(new ActionListener()
141 public void actionPerformed(ActionEvent e)
143 applyButton_actionPerformed(e);
146 undoButton.setEnabled(false);
147 undoButton.setFont(VERDANA_11);
148 undoButton.setOpaque(false);
149 undoButton.setText(MessageManager.getString("action.undo"));
150 undoButton.addActionListener(new ActionListener()
153 public void actionPerformed(ActionEvent e)
155 undoButton_actionPerformed(e);
158 allGroupsCheck.setEnabled(false);
159 allGroupsCheck.setFont(VERDANA_11);
160 allGroupsCheck.setOpaque(false);
162 .setText(MessageManager.getString("action.apply_all_groups"));
164 this.setLayout(new GridLayout(2, 0));
165 this.setBackground(Color.white);
167 JPanel firstRow = new JPanel(new FlowLayout());
168 firstRow.setOpaque(false);
170 firstRow.add(applyButton);
171 firstRow.add(undoButton);
174 JPanel jPanel1 = new JPanel(new BorderLayout());
175 jPanel1.setOpaque(false);
176 jPanel1.add(valueField, BorderLayout.CENTER);
177 jPanel1.add(allGroupsCheck, BorderLayout.EAST);
179 southPanel.setLayout(new BorderLayout());
180 southPanel.setOpaque(false);
181 southPanel.add(jPanel1, BorderLayout.EAST);
182 southPanel.add(slider, BorderLayout.CENTER);
183 this.add(southPanel);
187 * Action on changing the slider text field value
189 protected void valueField_actionPerformed()
193 int i = Integer.valueOf(valueField.getText());
195 } catch (NumberFormatException ex)
197 valueField.setText(String.valueOf(slider.getValue()));
207 protected void applyButton_actionPerformed(ActionEvent e)
217 protected void undoButton_actionPerformed(ActionEvent e)
221 public void slider_mouseReleased(MouseEvent e)