summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2005-07-15 11:41:05 +0000
committerRoman Kennke <roman@kennke.org>2005-07-15 11:41:05 +0000
commitcaaedaabb5f445a1826d804543ffefc68ef566c5 (patch)
tree424ee1e29e6714c63549f476bf75469ac0d0b720
parent349b866a445a60d9327414555ea9deff6c046ab5 (diff)
downloadclasspath-caaedaabb5f445a1826d804543ffefc68ef566c5.tar.gz
2005-07-15 Roman Kennke <roman@kennke.org>
* javax/swing/AbstractButton.java (AbstractButton): Directly call init() and updateUI(). (AbstractButton(String, Icon)): Removed. This is not necessary since we have init(String, Icon) for that purpose. (getActionCommand): Reverted to previous behaviour: If actionCommand is set, return this, otherwise return text, even if text is null. * javax/swing/JButton.java (JButton(String, Icon)): Call super() and init(String, Icon) instead of super(String, Icon). * javax/swing/JMenuItem.java (JMenuItem): Call super() instead of super(String, Icon). (JMenuItem(Icon)): Call this(String, Icon) instead of super(String, Icon). (JMenuItem(String)): Call this(String, Icon) instead of super(String, Icon). (JMenuItem(Action)): Call super() instead of super(String, Icon). (JMenuItem(String, Icon)): Call super() and init(String, Icon) instead of super(String, Icon). (JMenuItem(String, int)): Call this(String, Icon) instead of super(String, Icon). * javax/swing/JToggleButton.java (ToggleButtonModel.setPressed): Fire an ActionEvent if button is released. According to my Mauve tests, it seems that this is what the JDK does, so do we. (ToggleButtonModel.setSelected): Removed. (JToggleButton): Call super() and init(String, Icon) instead of super(String, Icon).
-rw-r--r--ChangeLog32
-rw-r--r--javax/swing/AbstractButton.java17
-rw-r--r--javax/swing/JButton.java3
-rw-r--r--javax/swing/JMenuItem.java14
-rw-r--r--javax/swing/JToggleButton.java24
5 files changed, 52 insertions, 38 deletions
diff --git a/ChangeLog b/ChangeLog
index 66253e504..3585d4c6b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2005-07-15 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/AbstractButton.java
+ (AbstractButton): Directly call init() and updateUI().
+ (AbstractButton(String, Icon)): Removed. This is not necessary
+ since we have init(String, Icon) for that purpose.
+ (getActionCommand): Reverted to previous behaviour: If
+ actionCommand is set, return this, otherwise return text, even
+ if text is null.
+ * javax/swing/JButton.java
+ (JButton(String, Icon)): Call super() and init(String, Icon)
+ instead of super(String, Icon).
+ * javax/swing/JMenuItem.java
+ (JMenuItem): Call super() instead of super(String, Icon).
+ (JMenuItem(Icon)): Call this(String, Icon) instead of
+ super(String, Icon).
+ (JMenuItem(String)): Call this(String, Icon) instead of
+ super(String, Icon).
+ (JMenuItem(Action)): Call super() instead of
+ super(String, Icon).
+ (JMenuItem(String, Icon)): Call super() and init(String, Icon)
+ instead of super(String, Icon).
+ (JMenuItem(String, int)): Call this(String, Icon) instead of
+ super(String, Icon).
+ * javax/swing/JToggleButton.java
+ (ToggleButtonModel.setPressed): Fire an ActionEvent if button
+ is released. According to my Mauve tests, it seems that this
+ is what the JDK does, so do we.
+ (ToggleButtonModel.setSelected): Removed.
+ (JToggleButton): Call super() and init(String, Icon) instead
+ of super(String, Icon).
+
2005-07-15 Robert Schuster <robertschuster@fsfe.org>
* javax/swing/tree/DefaultMutableTreeNode.java:
diff --git a/javax/swing/AbstractButton.java b/javax/swing/AbstractButton.java
index 8984c633c..5aaf71651 100644
--- a/javax/swing/AbstractButton.java
+++ b/javax/swing/AbstractButton.java
@@ -517,18 +517,7 @@ public abstract class AbstractButton extends JComponent
*/
public AbstractButton()
{
- this("",null);
- }
-
- /**
- * Creates a new AbstractButton object.
- *
- * @param txt Value to use for the button's "text" property
- * @param icon Value to use for the button's "defaultIcon" property
- */
- AbstractButton(String txt, Icon icon)
- {
- init (txt, icon);
+ init("", null);
updateUI();
}
@@ -610,10 +599,8 @@ public abstract class AbstractButton extends JComponent
String ac = model.getActionCommand();
if (ac != null)
return ac;
- else if (text != null)
- return text;
else
- return "";
+ return text;
}
/**
diff --git a/javax/swing/JButton.java b/javax/swing/JButton.java
index 7f8f43749..0234e47af 100644
--- a/javax/swing/JButton.java
+++ b/javax/swing/JButton.java
@@ -77,7 +77,8 @@ public class JButton extends AbstractButton
public JButton(String text, Icon icon)
{
- super(text, icon);
+ super();
+ init(text, icon);
setModel(new DefaultButtonModel());
}
diff --git a/javax/swing/JMenuItem.java b/javax/swing/JMenuItem.java
index 02f32bb17..069b7bc86 100644
--- a/javax/swing/JMenuItem.java
+++ b/javax/swing/JMenuItem.java
@@ -83,7 +83,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
*/
public JMenuItem()
{
- super(null, null);
+ super();
}
/**
@@ -95,7 +95,8 @@ public class JMenuItem extends AbstractButton implements Accessible,
{
// FIXME: The requestedFocusEnabled property should
// be set to false, when only icon is set for menu item.
- super(null, icon);
+ super();
+ init(null, icon);
}
/**
@@ -105,7 +106,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
*/
public JMenuItem(String text)
{
- super(text, null);
+ this(text, null);
}
/**
@@ -115,7 +116,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
*/
public JMenuItem(Action action)
{
- super(null, null);
+ super();
super.setAction(action);
}
@@ -128,7 +129,8 @@ public class JMenuItem extends AbstractButton implements Accessible,
*/
public JMenuItem(String text, Icon icon)
{
- super(text, icon);
+ super();
+ init(text, icon);
}
/**
@@ -141,7 +143,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
*/
public JMenuItem(String text, int mnemonic)
{
- super(text, null);
+ this(text, null);
setMnemonic(mnemonic);
}
diff --git a/javax/swing/JToggleButton.java b/javax/swing/JToggleButton.java
index 957db0c7c..0e1b9e601 100644
--- a/javax/swing/JToggleButton.java
+++ b/javax/swing/JToggleButton.java
@@ -133,7 +133,6 @@ public class JToggleButton extends AbstractButton implements Accessible
/**
* Sets the pressed state of the button. The selected state
* of the button also changes follwing the button being pressed.
- * Unlike DefaultButtonModel, does not fire an ActionEvent.
*
* @param b true if the button is pressed down.
*/
@@ -159,20 +158,12 @@ public class JToggleButton extends AbstractButton implements Accessible
// setPressed(false) == mouse release on us,
// if we were armed, we flip the selected state.
if (!p && isArmed())
- setSelected(! isSelected());
- }
-
- /**
- * Sets the selected state of the button. Unlike DefaultButtonModel,
- * fires an ActionEvent.
- *
- * @param s true if button is selected
- */
- public void setSelected(boolean s)
- {
- super.setSelected(s);
- fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
- actionCommand));
+ {
+ fireActionPerformed(new ActionEvent(this,
+ ActionEvent.ACTION_PERFORMED,
+ actionCommand));
+ setSelected(! isSelected());
+ }
}
}
@@ -269,7 +260,8 @@ public class JToggleButton extends AbstractButton implements Accessible
*/
public JToggleButton (String text, Icon icon, boolean selected)
{
- super(text, icon);
+ super();
+ init(text, icon);
setModel(new ToggleButtonModel());
model.setSelected(selected);