Source code: com/eireneh/swing/NudgeButton.java
1
2 package com.eireneh.swing;
3
4 import java.io.*;
5 import java.util.*;
6 import java.awt.*;
7 import java.awt.event.*;
8 import javax.swing.*;
9 import javax.swing.event.*;
10
11 import com.eireneh.util.StackTrace;
12 import com.eireneh.util.StringUtil;
13
14 /**
15 * A nudge button set based on this dialog -
16 * even down to passing on edited source.
17 *
18 * <table border='1' cellPadding='3' cellSpacing='0' width="100%">
19 * <tr><td bgColor='white'class='TableRowColor'><font size='-7'>
20 * Distribution Licence:<br />
21 * Project B is free software; you can redistribute it
22 * and/or modify it under the terms of the GNU General Public License,
23 * version 2 as published by the Free Software Foundation.<br />
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * General Public License for more details.<br />
28 * The License is available on the internet
29 * <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, by writing to
30 * <i>Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
31 * MA 02111-1307, USA</i>, Or locally at the Licence link below.<br />
32 * The copyright to this program is held by it's authors.
33 * </font></td></tr></table>
34 * @see <a href='http://www.eireneh.com/servlets/Web'>Project B Home</a>
35 * @see docs.Licence
36 * @author Joe Walker
37 */
38 public class NudgeButton extends JPanel
39 {
40 /**
41 *
42 */
43 public NudgeButton()
44 {
45 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
46
47 add(up);
48 add(down);
49 }
50
51 /**
52 *
53 */
54 public void setUpEnabled(boolean active)
55 {
56 up.setEnabled(active);
57 }
58
59 /**
60 *
61 */
62 public void setDownEnabled(boolean active)
63 {
64 down.setEnabled(active);
65 }
66
67 /**
68 *
69 */
70 public boolean getUpEnabled()
71 {
72 return up.isEnabled();
73 }
74
75 /**
76 *
77 */
78 public boolean getDownEnabled()
79 {
80 return down.isEnabled();
81 }
82
83 /**
84 *
85 */
86 public void addUpActionListener(ActionListener al)
87 {
88 up.addActionListener(al);
89 }
90
91 /**
92 *
93 */
94 public void removeUpActionListener(ActionListener al)
95 {
96 up.removeActionListener(al);
97 }
98
99 /**
100 *
101 */
102 public void addDownActionListener(ActionListener al)
103 {
104 down.addActionListener(al);
105 }
106
107 /**
108 *
109 */
110 public void removeDownActionListener(ActionListener al)
111 {
112 down.removeActionListener(al);
113 }
114
115 /** The up button */
116 private JButton up = new javax.swing.plaf.basic.BasicArrowButton(SwingConstants.NORTH);
117
118 /** The down button */
119 private JButton down = new javax.swing.plaf.basic.BasicArrowButton(SwingConstants.SOUTH);
120 }