2008. 4. 7. 12:10

package ex0407;

import java.awt.*;
import java.awt.event.*;

class ScrollBar2 extends Frame implements AdjustmentListener
{
 /**
  *
  */
 private static final long serialVersionUID = 1L;
 Scrollbar red, green, blue;
 Panel panel1, panel2;
 public ScrollBar2(String str)
 {
  super(str);
  red = new Scrollbar(Scrollbar.VERTICAL, 0, 10,0,255);
  green = new Scrollbar(Scrollbar.VERTICAL, 0, 10,0,255);
  blue = new Scrollbar(Scrollbar.VERTICAL, 0, 10,0,255);
 
  red.addAdjustmentListener(this);
  green.addAdjustmentListener(this);
  blue.addAdjustmentListener(this);
 
  panel1 = new Panel();
  panel2 = new Panel();
  panel1.setSize(200,100);
  panel2.setSize(200,100);
  panel2.add(red);
  panel2.add(green);
  panel2.add(blue);
  add("Center", panel1);
  add("South", panel2);
  setSize(200,200);
  setVisible(true);
 }
 
  public  void adjustmentValueChanged(AdjustmentEvent e)
  {
   panel1.setBackground(new Color(red.getValue(), green.getValue(), blue.getValue()));
  }
  public static void main(String[] args)
  {
   new ScrollBar2("Scroll");
  }
}