I'm puzzled by the behavior of TableDialogEditDemo
<
http://java.sun.com/docs/books/tutorial/uiswing/examples/zipfiles/compon
ents-TableDialogEditDemoProject.zip>
under Java
1.5.0_13, on Mac OS
10.4.11. The first time the JColorChooser
dialog is displayed, the OK button is the default; on subsequent
invocations, no default appears. The relevant code in CellEditor.java
instantiates JColorChooser and creates a dialog
colorChooser = new JColorChooser();
dialog = JColorChooser.createDialog(...)
The code then reveals the dialog in the actionPerformed() method, when a
table cell is clicked:
dialog.setVisible(true);
Although it's a bit slower, the problem does not occur if the dialog is
re-created each time:
newColor = JColorChooser.showDialog(null, "Choose...", currentColor);
Is this a platform anomaly? Is there a way to set the default button
before making the dialog visible?
Thanks for any insights,