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 intHORIZONTALunused - presently always horizontalstatic intVERTICALunused - presently always horizontal -
Constructor Summary
Constructors Constructor Description PVScrollbar()PVScrollbar(int value, int min, int max) -
Method Summary
Modifier and Type Method Description voidaddKeyListener(java.awt.event.KeyListener l)voidaddPVScrollbarListener(PVScrollbarListener listener)voiddrawLeftArrow(java.awt.Graphics bg)voiddrawRightArrow(java.awt.Graphics bg)voiddrawScrollRect(java.awt.Graphics bg)java.awt.ColorgetBackground()java.awt.RectanglegetBounds()java.awt.ComponentgetComponent()java.awt.FontgetFont()java.awt.GraphicsgetGraphics()intgetImgHeight()intgetImgWidth()intgetLineIncrement()java.awt.PointgetLocation()intgetMax()intgetMin()intgetPageIncrement()java.awt.ContainergetParent()java.awt.ColorgetSBBackgroundColor()intgetValue()booleanisEnabled()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)voidremoveKeyListener(java.awt.event.KeyListener l)voidremovePVScrollbarListener(PVScrollbarListener listener)voidrepaint()voidsetArrowColor(java.awt.Color c)voidsetBackground(java.awt.Color color)voidsetBevelColor1(java.awt.Color c)voidsetBevelColor2(java.awt.Color c)voidsetCanvasSize(int w, int h)voidsetEnabled(boolean b)voidsetFont(java.awt.Font font)voidsetLineIncrement(int v)Set how much the value jumps when click on leftmost or rightmost arrow.voidsetLocation(int x, int y)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 scrollbarvoidsetSize(java.awt.Dimension d)voidsetValue(int v)voidsetValues(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:
getComponentin 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:
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) -
getGraphics
public java.awt.Graphics getGraphics()- Specified by:
getGraphicsin 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:
setCanvasSizein interfacePVCanvas
-
getParent
public java.awt.Container getParent()- Specified by:
getParentin interfacePVComponent
-
getBounds
public java.awt.Rectangle getBounds()- Specified by:
getBoundsin interfacePVComponent
-
setLocation
public void setLocation(int x, int y)- Specified by:
setLocationin interfacePVComponent
-
getLocation
public java.awt.Point getLocation()- Specified by:
getLocationin interfacePVComponent
-
setEnabled
public void setEnabled(boolean b)- Specified by:
setEnabledin interfacePVComponent
-
isEnabled
public boolean isEnabled()- Specified by:
isEnabledin interfacePVComponent
-
addKeyListener
public void addKeyListener(java.awt.event.KeyListener l)- Specified by:
addKeyListenerin interfacePVComponent
-
removeKeyListener
public void removeKeyListener(java.awt.event.KeyListener l)- Specified by:
removeKeyListenerin interfacePVComponent
-
setBackground
public void setBackground(java.awt.Color color)- Specified by:
setBackgroundin interfacePVComponent
-
getBackground
public java.awt.Color getBackground()- Specified by:
getBackgroundin interfacePVComponent
-
setFont
public void setFont(java.awt.Font font)- Specified by:
setFontin interfacePVComponent
-
getFont
public java.awt.Font getFont()- Specified by:
getFontin interfacePVComponent
-