File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
src/main/java/org/scijava/ui/swing Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 3232
3333import java .awt .BorderLayout ;
3434import java .awt .Component ;
35+ import java .awt .Container ;
3536import java .awt .Insets ;
3637import java .awt .Window ;
3738import java .awt .event .WindowAdapter ;
@@ -203,6 +204,9 @@ public boolean isModal() {
203204 public void setModal (final boolean modal ) {
204205 this .modal = modal ;
205206 buttons .setVisible (modal );
207+
208+ // disable the buttons if non-modal, to avoid ENTER closing the dialog.
209+ setEnabled (buttons , modal );
206210 }
207211
208212 /** Gets whether the dialog is resizable by the user. */
@@ -351,4 +355,13 @@ public void windowGainedFocus(final WindowEvent e) {
351355 });
352356 }
353357
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+ }
354367}
You can’t perform that action at this time.
0 commit comments