Java Reference
In-Depth Information
Display 18.20 JColorChooser Dialog (part 2 of 2)
36 public void actionPerformed(ActionEvent e)
37 {
38 if (e.getActionCommand().equals("Choose a Color"))
39 {
40 sampleColor =
41 JColorChooser.showDialog( this ,
"JColorChooser", sampleColor);
42 if (sampleColor != null )//If a color was chosen
43 getContentPane().setBackground(sampleColor);
44 }
45 else
46 System.out.println("Unanticipated Error");
47 }
48 }
Resulting GUI (Three views of one GUI)
Start view.
After clicking
Choose a Color.
After clicking the RGB tab.
 
Search WWH ::




Custom Search