| |
e877. Getting and Setting the Selected Color in a JColorChooser Dialog
Normally, the color is retrieved from a color chooser dialog when the
dialog is closed. See e884 Listening for OK and Cancel Events in a JColorChooser Dialog
for an example of how to determine when the dialog is closed.
// Create the chooser
JColorChooser chooser = new JColorChooser();
// Set the selected color
chooser.setColor(Color.red);
// Create and show dialog.
// See e876 Creating a JColorChooser Dialog.
// Get current selected color
Color color = chooser.getColor();
e876.
Creating a JColorChooser Dialog
© 2002 Addison-Wesley.
|