Class PVScrollbar

java.lang.Object
com.didkovsky.portview.PVScrollbar
All Implemented Interfaces:
PVCanvas, PVComponent, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener

public class PVScrollbar
extends java.lang.Object
implements PVCanvas, java.awt.event.MouseListener, java.awt.event.MouseMotionListener
Our own horizontal scrollbar. This ViewFactory to build either an AWT or Swing version . PVScrollbarListener interface to broadcast scrollbar moves.

PVScrollbarListener's implement public void notifyScrollbarValueChanged(PVScrollbar sb); to be notified of the scrollbar's value changing.
Example follows. Note use of view factory components. Setting the view factory will build this in Swing or in AWT.
        PVScrollbarListener listener = new PVScrollbarListener() {
            public void notifyScrollbarValueChanged(PVScrollbar jmslPortableScrollbar) {
                northLabel.setText("Scrollbar value: " + jmslPortableScrollbar.getValue() + ", " + jmslPortableScrollbar.getBounds().width);
                System.out.println(jmslPortableScrollbar.getValue());
            }
        };

        PVScrollbar myScrollbar = new PVScrollbar(50, 0, 100);
        myScrollbar.addPVScrollbarListener(listener);
        myScrollbar.setSize(200, 30);
        myScrollbar.setPageIncrement(10);
        myScrollbar.setLineIncrement(1);

 
Author:
Nick Didkovsky, copyright 1999 Nick Didkovsky
  • 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

    • PVScrollbar

      public PVScrollbar()
    • PVScrollbar

      public PVScrollbar​(int value, int min, int max)
  • Method Details

    • addPVScrollbarListener

      public void addPVScrollbarListener​(PVScrollbarListener listener)
    • removePVScrollbarListener

      public void removePVScrollbarListener​(PVScrollbarListener listener)
    • getComponent

      public java.awt.Component getComponent()
      Specified by:
      getComponent in interface PVComponent
      Returns:
      implementation Component of the class that implements this interface
    • 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
    • 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)
    • drawLeftArrow

      public void drawLeftArrow​(java.awt.Graphics bg)
    • drawRightArrow

      public void drawRightArrow​(java.awt.Graphics bg)
    • drawScrollRect

      public void drawScrollRect​(java.awt.Graphics bg)
    • 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)
    • getGraphics

      public java.awt.Graphics getGraphics()
      Specified by:
      getGraphics in interface PVCanvas
    • repaint

      public void repaint()
      Specified by:
      repaint in interface PVCanvas
    • setSize

      public void setSize​(java.awt.Dimension d)
    • getSBBackgroundColor

      public java.awt.Color getSBBackgroundColor()
      Returns:
    • getImgWidth

      public int getImgWidth()
      Returns:
    • getImgHeight

      public int getImgHeight()
    • setCanvasSize

      public void setCanvasSize​(int w, int h)
      Specified by:
      setCanvasSize in interface PVCanvas
    • getParent

      public java.awt.Container getParent()
      Specified by:
      getParent in interface PVComponent
    • getBounds

      public java.awt.Rectangle getBounds()
      Specified by:
      getBounds in interface PVComponent
    • setLocation

      public void setLocation​(int x, int y)
      Specified by:
      setLocation in interface PVComponent
    • getLocation

      public java.awt.Point getLocation()
      Specified by:
      getLocation in interface PVComponent
    • setEnabled

      public void setEnabled​(boolean b)
      Specified by:
      setEnabled in interface PVComponent
    • isEnabled

      public boolean isEnabled()
      Specified by:
      isEnabled in interface PVComponent
    • addKeyListener

      public void addKeyListener​(java.awt.event.KeyListener l)
      Specified by:
      addKeyListener in interface PVComponent
    • removeKeyListener

      public void removeKeyListener​(java.awt.event.KeyListener l)
      Specified by:
      removeKeyListener in interface PVComponent
    • setBackground

      public void setBackground​(java.awt.Color color)
      Specified by:
      setBackground in interface PVComponent
    • getBackground

      public java.awt.Color getBackground()
      Specified by:
      getBackground in interface PVComponent
    • setFont

      public void setFont​(java.awt.Font font)
      Specified by:
      setFont in interface PVComponent
    • getFont

      public java.awt.Font getFont()
      Specified by:
      getFont in interface PVComponent