File tree 1 file changed +13
-0
lines changed
src/main/java/org/scijava/ui/swing
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 32
32
33
33
import java .awt .BorderLayout ;
34
34
import java .awt .Component ;
35
+ import java .awt .Container ;
35
36
import java .awt .Insets ;
36
37
import java .awt .Window ;
37
38
import java .awt .event .WindowAdapter ;
@@ -203,6 +204,9 @@ public boolean isModal() {
203
204
public void setModal (final boolean modal ) {
204
205
this .modal = modal ;
205
206
buttons .setVisible (modal );
207
+
208
+ // disable the buttons if non-modal, to avoid ENTER closing the dialog.
209
+ setEnabled (buttons , modal );
206
210
}
207
211
208
212
/** Gets whether the dialog is resizable by the user. */
@@ -351,4 +355,13 @@ public void windowGainedFocus(final WindowEvent e) {
351
355
});
352
356
}
353
357
358
+ /** Recursively enable or disable components. */
359
+ private void setEnabled (final Component c , final boolean enabled ) {
360
+ if (c instanceof Container ) {
361
+ for (final Component child : ((Container ) c ).getComponents ()) {
362
+ setEnabled (child , enabled );
363
+ }
364
+ }
365
+ c .setEnabled (enabled );
366
+ }
354
367
}
You can’t perform that action at this time.
0 commit comments