📄 jscrollbar.java
字号:
* * @param unitIncrement The new unitIncrement. */ public void setUnitIncrement(int unitIncrement) { if (unitIncrement != this.unitIncrement) { int oldInc = this.unitIncrement; this.unitIncrement = unitIncrement; firePropertyChange("unitIncrement", oldInc, this.unitIncrement); } } /** * The method returns how much the scrollbar's value * should change for a block increment depending on * the given direction. * * @param direction The direction to scroll in. * * @return The amount the scrollbar's value will change given the direction. */ public int getBlockIncrement(int direction) { return direction * blockIncrement; } /** * This method sets the blockIncrement property. * * @param blockIncrement The new blockIncrement. */ public void setBlockIncrement(int blockIncrement) { if (blockIncrement != this.blockIncrement) { int oldInc = this.blockIncrement; this.blockIncrement = blockIncrement; firePropertyChange("blockIncrement", oldInc, this.blockIncrement); } } /** * This method returns the unitIncrement. * * @return The unitIncrement. */ public int getUnitIncrement() { return unitIncrement; } /** * This method returns the blockIncrement. * * @return The blockIncrement. */ public int getBlockIncrement() { return blockIncrement; } /** * This method returns the value of the scrollbar. * * @return The value of the scrollbar. */ public int getValue() { return model.getValue(); } /** * This method changes the value of the scrollbar. * * @param value The new value of the scrollbar. */ public void setValue(int value) { if (isEnabled() && value != getValue()) { model.setValue(value); fireAdjustmentValueChanged(AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED, AdjustmentEvent.TRACK, value); } } /** * This method returns the visible amount (AKA extent). * The visible amount can be used by UI delegates to * determine the size of the thumb. * * @return The visible amount (AKA extent). */ public int getVisibleAmount() { return model.getExtent(); } /** * This method sets the visible amount (AKA extent). * * @param extent The visible amount (AKA extent). */ public void setVisibleAmount(int extent) { if (extent != getVisibleAmount()) { model.setExtent(extent); fireAdjustmentValueChanged(AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED, AdjustmentEvent.TRACK, extent); } } /** * This method returns the minimum value of the scrollbar. * * @return The minimum value of the scrollbar. */ public int getMinimum() { return model.getMinimum(); } /** * This method sets the minimum value of the scrollbar. * * @param minimum The minimum value of the scrollbar. */ public void setMinimum(int minimum) { if (minimum != getMinimum()) { model.setMinimum(minimum); fireAdjustmentValueChanged(AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED, AdjustmentEvent.TRACK, minimum); } } /** * This method returns the maximum value of the scrollbar. * * @return The maximum value of the scrollbar. */ public int getMaximum() { return model.getMaximum(); } /** * This method sets the maximum value of the scrollbar. * * @param maximum The maximum value of the scrollbar. */ public void setMaximum(int maximum) { if (maximum != getMaximum()) { model.setMaximum(maximum); fireAdjustmentValueChanged(AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED, AdjustmentEvent.TRACK, maximum); } } /** * This method returns the model's isAjusting value. * * @return The model's isAdjusting value. */ public boolean getValueIsAdjusting() { return model.getValueIsAdjusting(); } /** * This method sets the model's isAdjusting value. * * @param b The new isAdjusting value. */ public void setValueIsAdjusting(boolean b) { model.setValueIsAdjusting(b); } /** * This method sets the value, extent, minimum and * maximum. * * @param newValue The new value. * @param newExtent The new extent. * @param newMin The new minimum. * @param newMax The new maximum. */ public void setValues(int newValue, int newExtent, int newMin, int newMax) { if (!isEnabled()) newValue = model.getValue(); // It seems to be that on any change the value is fired. if (newValue != getValue() || newExtent != getVisibleAmount() || newMin != getMinimum() || newMax != getMaximum()) { model.setRangeProperties(newValue, newExtent, newMin, newMax, model.getValueIsAdjusting()); fireAdjustmentValueChanged(AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED, AdjustmentEvent.TRACK, newValue); } } /** * This method adds an AdjustmentListener to the scroll bar. * * @param listener The listener to add. */ public void addAdjustmentListener(AdjustmentListener listener) { listenerList.add(AdjustmentListener.class, listener); } /** * This method removes an AdjustmentListener from the scroll bar. * * @param listener The listener to remove. */ public void removeAdjustmentListener(AdjustmentListener listener) { listenerList.remove(AdjustmentListener.class, listener); } /** * This method returns an arry of all AdjustmentListeners listening to * this scroll bar. * * @return An array of AdjustmentListeners listening to this scroll bar. */ public AdjustmentListener[] getAdjustmentListeners() { return (AdjustmentListener[]) listenerList.getListeners(AdjustmentListener.class); } /** * This method is called to fired AdjustmentEvents to the listeners * of this scroll bar. All AdjustmentEvents that are fired * will have an ID of ADJUSTMENT_VALUE_CHANGED and a type of * TRACK. * * @param id The ID of the adjustment event. * @param type The Type of change. * @param value The new value for the property that was changed.. */ protected void fireAdjustmentValueChanged(int id, int type, int value) { Object[] adjustmentListeners = listenerList.getListenerList(); AdjustmentEvent adjustmentEvent = new AdjustmentEvent(this, AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED, AdjustmentEvent.TRACK, value); for (int i = adjustmentListeners.length - 2; i >= 0; i -= 2) { if (adjustmentListeners[i] == AdjustmentListener.class) ((AdjustmentListener) adjustmentListeners[i + 1]).adjustmentValueChanged(adjustmentEvent); } } /** * This method returns the minimum size for this scroll bar. * * @return The minimum size. */ public Dimension getMinimumSize() { return ui.getMinimumSize(this); } /** * This method returns the maximum size for this scroll bar. * * @return The maximum size. */ public Dimension getMaximumSize() { return ui.getMaximumSize(this); } /** * This method overrides the setEnabled in JComponent. * When the scroll bar is disabled, the knob cannot * be moved. * * @param x Whether the scrollbar is enabled. */ public void setEnabled(boolean x) { // nothing special needs to be done here since we // just check the enabled setting before changing the value. super.setEnabled(x); } /** * A string that describes this JScrollBar. Normally only used * for debugging. * * @return A string describing this JScrollBar. */ protected String paramString() { return "JScrollBar"; } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public AccessibleContext getAccessibleContext() { if (accessibleContext == null) accessibleContext = new AccessibleJScrollBar(); return accessibleContext; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -