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:
 
  
   // 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 int HORIZONTAL
    unused - presently always horizontal
    static int VERTICAL
    unused - presently always horizontal

    Fields inherited from class java.awt.Component

    BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT

    Fields 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
    int getLineIncrement()  
    int getMax()  
    int getMin()  
    int getPageIncrement()  
    int getValue()  
    static void main​(java.lang.String[] args)  
    void mouseClicked​(java.awt.event.MouseEvent e)  
    void mouseDragged​(java.awt.event.MouseEvent e)  
    void mouseEntered​(java.awt.event.MouseEvent e)  
    void mouseExited​(java.awt.event.MouseEvent e)  
    void mouseMoved​(java.awt.event.MouseEvent e)  
    void mousePressed​(java.awt.event.MouseEvent e)  
    void mouseReleased​(java.awt.event.MouseEvent e)  
    void paint​(java.awt.Graphics g)  
    void setArrowColor​(java.awt.Color c)  
    void setBevelColor1​(java.awt.Color c)  
    void setBevelColor2​(java.awt.Color c)  
    void setLineIncrement​(int v)
    Set how much the value jumps when click on leftmost or rightmost arrow.
    void setMax​(int max)
    set the max value for this scrollbar
    void setMin​(int min)
    set the min value for this scrollbar
    void setPageIncrement​(int v)
    Set how much the value jumps when click to left or right of slider.
    void setScrollbarBackgroundColor​(java.awt.Color c)  
    void setSize​(int w, int h)
    reshape size of scrollbar
    void setValue​(int v)  
    void setValues​(int v, int min, int max)
    Set current value, minimum value, maximum value of scrollbar
    void update​(java.awt.Graphics g)  

    Methods inherited from class java.awt.Canvas

    addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy

    Methods 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, validate

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • HORIZONTAL

      public static final int HORIZONTAL
      unused - presently always horizontal
      See Also:
      Constant Field Values
    • VERTICAL

      public static final int VERTICAL
      unused - presently always horizontal
      See Also:
      Constant Field Values
  • Constructor Details

    • JMSLScrollbar

      public JMSLScrollbar()
    • JMSLScrollbar

      public 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. 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:
      setSize in class java.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:
      update in class java.awt.Canvas
    • paint

      public void paint​(java.awt.Graphics g)
      Overrides:
      paint in class java.awt.Canvas
    • mouseDragged

      public void mouseDragged​(java.awt.event.MouseEvent e)
      Specified by:
      mouseDragged in interface java.awt.event.MouseMotionListener
    • mouseMoved

      public void mouseMoved​(java.awt.event.MouseEvent e)
      Specified by:
      mouseMoved in interface java.awt.event.MouseMotionListener
    • mouseClicked

      public void mouseClicked​(java.awt.event.MouseEvent e)
      Specified by:
      mouseClicked in interface java.awt.event.MouseListener
    • mousePressed

      public void mousePressed​(java.awt.event.MouseEvent e)
      Specified by:
      mousePressed in interface java.awt.event.MouseListener
    • mouseReleased

      public void mouseReleased​(java.awt.event.MouseEvent e)
      Specified by:
      mouseReleased in interface java.awt.event.MouseListener
    • mouseEntered

      public void mouseEntered​(java.awt.event.MouseEvent e)
      Specified by:
      mouseEntered in interface java.awt.event.MouseListener
    • mouseExited

      public void mouseExited​(java.awt.event.MouseEvent e)
      Specified by:
      mouseExited in interface java.awt.event.MouseListener
    • main

      public static void main​(java.lang.String[] args)