import javax.swing.*; 
import java.awt.*; 
import javax.swing.event.*; 
import java.awt.event.*; 
import javax.swing.border.*; 

class ColorShow extends JFrame implements AdjustmentListener{ 

JPanel m_show =new JPanel(); 
JScrollBar s_red = new JScrollBar(); 
JScrollBar s_green = new JScrollBar(); 
JScrollBar s_blue = new JScrollBar();
JPanel pan0; 
JLabel l_red,l_green,l_blue; 

public ColorShow() { 
super("调色板"); 
JScrollBar s_red=new JScrollBar(JScrollBar.HORIZONTAL); 
s_red.addAdjustmentListener(this); 
JScrollBar s_green=new JScrollBar(JScrollBar.HORIZONTAL); 
s_green.addAdjustmentListener(this); 
JScrollBar s_blue=new JScrollBar(JScrollBar.HORIZONTAL); 
s_blue.addAdjustmentListener(this); 
JPanel pan0=new JPanel(); 
JPanel m_show=new JPanel(); 
JLabel l_red=new JLabel("红色"); 
JLabel l_green=new JLabel("绿色"); 
JLabel l_blue=new JLabel("蓝色"); 

m_show.setBorder(new TitledBorder("显示")); 
pan0.setLayout(new GridLayout(3,2)); 
pan0.setBorder(new TitledBorder("调色")); 
pan0.add(l_red);pan0.add(s_red); 
pan0.add(l_green);pan0.add(s_green); 
pan0.add(l_blue);pan0.add(s_blue); 

s_red.setMinimum(0); 
s_red.setMaximum(255); 
s_green.setMinimum(0); 
s_green.setMaximum(255); 
s_blue.setMinimum(0); 
s_blue.setMaximum(255); 

getContentPane().setLayout(new GridLayout(2,1)); 
getContentPane().add(m_show); 
getContentPane().add(pan0); 

this.setVisible(true); 
this.pack(); 

} 

public void adjustmentValueChanged(AdjustmentEvent e) 
{ 
m_show.setForeground(new Color(s_red.getValue(),s_green.getValue(),s_blue.getValue())); 
} 

public static void main(String args[]) 
{ 
ColorShow cs=new ColorShow(); 
} 
} 

