Java Reference
In-Depth Information
EventQueue.invokeLater(showDialog);
}
};
button.addActionListener(actionListener);
frame.add(button, BorderLayout.CENTER);
frame.setSize(300, 100);
frame.setVisible(true);
}
};
EventQueue.invokeLater(runner);
}
}
■
Note
Notice that the
actionPerformed()
method that shows the color chooser uses the
EventQueue.invokeLater()
method to show the chooser. The current event handler needs to finish
before showing the chooser. Otherwise, the previous action event processing won't complete before the
chooser is shown.
JColorChooser Properties
Table 9-8 lists information on the eight properties of the
JColorChooser
, including the three
data types of the single property
color
.
Table 9-8.
JColorChooser Properties
Property Name
Data Type
Access
accessibleContext
AccessibleContext
Read-only
chooserPanels
AbstractColorChooserPanel[]
Read-write bound
color
Color
Read-write
color
int rgb
Write-only
color
int red
,
int green
,
int blue
Write-only
dragEnabled
boolean
Read-write
previewPanel
JComponent
Read-write bound
selectionModel
ColorSelectionModel
Read-write bound
UI
ColorChooserUI
Read-write bound
UIClassID
String
Read-only