import java.awt.*;
import java.awt.event.*;
public class ScrollDemo extends Frame implements AdjustmentListener,WindowListener{
Scrollbar r,g,b;
ScrollDemo(){
super("Scroll Color Setting");
setSize(500,600);
setLayout(new FlowLayout());
r=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,255);
g=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,255);
b=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,255);
add(r);
add(g);
add(b);
setVisible(true);
r.addAdjustmentListener(this);
g.addAdjustmentListener(this);
b.addAdjustmentListener(this);
addWindowListener(this);
Color c=new Color(r.getValue(),g.getValue(),b.getValue());
setBackground(c);
}
public void windowActivated(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowClosing(WindowEvent e){
System.exit(0);
}
public void windowDeactivated(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void adjustmentValueChanged(AdjustmentEvent e){
Color c=new Color(r.getValue(),g.getValue(),b.getValue());
setBackground(c);
}
public static void main(String ar[]){
ScrollDemo cH=new ScrollDemo();
}
}
No comments:
Post a Comment