| Method from javax.swing.JScrollBar Detail: |
public void addAdjustmentListener(AdjustmentListener l) {
listenerList.add(AdjustmentListener.class, l);
}
Adds an AdjustmentListener. Adjustment listeners are notified
each time the scrollbar's model changes. Adjustment events are
provided for backwards compatibility with java.awt.Scrollbar.
Note that the AdjustmentEvents type property will always have a
placeholder value of AdjustmentEvent.TRACK because all changes
to a BoundedRangeModels value are considered equivalent. To change
the value of a BoundedRangeModel one just sets its value property,
i.e. model.setValue(123). No information about the origin of the
change, e.g. it's a block decrement, is provided. We don't try
fabricate the origin of the change here. |
protected void fireAdjustmentValueChanged(int id,
int type,
int value) {
fireAdjustmentValueChanged(id, type, value, getValueIsAdjusting());
}
Notify listeners that the scrollbar's model has changed. |
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJScrollBar();
}
return accessibleContext;
}
Gets the AccessibleContext associated with this JScrollBar.
For JScrollBar, the AccessibleContext takes the form of an
AccessibleJScrollBar.
A new AccessibleJScrollBar instance is created if necessary. |
public AdjustmentListener[] getAdjustmentListeners() {
return (AdjustmentListener[])listenerList.getListeners(
AdjustmentListener.class);
}
Returns an array of all the AdjustmentListeners added
to this JScrollBar with addAdjustmentListener(). |
public int getBlockIncrement() {
return blockIncrement;
}
For backwards compatibility with java.awt.Scrollbar. |
public int getBlockIncrement(int direction) {
return blockIncrement;
}
Returns the amount to change the scrollbar's value by,
given a block (usually "page") up/down request. A ScrollBarUI
implementation typically calls this method when the user clicks
above or below the scrollbar "knob" to change the value
up or down by large amount. Subclasses my override this
method to compute a value, e.g. the change required to scroll
up or down one paragraph in a text document.
The JScrollPane component creates scrollbars (by default)
that override this method and delegate to the viewports
Scrollable view, if it has one. The Scrollable interface
provides a more specialized version of this method. |
public int getMaximum() {
return getModel().getMaximum();
}
The maximum value of the scrollbar is maximum - extent. |
public Dimension getMaximumSize() {
Dimension pref = getPreferredSize();
if (getOrientation() == VERTICAL) {
return new Dimension(pref.width, Short.MAX_VALUE);
} else {
return new Dimension(Short.MAX_VALUE, pref.height);
}
}
The scrollbar is flexible along it's scrolling axis and
rigid along the other axis. |
public int getMinimum() {
return getModel().getMinimum();
}
Returns the minimum value supported by the scrollbar
(usually zero). |
public Dimension getMinimumSize() {
Dimension pref = getPreferredSize();
if (orientation == VERTICAL) {
return new Dimension(pref.width, 5);
} else {
return new Dimension(5, pref.height);
}
}
The scrollbar is flexible along it's scrolling axis and
rigid along the other axis. |
public BoundedRangeModel getModel() {
return model;
}
Returns data model that handles the scrollbar's four
fundamental properties: minimum, maximum, value, extent. |
public int getOrientation() {
return orientation;
}
Returns the component's orientation (horizontal or vertical). |
public ScrollBarUI getUI() {
return (ScrollBarUI)ui;
}
Returns the delegate that implements the look and feel for
this component. |
public String getUIClassID() {
return uiClassID;
}
Returns the name of the LookAndFeel class for this component. |
public int getUnitIncrement() {
return unitIncrement;
}
For backwards compatibility with java.awt.Scrollbar. |
public int getUnitIncrement(int direction) {
return unitIncrement;
}
Returns the amount to change the scrollbar's value by,
given a unit up/down request. A ScrollBarUI implementation
typically calls this method when the user clicks on a scrollbar
up/down arrow and uses the result to update the scrollbar's
value. Subclasses my override this method to compute
a value, e.g. the change required to scroll up or down one
(variable height) line text or one row in a table.
The JScrollPane component creates scrollbars (by default)
that override this method and delegate to the viewports
Scrollable view, if it has one. The Scrollable interface
provides a more specialized version of this method. |
public int getValue() {
return getModel().getValue();
}
Returns the scrollbar's value. |
public boolean getValueIsAdjusting() {
return getModel().getValueIsAdjusting();
}
True if the scrollbar knob is being dragged. |
public int getVisibleAmount() {
return getModel().getExtent();
}
Returns the scrollbar's extent, aka its "visibleAmount". In many
scrollbar look and feel implementations the size of the
scrollbar "knob" or "thumb" is proportional to the extent. |
protected String paramString() {
String orientationString = (orientation == HORIZONTAL ?
"HORIZONTAL" : "VERTICAL");
return super.paramString() +
",blockIncrement=" + blockIncrement +
",orientation=" + orientationString +
",unitIncrement=" + unitIncrement;
}
Returns a string representation of this JScrollBar. This method
is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not
be null. |
public void removeAdjustmentListener(AdjustmentListener l) {
listenerList.remove(AdjustmentListener.class, l);
}
Removes an AdjustmentEvent listener. |
public void setBlockIncrement(int blockIncrement) {
int oldValue = this.blockIncrement;
this.blockIncrement = blockIncrement;
firePropertyChange("blockIncrement", oldValue, blockIncrement);
}
Sets the blockIncrement property.
Note, that if the argument is equal to the value of Integer.MIN_VALUE,
the most look and feels will not provide the scrolling to the right/down. |
public void setEnabled(boolean x) {
super.setEnabled(x);
Component[] children = getComponents();
for(int i = 0; i < children.length; i++) {
children[i].setEnabled(x);
}
}
Enables the component so that the knob position can be changed.
When the disabled, the knob position cannot be changed. |
public void setMaximum(int maximum) {
getModel().setMaximum(maximum);
}
Sets the model's maximum property. Note that the scrollbar's value
can only be set to maximum - extent. |
public void setMinimum(int minimum) {
getModel().setMinimum(minimum);
}
Sets the model's minimum property. |
public void setModel(BoundedRangeModel newModel) {
Integer oldValue = null;
BoundedRangeModel oldModel = model;
if (model != null) {
model.removeChangeListener(fwdAdjustmentEvents);
oldValue = Integer.valueOf(model.getValue());
}
model = newModel;
if (model != null) {
model.addChangeListener(fwdAdjustmentEvents);
}
firePropertyChange("model", oldModel, model);
if (accessibleContext != null) {
accessibleContext.firePropertyChange(
AccessibleContext.ACCESSIBLE_VALUE_PROPERTY,
oldValue, new Integer(model.getValue()));
}
}
Sets the model that handles the scrollbar's four
fundamental properties: minimum, maximum, value, extent. |
public void setOrientation(int orientation) {
checkOrientation(orientation);
int oldValue = this.orientation;
this.orientation = orientation;
firePropertyChange("orientation", oldValue, orientation);
if ((oldValue != orientation) && (accessibleContext != null)) {
accessibleContext.firePropertyChange(
AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
((oldValue == VERTICAL)
? AccessibleState.VERTICAL : AccessibleState.HORIZONTAL),
((orientation == VERTICAL)
? AccessibleState.VERTICAL : AccessibleState.HORIZONTAL));
}
if (orientation != oldValue) {
revalidate();
}
}
Set the scrollbar's orientation to either VERTICAL or
HORIZONTAL. |
public void setUI(ScrollBarUI ui) {
super.setUI(ui);
}
Sets the L&F object that renders this component. |
public void setUnitIncrement(int unitIncrement) {
int oldValue = this.unitIncrement;
this.unitIncrement = unitIncrement;
firePropertyChange("unitIncrement", oldValue, unitIncrement);
}
Sets the unitIncrement property.
Note, that if the argument is equal to the value of Integer.MIN_VALUE,
the most look and feels will not provide the scrolling to the right/down. |
public void setValue(int value) {
BoundedRangeModel m = getModel();
int oldValue = m.getValue();
m.setValue(value);
if (accessibleContext != null) {
accessibleContext.firePropertyChange(
AccessibleContext.ACCESSIBLE_VALUE_PROPERTY,
Integer.valueOf(oldValue),
Integer.valueOf(m.getValue()));
}
}
Sets the scrollbar's value. This method just forwards the value
to the model. |
public void setValueIsAdjusting(boolean b) {
BoundedRangeModel m = getModel();
boolean oldValue = m.getValueIsAdjusting();
m.setValueIsAdjusting(b);
if ((oldValue != b) && (accessibleContext != null)) {
accessibleContext.firePropertyChange(
AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
((oldValue) ? AccessibleState.BUSY : null),
((b) ? AccessibleState.BUSY : null));
}
}
Sets the model's valueIsAdjusting property. Scrollbar look and
feel implementations should set this property to true when
a knob drag begins, and to false when the drag ends. The
scrollbar model will not generate ChangeEvents while
valueIsAdjusting is true. |
public void setValues(int newValue,
int newExtent,
int newMin,
int newMax) {
BoundedRangeModel m = getModel();
int oldValue = m.getValue();
m.setRangeProperties(newValue, newExtent, newMin, newMax, m.getValueIsAdjusting());
if (accessibleContext != null) {
accessibleContext.firePropertyChange(
AccessibleContext.ACCESSIBLE_VALUE_PROPERTY,
Integer.valueOf(oldValue),
Integer.valueOf(m.getValue()));
}
}
Sets the four BoundedRangeModel properties after forcing
the arguments to obey the usual constraints:
minimum <= value <= value+extent <= maximum
|
public void setVisibleAmount(int extent) {
getModel().setExtent(extent);
}
Set the model's extent property. |
public void updateUI() {
setUI((ScrollBarUI)UIManager.getUI(this));
}
Overrides JComponent.updateUI. |