Package com.didkovsky.portview
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'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 Summary
Fields Modifier and Type Field Description static int
HORIZONTAL
unused - presently always horizontalstatic int
VERTICAL
unused - presently always horizontal -
Constructor Summary
Constructors Constructor Description PVScrollbar()
PVScrollbar(int value, int min, int max)
-
Method Summary
Modifier and Type Method Description 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()
java.awt.Point
getLocation()
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 scrollbarvoid
setMin(int min)
set the min value for this scrollbarvoid
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 scrollbarvoid
setSize(java.awt.Dimension d)
void
setValue(int v)
void
setValues(int v, int min, int max)
Set current value, minimum value, maximum value of scrollbarMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, 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
-
PVScrollbar
public PVScrollbar() -
PVScrollbar
public PVScrollbar(int value, int min, int max)
-
-
Method Details
-
addPVScrollbarListener
-
removePVScrollbarListener
-
getComponent
public java.awt.Component getComponent()- Specified by:
getComponent
in interfacePVComponent
- 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 interfacejava.awt.event.MouseMotionListener
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)- Specified by:
mouseMoved
in interfacejava.awt.event.MouseMotionListener
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent e)- Specified by:
mouseClicked
in interfacejava.awt.event.MouseListener
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)- Specified by:
mousePressed
in interfacejava.awt.event.MouseListener
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)- Specified by:
mouseReleased
in interfacejava.awt.event.MouseListener
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent e)- Specified by:
mouseEntered
in interfacejava.awt.event.MouseListener
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)- Specified by:
mouseExited
in interfacejava.awt.event.MouseListener
-
main
public static void main(java.lang.String[] args) -
getGraphics
public java.awt.Graphics getGraphics()- Specified by:
getGraphics
in interfacePVCanvas
-
repaint
public void repaint() -
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 interfacePVCanvas
-
getParent
public java.awt.Container getParent()- Specified by:
getParent
in interfacePVComponent
-
getBounds
public java.awt.Rectangle getBounds()- Specified by:
getBounds
in interfacePVComponent
-
setLocation
public void setLocation(int x, int y)- Specified by:
setLocation
in interfacePVComponent
-
getLocation
public java.awt.Point getLocation()- Specified by:
getLocation
in interfacePVComponent
-
setEnabled
public void setEnabled(boolean b)- Specified by:
setEnabled
in interfacePVComponent
-
isEnabled
public boolean isEnabled()- Specified by:
isEnabled
in interfacePVComponent
-
addKeyListener
public void addKeyListener(java.awt.event.KeyListener l)- Specified by:
addKeyListener
in interfacePVComponent
-
removeKeyListener
public void removeKeyListener(java.awt.event.KeyListener l)- Specified by:
removeKeyListener
in interfacePVComponent
-
setBackground
public void setBackground(java.awt.Color color)- Specified by:
setBackground
in interfacePVComponent
-
getBackground
public java.awt.Color getBackground()- Specified by:
getBackground
in interfacePVComponent
-
setFont
public void setFont(java.awt.Font font)- Specified by:
setFont
in interfacePVComponent
-
getFont
public java.awt.Font getFont()- Specified by:
getFont
in interfacePVComponent
-