package jmslexamples; import java.awt.FlowLayout; import javax.swing.JApplet; import com.didkovsky.portview.*; import com.didkovsky.portview.swing.ViewFactorySwing; import com.softsynth.jmsl.JMSL; import com.softsynth.jmsl.view.PVLabelAdapter; /** * The com.didkovsky.portview scrollbar can be either awt or Swing compatible depending on the ViewFactory * * @author Nick Didkovsky, (c) 2005 Nick Didkovsky * */ public class TestPortViewScrollbar extends JApplet implements PVScrollbarListener { PVScrollbar myScrollbar; PVLabel valueLabel; public void start() { JMSL.setViewFactory(new ViewFactorySwing()); // default value 50, min value 0, max value 100 myScrollbar = new PVScrollbar(50, 0, 100); myScrollbar.addPVScrollbarListener(this); // set the size of the scrollbar myScrollbar.setSize(200, 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 PVLabelAdapter("Scrollbar value"); getContentPane().setLayout(new FlowLayout()); getContentPane().add(myScrollbar.getComponent()); getContentPane().add(valueLabel.getComponent()); } public void stop() { removeAll(); } void handleMyScrollbar() { valueLabel.setText(myScrollbar.getValue() + ""); } /** * This is the callback where a scrollbar notifies listeners that its value changed. */ public void notifyScrollbarValueChanged(PVScrollbar sb) { if (sb == myScrollbar) { handleMyScrollbar(); } } }