Package com.softsynth.jmsl.view
Class JMSLScrollbar
java.lang.Object
java.awt.Component
java.awt.Canvas
com.softsynth.jmsl.view.JMSLScrollbar
- All Implemented Interfaces:
java.awt.event.MouseListener,java.awt.event.MouseMotionListener,java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,java.util.EventListener,javax.accessibility.Accessible
public class JMSLScrollbar
extends java.awt.Canvas
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener
Our own horizontal scrollbar, subclass of canvas, which uses
JMSLScrollbarProcessor interface to communicate with parent.
Example:
Parent must implement public void JMSLScrollbarValueChanged(JMSLScrollbar jsb) to be notified of the scrollbar's value changing.
Example:
Example:
// A new scrollbar with parent, with default value 50, min value 0, max value 100 // Assumes "this" is a class that implements JMSLScrollbarProcessor myScrollbar = new JMSLScrollbar(this, 50, 0, 100); // set the graphic size of the scrollbar myScrollbar.setSize(320, 25); // set the increment that the value will jump when user clicks inside scrollbar myScrollbar.setPageIncrement(10); // set the increment that the value will jump when user clicks on arrows of scrollbar myScrollbar.setLineIncrement(1); // add it to layout add(myScrollbar); ...
Parent must implement public void JMSLScrollbarValueChanged(JMSLScrollbar jsb) to be notified of the scrollbar's value changing.
Example:
public void JMSLScrollbarValueChanged(JMSLScrollbar jsb) {
if (jsb == myScrollbar) {
System.out.println("Value = " + myScrollbar.getValue());
}
}
- Author:
- Nick Didkovsky, copyright 1999 Nick Didkovsky
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior -
Field Summary
Fields Modifier and Type Field Description static intHORIZONTALunused - presently always horizontalstatic intVERTICALunused - presently always horizontalFields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors Constructor Description JMSLScrollbar()JMSLScrollbar(JMSLScrollbarProcessor par, int v, int min, int max)Constructor with parent who will receive notification of value change, initial value, min value, max value. -
Method Summary
Modifier and Type Method Description intgetLineIncrement()intgetMax()intgetMin()intgetPageIncrement()intgetValue()static voidmain(java.lang.String[] args)voidmouseClicked(java.awt.event.MouseEvent e)voidmouseDragged(java.awt.event.MouseEvent e)voidmouseEntered(java.awt.event.MouseEvent e)voidmouseExited(java.awt.event.MouseEvent e)voidmouseMoved(java.awt.event.MouseEvent e)voidmousePressed(java.awt.event.MouseEvent e)voidmouseReleased(java.awt.event.MouseEvent e)voidpaint(java.awt.Graphics g)voidsetArrowColor(java.awt.Color c)voidsetBevelColor1(java.awt.Color c)voidsetBevelColor2(java.awt.Color c)voidsetLineIncrement(int v)Set how much the value jumps when click on leftmost or rightmost arrow.voidsetMax(int max)set the max value for this scrollbarvoidsetMin(int min)set the min value for this scrollbarvoidsetPageIncrement(int v)Set how much the value jumps when click to left or right of slider.voidsetScrollbarBackgroundColor(java.awt.Color c)voidsetSize(int w, int h)reshape size of scrollbarvoidsetValue(int v)voidsetValues(int v, int min, int max)Set current value, minimum value, maximum value of scrollbarvoidupdate(java.awt.Graphics g)Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategyMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, dispatchEvent, doLayout, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validateMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
HORIZONTAL
public static final int HORIZONTALunused - presently always horizontal- See Also:
- Constant Field Values
-
VERTICAL
public static final int VERTICALunused - presently always horizontal- See Also:
- Constant Field Values
-
-
Constructor Details
-
JMSLScrollbar
public JMSLScrollbar() -
JMSLScrollbar
Constructor with parent who will receive notification of value change, initial value, min value, max value. LineIncrement defaults to 1, PageIncrement defaults to 10 (see setLineIncrement() and setPageIncrement() below)
-
-
Method Details
-
setArrowColor
public void setArrowColor(java.awt.Color c) -
setBevelColor1
public void setBevelColor1(java.awt.Color c) -
setBevelColor2
public void setBevelColor2(java.awt.Color c) -
setScrollbarBackgroundColor
public void setScrollbarBackgroundColor(java.awt.Color c) -
setValues
public void setValues(int v, int min, int max)Set current value, minimum value, maximum value of scrollbar -
setMin
public void setMin(int min)set the min value for this scrollbar -
setMax
public void setMax(int max)set the max value for this scrollbar -
getMin
public int getMin()- Returns:
- min value for this scrollbar
-
getMax
public int getMax()- Returns:
- max value for this scrollbar
-
setSize
public void setSize(int w, int h)reshape size of scrollbar- Overrides:
setSizein classjava.awt.Component
-
setPageIncrement
public void setPageIncrement(int v)Set how much the value jumps when click to left or right of slider. Default is 10 -
getPageIncrement
public int getPageIncrement() -
setLineIncrement
public void setLineIncrement(int v)Set how much the value jumps when click on leftmost or rightmost arrow. Default is 1 -
getLineIncrement
public int getLineIncrement() -
getValue
public int getValue()- Returns:
- Scrollbar's current value
-
setValue
public void setValue(int v) -
update
public void update(java.awt.Graphics g)- Overrides:
updatein classjava.awt.Canvas
-
paint
public void paint(java.awt.Graphics g)- Overrides:
paintin classjava.awt.Canvas
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)- Specified by:
mouseDraggedin interfacejava.awt.event.MouseMotionListener
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)- Specified by:
mouseMovedin interfacejava.awt.event.MouseMotionListener
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent e)- Specified by:
mouseClickedin interfacejava.awt.event.MouseListener
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)- Specified by:
mousePressedin interfacejava.awt.event.MouseListener
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent e)- Specified by:
mouseEnteredin interfacejava.awt.event.MouseListener
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)- Specified by:
mouseExitedin interfacejava.awt.event.MouseListener
-
main
public static void main(java.lang.String[] args)
-