package cs1;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class myJFrame extends JFrame implements ActionListener
{
private JColorChooser jcc;
private JDialog jdd;
private JButton jbb;
public static void main(String args[])
{
myJFrame test=new myJFrame();
test.setTitle("JFrame");
test.setSize(300,200);
test.setVisible(true);
}
public myJFrame()
{
jcc=new JColorChooser();
jdd=JColorChooser.createDialog(this,"选择颜色",true,jcc,this,null);
jbb=new JButton("click");
jbb.addActionListener(this);
getContentPane().add(jbb,BorderLayout.NORTH);
}
public void actionPerformed(ActionEvent e)
{
String text=((JButton)e.getSource()).getText();
if(text=="click")
jdd.show();
else
jbb.setBackground(jcc.getColor());
}
}