Home » » Color Chooser in Java Program

Color Chooser in Java Program

Color Chooser in Java Program

Color Chooser in Java Program

Color Chooser in Java Program

import java.awt.*;
import javax.Swing.*;
import javax.Swing.event.*;
public class Swing ColorChooserDemo extends JPanel implements ChangeListener
{
protected JClorChooser tcc;
public SwingColorChooserDemo()
{
super(new BorderLayout());
tcc=new JColorChooser();
tcc.getSelectionModel().addChangeListener(this);
tcc.setBorder(BorderFactory.createTitledBorder("choose Text color"));
add(tcc,BorderLayout.PAGE_END);
}
public void StateChanged(changeEvent e)
{
color newclor=tcc.get Colour();
tcc.setColor(newColor);
}
private Static void create AndShowGUI()
{
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame=new JFrame("SwingColorChooserDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JComponent newContentPane=new SwingColorChooserDemo();
newContent Pane.setOpaque(true);
frame.setContentPane(new ContentPane);
frame.pack();
frame.setVisible(true);
}
public Static void main(String args[])
{
javax.Swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
createAndShow GUI();
}
});
}

}

0 coment�rios:

Post a Comment

Link you don't want to vouch for Read more: https://html.com/seo/#ixzz5zVltiZ5g