📄 scrollbar.java
字号:
}/*************************************************************************//** * Sets the width of the scrollbar's thumb, in units relative to the * maximum and minimum value of the scrollbar. * * @param visibileAmount The new visible amount value of the scrollbar. */public voidsetVisibleAmount(int visibleAmount){ setValues(value, visibleAmount, minimum, maximum);}/*************************************************************************//** * Sets the current value, visible amount, minimum, and maximum for this * scrollbar. These values are adjusted to be internally consistent * if necessary. * * @param value The new value for this scrollbar. * @param visibleAmount The new visible amount for this scrollbar. * @param minimum The new minimum value for this scrollbar. * @param maximum The new maximum value for this scrollbar. */public synchronized voidsetValues(int value, int visibleAmount, int minimum, int maximum){ if (maximum < minimum) maximum = minimum; if (value < minimum) value = minimum; if (value > maximum) value = maximum; if (visibleAmount > value) visibleAmount = value; this.value = value; this.visibleAmount = visibleAmount; this.minimum = minimum; this.maximum = maximum; ScrollbarPeer sp = (ScrollbarPeer)getPeer(); if (sp != null) sp.setValues(value, visibleAmount, minimum, maximum); int range = maximum - minimum; if (lineIncrement > range) { if (range == 0) lineIncrement = 1; else lineIncrement = range; if (sp != null) sp.setLineIncrement(lineIncrement); } if (pageIncrement > range) { if (range == 0) pageIncrement = 1; else pageIncrement = range; if (sp != null) sp.setPageIncrement(pageIncrement); }}/*************************************************************************//** * Returns the value added or subtracted when the user activates the scrollbar * scroll by a "unit" amount. * * @return The unit increment value. */public intgetUnitIncrement(){ return(lineIncrement);}/*************************************************************************//** * Returns the value added or subtracted when the user selects the scrollbar * scroll by a "unit" amount control. * * @return The unit increment value. * * @deprecated This method is deprecated in favor of * <code>getUnitIncrement()</code>. */public intgetLineIncrement(){ return(lineIncrement);}/*************************************************************************//** * Sets the value added or subtracted to the scrollbar value when the * user selects the scroll by a "unit" amount control. * * @param unitIncrement The new unit increment amount. */public synchronized voidsetUnitIncrement(int unitIncrement){ if (unitIncrement < 0) throw new IllegalArgumentException("Unit increment less than zero."); int range = maximum - minimum; if (unitIncrement > range) { if (range == 0) unitIncrement = 1; else unitIncrement = range; } if (unitIncrement == lineIncrement) return; lineIncrement = unitIncrement; ScrollbarPeer sp = (ScrollbarPeer)getPeer(); if (sp != null) sp.setLineIncrement(lineIncrement);}/*************************************************************************//** * Sets the value added or subtracted to the scrollbar value when the * user selects the scroll by a "unit" amount control. * * @param lineIncrement The new unit increment amount. * * @deprecated This method is deprecated in favor of * <code>setUnitIncrement()</code>. */public voidsetLineIncrement(int lineIncrement){ setUnitIncrement(lineIncrement);}/*************************************************************************//** * Returns the value added or subtracted when the user activates the scrollbar * scroll by a "block" amount. * * @return The block increment value. */public intgetBlockIncrement(){ return(pageIncrement);}/*************************************************************************//** * Returns the value added or subtracted when the user selects the scrollbar * scroll by a "block" amount control. * * @return The block increment value. * * @deprecated This method is deprecated in favor of * <code>getBlockIncrement()</code>. */public intgetPageIncrement(){ return(pageIncrement);}/*************************************************************************//** * Sets the value added or subtracted to the scrollbar value when the * user selects the scroll by a "block" amount control. * * @param blockIncrement The new block increment amount. */public synchronized voidsetBlockIncrement(int blockIncrement){ if (blockIncrement < 0) throw new IllegalArgumentException("Block increment less than zero."); int range = maximum - minimum; if (blockIncrement > range) { if (range == 0) blockIncrement = 1; else blockIncrement = range; } if (blockIncrement == pageIncrement) return; pageIncrement = blockIncrement; ScrollbarPeer sp = (ScrollbarPeer)getPeer(); if (sp != null) sp.setPageIncrement(pageIncrement);}/*************************************************************************//** * Sets the value added or subtracted to the scrollbar value when the * user selects the scroll by a "block" amount control. * * @param pageIncrement The new block increment amount. * * @deprecated This method is deprecated in favor of * <code>setBlockIncrement()</code>. */public voidsetPageIncrement(int pageIncrement){ setBlockIncrement(pageIncrement);}/*************************************************************************//** * Notifies this object to create its native peer. */public synchronized voidaddNotify(){ if (peer == null) peer = getToolkit ().createScrollbar (this); super.addNotify ();}/*************************************************************************//** * Adds a new adjustment listener to the list of registered listeners * for this object. * * @param listener The listener to add. */public synchronized voidaddAdjustmentListener(AdjustmentListener listener){ adjustment_listeners = AWTEventMulticaster.add(adjustment_listeners, listener); enableEvents(AWTEvent.ADJUSTMENT_EVENT_MASK);}/*************************************************************************//** * Removes the specified listener from the list of registered listeners * for this object. * * @param listener The listener to remove. */public synchronized voidremoveAdjustmentListener(AdjustmentListener listener){ adjustment_listeners = AWTEventMulticaster.remove(adjustment_listeners, listener);}/*************************************************************************//** * Processes events for this scrollbar. It does this by calling * <code>processAdjustmentEvent()</code> if the event is an instance of * <code>AdjustmentEvent</code>, otherwise it calls the superclass to * process the event. * * @param event The event to process. */protected voidprocessEvent(AWTEvent event){ if (event instanceof AdjustmentEvent) processAdjustmentEvent((AdjustmentEvent)event); else super.processEvent(event);}/*************************************************************************//** * Processes adjustment events for this object by dispatching them to * any registered listeners. Note that this method will only be called * if adjustment events are enabled. This will happen automatically if * any listeners are registered. Otherwise, it can be enabled by a * call to <code>enableEvents()</code>. * * @param event The event to process. */protected voidprocessAdjustmentEvent(AdjustmentEvent event){ if (adjustment_listeners != null) adjustment_listeners.adjustmentValueChanged(event);}voiddispatchEventImpl(AWTEvent e){ if (e.id <= AdjustmentEvent.ADJUSTMENT_LAST && e.id >= AdjustmentEvent.ADJUSTMENT_FIRST && (adjustment_listeners != null || (eventMask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0)) processEvent(e); else super.dispatchEventImpl(e);}/*************************************************************************//** * Returns a debugging string for this object. * * @return A debugging string for this object. */protected StringparamString(){ return("value=" + getValue() + ",visibleAmount=" + getVisibleAmount() + ",minimum=" + getMinimum() + ",maximum=" + getMaximum() + ",pageIncrement=" + pageIncrement + ",lineIncrement=" + lineIncrement + ",orientation=" + (orientation == HORIZONTAL ? "HORIZONTAL" : "VERTICAL") + super.paramString());}} // class Scrollbar
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -