هذا مثال
======================================
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
public class JSliderex extends JApplet implements ChangeListener//,ActionListener
{
Container c;
JSlider s,c1,c2,c3;
d p;
Font f;
Color col;
JLabel l;
public void init()
{
JPanel p1=new JPanel();
c1=new JSlider(JSlider.VERTICAL,0,255,0);`
c2=new JSlider(JSlider.VERTICAL,0,255,0);
c3=new JSlider(JSlider.VERTICAL,0,255,0);
l=new JLabel();
s=new JSlider(0,40,20);
c=getContentPane();
c.add(s,BorderLayout.NORTH);
p1.add(c1);
p1.add(c2);
p1.add(c3);
f=new Font("SansSerif", Font.BOLD ,20 );
p=new d();
p.setLayout(new FlowLayout());
c.add(p,BorderLayout.CENTER);
c.add(p1,BorderLayout.WEST);
c.add(l,BorderLayout.SOUTH);
http://c.setBackground(col);
s.setLabelTable(s.createStandardLabels(20));
s.setPaintLabels(true);
s.addChangeListener(this);
c1.addChangeListener(this);
c2.addChangeListener(this);
c3.addChangeListener(this);
}
public void stateChanged(ChangeEvent e)
{
int x=s.getValue();
int x1=c1.getValue();
int x2=c2.getValue();
int x3=c3.getValue();
col=new Color(x1,x2,x3);
f=new Font("SansSerif", Font.BOLD ,x );
l.setText("R = "+x1+" G = "+x2+" B = "+x3);
repaint();
}
class d extends JPanel{
public d(){setBackground(Color.white);};
public void paint(Graphics g)
{
g.setColor(col);
g.setFont(f);
g.drawString("Jak",100,100);
}
}
}