1 /* ScrollPaneAdjustable.java -- Scrollbars for a ScrollPane
2 Copyright (C) 1999 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
41 import java.awt.event.AdjustmentListener;
42 import java.io.Serializable;
45 * Need this class since the serialization spec for ScrollPane
48 * @author Aaron M. Renn (arenn@urbanophile.com)
51 public class ScrollPaneAdjustable
52 implements Adjustable, Serializable
54 private static final long serialVersionUID = -3359745691033257079L;
62 int unitIncrement = 1;
63 int blockIncrement = 1;
64 AdjustmentListener adjustmentListener;
66 private transient boolean valueIsAdjusting = false;
68 ScrollPaneAdjustable (ScrollPane sp, int orientation)
71 this.orientation = orientation;
74 ScrollPaneAdjustable (ScrollPane sp, int orientation, int value, int minimum,
75 int maximum, int visibleAmount, int unitIncrement,
79 this.orientation = orientation;
81 this.minimum = minimum;
82 this.maximum = maximum;
83 this.visibleAmount = visibleAmount;
84 this.unitIncrement = unitIncrement;
85 this.blockIncrement = blockIncrement;
88 public void addAdjustmentListener (AdjustmentListener listener)
92 adjustmentListener = AWTEventMulticaster.add (adjustmentListener, listener);
95 public void removeAdjustmentListener (AdjustmentListener listener)
99 adjustmentListener = AWTEventMulticaster.remove (adjustmentListener, listener);
102 public AdjustmentListener[] getAdjustmentListeners ()
104 return (AdjustmentListener[]) AWTEventMulticaster.getListeners
105 (adjustmentListener, AdjustmentListener.class);
108 public int getBlockIncrement ()
110 return blockIncrement;
113 public int getMaximum ()
118 public int getMinimum ()
123 public int getOrientation ()
128 public int getUnitIncrement ()
130 return unitIncrement;
133 public int getValue ()
138 public int getVisibleAmount ()
140 return visibleAmount;
143 public void setBlockIncrement (int blockIncrement)
145 this.blockIncrement = blockIncrement;
149 * This method should never be called.
151 * @param maximum The maximum value to be set.
152 * @throws AWTError Always throws this error when called.
154 public void setMaximum (int maximum) throws AWTError
156 throw new AWTError("Can be set by scrollpane only");
160 * This method should never be called.
162 * @param minimum The minimum value to be set.
163 * @throws AWTError Always throws this error when called.
165 public void setMinimum (int minimum)
167 throw new AWTError("Can be set by scrollpane only");
170 public void setUnitIncrement (int unitIncrement)
172 this.unitIncrement = unitIncrement;
175 public void setValue (int value)
187 * This method should never be called.
189 * @param visibleAmount The visible amount to be set.
190 * @throws AWTError Always throws this error when called.
192 public void setVisibleAmount (int visibleAmount)
194 throw new AWTError("Can be set by scrollpane only");
197 public String paramString ()
199 return paramStringHelper()
200 + ",[" + getMinimum() + ".." + getMaximum()
201 + "],val=" + getValue()
202 + ",vis=" + getVisibleAmount()
203 + ",unit=" + getUnitIncrement()
204 + ",block=" + getBlockIncrement()
205 + ",isAdjusting=" + valueIsAdjusting;
208 private String paramStringHelper()
210 if (getOrientation() == HORIZONTAL)
216 public String toString()
218 return getClass().getName() + "[" + paramString() + "]";
222 * Returns true if the value is in the process of changing.
226 public boolean getValueIsAdjusting ()
228 return valueIsAdjusting;
232 * Sets the value of valueIsAdjusting.
236 public void setValueIsAdjusting (boolean valueIsAdjusting)
238 this.valueIsAdjusting = valueIsAdjusting;
241 } // class ScrollPaneAdjustable