//HSBScroller //HSBDemo using the Scroller class //Andy Harris, 05/00 import java.awt.*; import java.applet.*; import java.awt.event.*; import Scroller; public class HSBScroller extends Applet implements AdjustmentListener{ Label lblOutput = new Label(); Scroller sclRed = new Scroller(Scroller.HSB, "H"); Scroller sclGreen = new Scroller(Scroller.HSB, "S"); Scroller sclBlue = new Scroller(Scroller.HSB, "B"); Panel pnlHSB = new Panel(); public void init(){ setLayout(new BorderLayout()); add(pnlHSB, BorderLayout.WEST); add(lblOutput, BorderLayout.CENTER); pnlHSB.setLayout(new GridLayout(1,0)); pnlHSB.add(sclRed); pnlHSB.add(sclGreen); pnlHSB.add(sclBlue); sclRed.addAdjustmentListener(this); sclGreen.addAdjustmentListener(this); sclBlue.addAdjustmentListener(this); } // end init public void adjustmentValueChanged(AdjustmentEvent e){ float hue = sclRed.getHSBValue(); float sat = sclGreen.getHSBValue(); float bright = sclBlue.getHSBValue(); Color theColor = Color.getHSBColor(hue, sat, bright); lblOutput.setBackground(theColor); } // end adjValChanged } // end class def