Color Chooser Java
Saturday, 25 January 2014Posted by
Amrishwa
0 Comments
For building a color chosser application first of all we have to import necessary packages.
import java.awt.Color;
import javax.swing.JColorChooser;
import javax.swing.JDialog;
There after we have to write this code on button click event
like this.
Color cl=JColorChooser.showDialog(mainPanel, "Select a Color", mainPanel.getBackground());
if(cl!=null)
{
mainPanel.setBackground(cl);
jLabel1.setBackground(cl);
}
else
System.out.println("Not found colors");
That’s It.
Subscribe to:
Post Comments (Atom)