com.didkovsky.portview
Class PVScrollbar

java.lang.Object
  extended by 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.

 
 

Author:
Nick Didkovsky, copyright 1999 Nick Didkovsky

Field Summary
static int HORIZONTAL
          unused - presently always horizontal
static int VERTICAL
          unused - presently always horizontal
 
Constructor Summary
PVScrollbar()
           
PVScrollbar(int value, int min, int max)
           
 
Method Summary
 void addKeyListener(java.awt.event.KeyListener l)
           
 void addPVScrollbarListener(PVScrollbarListener listener)
           
 void drawLeftArrow(java.awt.Graphics bg)
           
 void drawRightArrow(java.awt.Graphics bg)
           
 void drawScrollRect(java.awt.Graphics bg)
           
 java.awt.Color getBackground()
           
 java.awt.Rectangle getBounds()
           
 java.awt.Component getComponent()
           
 java.awt.Font getFont()
           
 java.awt.Graphics getGraphics()
           
 int getImgHeight()
           
 int getImgWidth()
           
 int getLineIncrement()
           
 int getMax()
           
 int getMin()
           
 int getPageIncrement()
           
 java.awt.Container getParent()
           
 java.awt.Color getSBBackgroundColor()
           
 int getValue()
           
 boolean isEnabled()
           
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 removeKeyListener(java.awt.event.KeyListener l)
           
 void removePVScrollbarListener(PVScrollbarListener listener)
           
 void repaint()
           
 void setArrowColor(java.awt.Color c)
           
 void setBackground(java.awt.Color color)
           
 void setBevelColor1(java.awt.Color c)
           
 void setBevelColor2(java.awt.Color c)
           
 void setCanvasSize(int w, int h)
           
 void setEnabled(boolean b)
           
 void setFont(java.awt.Font font)
           
 void setLineIncrement(int v)
          Set how much the value jumps when click on leftmost or rightmost arrow.
 void setLocation(int x, int y)
           
 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(java.awt.Dimension d)
           
 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
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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 Detail

PVScrollbar

public PVScrollbar()

PVScrollbar

public PVScrollbar(int value,
                   int min,
                   int max)
Method Detail

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

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