import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class scroll extends JFrame implements AdjustmentListener
{
JScrollBar s1,s2,s3;
Container c=getContentPane();
scroll()
{
c.setLayout(null);
s1=new JScrollBar(1,0,0,0,255); //JScrollBar.VERTICAL
s1.setBounds(100,100,20,150);
s1.addAdjustmentListener(this);
c.add(s1);
s2=new JScrollBar(JScrollBar.VERTICAL,0,0,0,255);
s2.setBounds(130,100,20,150);
s2.addAdjustmentListener(this);
c.add(s2);
s3=new JScrollBar(JScrollBar.VERTICAL,0,0,0,255);
s3.setBounds(160,100,20,150);
s3.addAdjustmentListener(this);
c.add(s3);
}
public void adjustmentValueChanged(AdjustmentEvent ae)
{
Graphics g=getGraphics();
c.setBackground(new Color(s1.getValue(),s2.getValue(),s3.getValue()));
g.drawString(String.valueOf(s1.getValue()),100,80);
g.drawString(String.valueOf(s2.getValue()),130,80);
g.drawString(String.valueOf(s3.getValue()),160,80);
}
public static void main(String args[])
{
scroll f=new scroll();
f.setSize(400,400);
f.setVisible(true);
}
}
No comments:
Post a Comment