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, 11);
56 protected static final int FRAME_WIDTH = 420;
58 protected static final int FRAME_HEIGHT = 120;
60 // this is used for conservation colours, PID colours and redundancy threshold
61 protected JSlider slider = new JSlider();
63 protected JTextField valueField = new JTextField();
65 protected JLabel label = new JLabel();
67 protected JPanel southPanel = new JPanel();
69 protected JButton applyButton = new JButton();
71 protected JButton undoButton = new JButton();
73 protected JCheckBox allGroupsCheck = new JCheckBox();
76 * Creates a new GSliderPanel object.
90 * Constructs and lays out the controls
94 slider.setMajorTickSpacing(10);
95 slider.setMinorTickSpacing(1);
96 slider.setPaintTicks(true);
97 slider.setBackground(Color.white);
98 slider.setFont(VERDANA_11);
99 slider.setDoubleBuffered(true);
100 slider.addMouseListener(new MouseAdapter()
103 public void mouseReleased(MouseEvent e)
105 slider_mouseReleased(e);
108 valueField.setFont(VERDANA_11);
109 valueField.setMinimumSize(new Dimension(6, 14));
110 valueField.setPreferredSize(new Dimension(50, 12));
111 valueField.setText("");
112 valueField.setHorizontalAlignment(SwingConstants.CENTER);
113 valueField.addActionListener(new ActionListener()
116 public void actionPerformed(ActionEvent e)
118 valueField_actionPerformed();
121 valueField.addFocusListener(new FocusAdapter()
124 public void focusLost(FocusEvent e)
126 valueField_actionPerformed();
129 label.setFont(VERDANA_11);
130 label.setOpaque(false);
131 label.setHorizontalAlignment(SwingConstants.CENTER);
132 label.setText(MessageManager.getString("label.set_this_label_text"));
134 applyButton.setFont(VERDANA_11);
135 applyButton.setOpaque(false);
136 applyButton.setText(MessageManager.getString("action.apply"));
137 applyButton.addActionListener(new ActionListener()
140 public void actionPerformed(ActionEvent e)
142 applyButton_actionPerformed(e);
145 undoButton.setEnabled(false);
146 undoButton.setFont(VERDANA_11);
147 undoButton.setOpaque(false);
148 undoButton.setText(MessageManager.getString("action.undo"));
149 undoButton.addActionListener(new ActionListener()
152 public void actionPerformed(ActionEvent e)
154 undoButton_actionPerformed(e);
157 allGroupsCheck.setEnabled(false);
158 allGroupsCheck.setFont(VERDANA_11);
159 allGroupsCheck.setOpaque(false);
161 .setText(MessageManager.getString("action.apply_all_groups"));
163 this.setLayout(new GridLayout(2, 0));
164 this.setBackground(Color.white);
166 JPanel firstRow = new JPanel(new FlowLayout());
167 firstRow.setOpaque(false);
169 firstRow.add(applyButton);
170 firstRow.add(undoButton);
173 JPanel jPanel1 = new JPanel(new BorderLayout());
174 jPanel1.setOpaque(false);
175 jPanel1.add(valueField, BorderLayout.CENTER);
176 jPanel1.add(allGroupsCheck, BorderLayout.EAST);
178 southPanel.setLayout(new BorderLayout());
179 southPanel.setOpaque(false);
180 southPanel.add(jPanel1, BorderLayout.EAST);
181 southPanel.add(slider, BorderLayout.CENTER);
182 this.add(southPanel);
186 * Action on changing the slider text field value
188 protected void valueField_actionPerformed()
192 int i = Integer.valueOf(valueField.getText());
194 } catch (NumberFormatException ex)
196 valueField.setText(String.valueOf(slider.getValue()));
206 protected void applyButton_actionPerformed(ActionEvent e)
216 protected void undoButton_actionPerformed(ActionEvent e)
220 public void slider_mouseReleased(MouseEvent e)