 // カラーを表示 (HSB) [Color4.java](JDK 1.0.2)
 import java.applet.Applet;
 import java.awt.*;
 //!import java.awt.event.*;               // JDK 1.1
 //!public class Color4 extends Applet 
 //!       implements AdjustmentListener { // JDK 1.1
 public class Color4 extends Applet { //!
  Scrollbar scrH,scrS,scrB;    // Scrollbar
  public void init() {  // アプレットロード時の初期化メソッド
     setLayout(new BorderLayout());        //(a) BorderLayout
     Panel p=new Panel();                  //(b) Panel
     p.setLayout(new GridLayout(3,2,0,5)); // 行,列,hgap,vgap
     scrH = new Scrollbar(Scrollbar.HORIZONTAL, 50,10,0,109);
     scrS = new Scrollbar(Scrollbar.HORIZONTAL,100,10,0,110);
     scrB = new Scrollbar(Scrollbar.HORIZONTAL,100,10,0,110);
     p.add(scrH);                     // Hue Scrollbar
     p.add(new Label(" Hue       ")); // 色相
     p.add(scrS);                     // Saturation
     p.add(new Label(" Saturation")); // 彩度
     p.add(scrB);                     // Brightness
     p.add(new Label(" Brightness")); // 明度
  //!   add(p,"South");
     add("South",p);
  //!   scrH.addAdjustmentListener(this); // JDK 1.1
  //!   scrS.addAdjustmentListener(this); // JDK 1.1
  //!   scrB.addAdjustmentListener(this); // JDK 1.1
     setBackground(new Color(192,192,192));  // 背景色
  } //end init
  //!//========= JDK 1.1 イベント処理(スクロールバー) =========
  //!public void adjustmentValueChanged(AdjustmentEvent e) {
  //!   repaint();
  //!} //end adjustmentValueChanged
  //========= JDK 1.0.2 イベント処理(スクロールバー) =========
  public boolean handleEvent(Event e) { //! イベントの処理
     if (e.target instanceof Scrollbar) { //!
        scrH.setValue(scrH.getValue());   //! 色相
        scrS.setValue(scrS.getValue());   //! 彩度
        scrB.setValue(scrB.getValue());   //! 明度
        repaint();
     }
     return true;
  } //end handleEvent
  //==================== update メソッド ===================
  public void update(Graphics g) {
     paint(g); // 画面をクリアしないでpaintを呼び出す
  } //end update
  //==================== paint メソッド ====================
  public void paint(Graphics g) {
     int x,y,w,h,xg,R,G,B;
     float hue=0.5f,sat=0.5f,bri=1.0f;
     w=size().width;      //!w=getSize().width;  // 横の大きさ
     h=size().height;     //!h=getSize().height; // 縦の大きさ
     x=13; y=h-115;       // x,yの初期値
     xg=(w-30)/2/16;      // 横の長さの計算
     for (int k=0; k<=15; k++) {
        float hu=(float)k/16.0f;  // 色相
        Color co = Color.getHSBColor(hu,1.0f,1.0f); //(c)
        g.setColor(co);
        g.fillRect(x,y,xg-1,19);  // 塗り潰し
        x+=xg;                    // xの増分
     }
     g.setColor(Color.black);
     g.fillRect(10,10,200,40);    // 塗り潰し
     g.setColor(Color.white);
     hue=(float)scrH.getValue()/100.0f;  // 色相
     sat=(float)scrS.getValue()/100.0f;  // 彩度
     bri=(float)scrB.getValue()/100.0f;  // 明度
     g.drawString(" H="+hue+" S="+sat+" B="+bri,15,25);
     Color co = Color.getHSBColor(hue,sat,bri);
     R=co.getRed();    // 赤の抽出
     G=co.getGreen();  // 緑の抽出
     B=co.getBlue();   // 青の抽出
     g.drawString(" R="+R+" G="+G+" B="+B,15,43);
     g.setColor(co);
     g.fillRect(w/2+20,10,60,60); // 塗り潰し
  } //end paint
 } //end Color4
