package jmslexamples; import java.awt.*; import com.softsynth.jmsl.view.JMSLScrollbar; import com.softsynth.jmsl.view.JMSLScrollbarProcessor; /** awt's Scrollbar is weird - unreliable behavior... JMSL has its own which is very stable @author Nick Didkovsky and Phil Burk, (c) 1999 Nick Didkovsky and Phil Burk */ public class TestJMSLScrollbar extends java.applet.Applet implements JMSLScrollbarProcessor { JMSLScrollbar myScrollbar; Label valueLabel; public void init() { // A new scrollbar with this applet as parent, with default value 50, min value 0, max value 100 myScrollbar = new JMSLScrollbar(this, 50, 0, 100); // set the 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); valueLabel = new Label("Scrollbar value"); add(myScrollbar); add(valueLabel); } void handleMyScrollbar() { valueLabel.setText(myScrollbar.getValue()+""); } /** Any class using a JMSLScrollbar must implement JMSLScrollbarProcessor by defining this method */ public void JMSLScrollbarValueChanged(JMSLScrollbar jsb) { if (jsb == myScrollbar) { handleMyScrollbar(); } } public static void main(String args[]) { TestJMSLScrollbar applet = new TestJMSLScrollbar(); Frame f = new Frame("JMSL Scrollbar Demo"); f.addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); f.add(applet, BorderLayout.CENTER); applet.init(); applet.start(); f.setSize(400,100); f.setVisible(true); } }