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