colorchooser example
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
/*
*/
public class colorchooser extends JApplet implements ActionListener
{
JPanel jpanel = new JPanel();
JButton jbutton;
public void init()
{
jbutton = new JButton("Click here to change colors.");
jbutton.addActionListener(this);
jpanel.add(jbutton);
getContentPane().add(jpanel); //, BorderLayout.CENTER);
}
public void actionPerformed(ActionEvent e)
{
Color color = JColorChooser.showDialog(colorchooser.this,
"Select a new color...", Color.white);
jpanel.setBackground(color);
}
}
import javax.swing.*;
import java.awt.event.*;
/*
*/
public class colorchooser extends JApplet implements ActionListener
{
JPanel jpanel = new JPanel();
JButton jbutton;
public void init()
{
jbutton = new JButton("Click here to change colors.");
jbutton.addActionListener(this);
jpanel.add(jbutton);
getContentPane().add(jpanel); //, BorderLayout.CENTER);
}
public void actionPerformed(ActionEvent e)
{
Color color = JColorChooser.showDialog(colorchooser.this,
"Select a new color...", Color.white);
jpanel.setBackground(color);
}
}
Comments
Post a Comment