summaryrefslogtreecommitdiff
path: root/javax/swing/JRootPane.java
diff options
context:
space:
mode:
Diffstat (limited to 'javax/swing/JRootPane.java')
-rw-r--r--javax/swing/JRootPane.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/javax/swing/JRootPane.java b/javax/swing/JRootPane.java
index dec43956c..b99384a32 100644
--- a/javax/swing/JRootPane.java
+++ b/javax/swing/JRootPane.java
@@ -624,12 +624,15 @@ public class JRootPane extends JComponent implements Accessible
public void setDefaultButton(JButton newButton)
{
- if (defaultButton == newButton)
- return;
-
- JButton oldButton = defaultButton;
- defaultButton = newButton;
- firePropertyChange("defaultButton", oldButton, newButton);
+ // We only change the default button if the new button is defaultCapable
+ // or null and the old and new button are different objects.
+ if (defaultButton != newButton
+ && (newButton == null || newButton.isDefaultCapable()))
+ {
+ JButton oldButton = defaultButton;
+ defaultButton = newButton;
+ firePropertyChange("defaultButton", oldButton, newButton);
+ }
}
/**