import java.applet.*; import java.awt.*; public class scroller extends Applet { Scrollbar colorscroll = new Scrollbar(Scrollbar.VERTICAL,0,0,0,255); int redvalue = 175; Label scrollvalue = new Label(String.valueOf(redvalue)); public void init() { add(new Label("Scroll to change the color of the box.")); add(colorscroll); colorscroll.setPageIncrement(50); colorscroll.setValue(175); add(new Label("value of the scrollbar =")); add(scrollvalue); } public void paint (Graphics g) { g.setColor(new Color(redvalue,0,0)); g.fillRect(90,90,100,100); } public boolean handleEvent(Event evt) { if (evt.target instanceof Scrollbar) { redvalue = colorscroll.getValue(); scrollvalue.setText(String.valueOf(redvalue)); repaint(); return true; } return false; } }