Index: javax/swing/AbstractButton.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/AbstractButton.java,v retrieving revision 1.20 diff -u -r1.20 AbstractButton.java --- javax/swing/AbstractButton.java 5 Sep 2004 20:03:23 -0000 1.20 +++ javax/swing/AbstractButton.java 23 Sep 2004 13:10:03 -0000 @@ -240,7 +240,7 @@ PropertyChangeListener actionPropertyChangeListener; /** ChangeEvent that is fired to button's ChangeEventListeners */ - private ChangeEvent changeEvent = new ChangeEvent(this); + protected ChangeEvent changeEvent = new ChangeEvent(this); /** Fired in a PropertyChangeEvent when the "borderPainted" property changes. */ public static final String BORDER_PAINTED_CHANGED_PROPERTY = "borderPainted"; @@ -441,7 +441,7 @@ { return null; // TODO } - } + } /** * Creates a new AbstractButton object. @@ -690,11 +690,8 @@ /** * Calls address@hidden ChangeEvent.stateChanged} on each address@hidden ChangeListener} * in the button's listener list. - * - * @param e The event signifying a change in one of the (non-bound) - * properties of the button's model. */ - public void fireStateChanged(ChangeEvent e) + public void fireStateChanged() { ChangeListener[] listeners = getChangeListeners(); @@ -784,8 +781,8 @@ { if (index < -1 || (text != null && index >= text.length())) throw new IllegalArgumentException(); - else - mnemonicIndex = index; + + mnemonicIndex = index; } /** @@ -891,14 +888,14 @@ */ public void setHorizontalAlignment(int a) { + if (horizontalAlignment == a) + return; + int old = horizontalAlignment; horizontalAlignment = a; - if (old != a) - { - firePropertyChange(HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, old, a); - revalidate(); - repaint(); - } + firePropertyChange(HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, old, a); + revalidate(); + repaint(); } /** @@ -928,14 +925,14 @@ */ public void setHorizontalTextPosition(int t) { + if (horizontalTextPosition == t) + return; + int old = horizontalTextPosition; horizontalTextPosition = t; - if (old != t) - { - firePropertyChange(HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, old, t); - revalidate(); - repaint(); - } + firePropertyChange(HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, old, t); + revalidate(); + repaint(); } /** @@ -963,14 +960,14 @@ */ public void setVerticalAlignment(int a) { + if (verticalAlignment == a) + return; + int old = verticalAlignment; verticalAlignment = a; - if (old != a) - { - firePropertyChange(VERTICAL_ALIGNMENT_CHANGED_PROPERTY, old, a); - revalidate(); - repaint(); - } + firePropertyChange(VERTICAL_ALIGNMENT_CHANGED_PROPERTY, old, a); + revalidate(); + repaint(); } /** @@ -1000,14 +997,14 @@ */ public void setVerticalTextPosition(int t) { + if (verticalTextPosition == t) + return; + int old = verticalTextPosition; verticalTextPosition = t; - if (old != t) - { - firePropertyChange(VERTICAL_TEXT_POSITION_CHANGED_PROPERTY, old, t); - revalidate(); - repaint(); - } + firePropertyChange(VERTICAL_TEXT_POSITION_CHANGED_PROPERTY, old, t); + revalidate(); + repaint(); } /** @@ -1031,14 +1028,14 @@ */ public void setBorderPainted(boolean b) { + if (borderPainted == b) + return; + boolean old = borderPainted; - borderPainted = b; - if (b != old) - { - firePropertyChange(BORDER_PAINTED_CHANGED_PROPERTY, old, b); - revalidate(); - repaint(); - } + borderPainted = b; + firePropertyChange(BORDER_PAINTED_CHANGED_PROPERTY, old, b); + revalidate(); + repaint(); } /** @@ -1077,10 +1074,7 @@ action.removePropertyChangeListener(actionPropertyChangeListener); actionPropertyChangeListener = null; } - - - } - + } Action old = action; action = a; @@ -1111,14 +1105,14 @@ */ public void setIcon(Icon i) { - if (default_icon != i) - { + if (default_icon == i) + return; + Icon old = default_icon; default_icon = i; firePropertyChange(ICON_CHANGED_PROPERTY, old, i); revalidate(); repaint(); - } } /** @@ -1162,14 +1156,14 @@ */ public void setText(String t) { + if (text == t) + return; + String old = text; text = t; - if (t != old) - { - firePropertyChange(TEXT_CHANGED_PROPERTY, old, t); - revalidate(); - repaint(); - } + firePropertyChange(TEXT_CHANGED_PROPERTY, old, t); + revalidate(); + repaint(); } /** @@ -1179,14 +1173,14 @@ */ public void setIconTextGap(int i) { + if (iconTextGap == i) + return; + int old = iconTextGap; iconTextGap = i; - if (old != i) - { - fireStateChanged(new ChangeEvent(this)); - revalidate(); - repaint(); - } + fireStateChanged(); + revalidate(); + repaint(); } /** @@ -1206,7 +1200,7 @@ * * @return The current "margin" property */ - public Insets getMargin() + public Insets getMargin() { return margin; } @@ -1220,15 +1214,15 @@ */ public void setMargin(Insets m) { + if (margin == m) + return; + Insets old = margin; margin = m; - if (m != old) - { - firePropertyChange(MARGIN_CHANGED_PROPERTY, old, m); - revalidate(); + firePropertyChange(MARGIN_CHANGED_PROPERTY, old, m); + revalidate(); repaint(); } - } /** * Return the button's "pressedIcon" property. The look and feel class @@ -1253,15 +1247,15 @@ */ public void setPressedIcon(Icon pressedIcon) { + if (pressed_icon == pressedIcon) + return; + Icon old = pressed_icon; pressed_icon = pressedIcon; - if (pressed_icon != old) - { - firePropertyChange(PRESSED_ICON_CHANGED_PROPERTY, old, pressed_icon); + firePropertyChange(PRESSED_ICON_CHANGED_PROPERTY, old, pressed_icon); revalidate(); repaint(); } - } /** * Return the button's "disabledIcon" property. The look and feel class @@ -1322,15 +1316,14 @@ */ public void setFocusPainted(boolean p) { + if (focusPainted == p) + return; + boolean old = focusPainted; focusPainted = p; - - if (old != focusPainted) - { - firePropertyChange(FOCUS_PAINTED_CHANGED_PROPERTY, old, p); - revalidate(); - repaint(); - } + firePropertyChange(FOCUS_PAINTED_CHANGED_PROPERTY, old, p); + revalidate(); + repaint(); } /** @@ -1553,7 +1546,7 @@ { public void stateChanged(ChangeEvent e) { - AbstractButton.this.fireStateChanged(e); + AbstractButton.this.fireStateChanged(); AbstractButton.this.repaint(); } }; @@ -1611,13 +1604,13 @@ getModel().setArmed(true); getModel().setPressed(true); try - { + { java.lang.Thread.sleep(pressTime); - } + } catch (java.lang.InterruptedException e) - { + { // probably harmless - } + } getModel().setPressed(false); getModel().setArmed(false); } @@ -1643,22 +1636,20 @@ * true. This icon can be null, in which case * it is synthesized from the button's selected icon. * - * @param disabledSelectedIcon The new disabled selected icon + * @param icon The new disabled selected icon */ - public void setDisabledSelectedIcon(Icon disabledSelectedIcon) + public void setDisabledSelectedIcon(Icon icon) { + if (disabledSelectedIcon == icon) + return; + Icon old = disabledSelectedIcon; - disabledSelectedIcon = disabledSelectedIcon; - if (old != disabledSelectedIcon) - { - firePropertyChange(DISABLED_SELECTED_ICON_CHANGED_PROPERTY, old, - disabledSelectedIcon); - revalidate(); - repaint(); - } + disabledSelectedIcon = icon; + firePropertyChange(DISABLED_SELECTED_ICON_CHANGED_PROPERTY, old, icon); + revalidate(); + repaint(); } - /** * Return the button's rollover icon. The look and feel class should * paint this icon when the "rolloverEnabled" property of the button is @@ -1680,15 +1671,14 @@ */ public void setRolloverIcon(Icon r) { + if (rolloverIcon == r) + return; + Icon old = rolloverIcon; rolloverIcon = r; - if (old != rolloverIcon) - { - firePropertyChange(ROLLOVER_ICON_CHANGED_PROPERTY, old, - rolloverIcon); - revalidate(); - repaint(); - } + firePropertyChange(ROLLOVER_ICON_CHANGED_PROPERTY, old, rolloverIcon); + revalidate(); + repaint(); } /** @@ -1714,18 +1704,16 @@ */ public void setRolloverSelectedIcon(Icon r) { + if (rolloverSelectedIcon == r) + return; + Icon old = rolloverSelectedIcon; rolloverSelectedIcon = r; - if (old != rolloverSelectedIcon) - { - firePropertyChange(ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, old, - rolloverSelectedIcon); - revalidate(); - repaint(); - } + firePropertyChange(ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, old, r); + revalidate(); + repaint(); } - /** * Return the button's selected icon. The look and feel class should * paint this icon when the "selected" property of the button's model is @@ -1751,15 +1739,14 @@ */ public void setSelectedIcon(Icon s) { + if (selectedIcon == s) + return; + Icon old = selectedIcon; selectedIcon = s; - if (old != selectedIcon) - { - firePropertyChange(SELECTED_ICON_CHANGED_PROPERTY, old, - selectedIcon); - revalidate(); - repaint(); - } + firePropertyChange(SELECTED_ICON_CHANGED_PROPERTY, old, s); + revalidate(); + repaint(); } /** @@ -1776,9 +1763,9 @@ Object[] objs = new Object[1]; objs[0] = getText(); return objs; - } + } else - { + { return null; } } @@ -1799,9 +1786,9 @@ */ public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) - { + { return current_icon == img; - } + } /** * Returns the value of the button's "contentAreaFilled" property. This @@ -1813,9 +1800,9 @@ * @return The current value of the "contentAreaFilled" property */ public boolean isContentAreaFilled() - { + { return contentAreaFilled; - } + } /** * Sets the value of the button's "contentAreaFilled" property. This @@ -1827,16 +1814,16 @@ * @param b The new value of the "contentAreaFilled" property */ public void setContentAreaFilled(boolean b) - { + { + if (contentAreaFilled == b) + return; + boolean old = contentAreaFilled; contentAreaFilled = b; - if (b != old) - { - firePropertyChange(CONTENT_AREA_FILLED_CHANGED_PROPERTY, old, b); - revalidate(); - repaint(); - } - } + firePropertyChange(CONTENT_AREA_FILLED_CHANGED_PROPERTY, old, b); + revalidate(); + repaint(); + } /** * Paints the button's border, if the button's "borderPainted" property is @@ -1845,10 +1832,10 @@ * @param g The graphics context used to paint the border */ protected void paintBorder(Graphics g) - { + { if (isBorderPainted()) super.paintBorder(g); - } + } /** * Returns a string, used only for debugging, which identifies or somehow @@ -1861,7 +1848,6 @@ return "AbstractButton"; } - /** * Set the "UI" property of the button, which is a look and feel class * responsible for handling the button's input events and painting it. @@ -1869,9 +1855,9 @@ * @param ui The new "UI" property */ public void setUI(ButtonUI ui) - { + { super.setUI(ui); - } + } /** * Set the "UI" property of the button, which is a look and feel class @@ -1882,7 +1868,7 @@ public ButtonUI getUI() { return (ButtonUI) ui; - } + } /** * Set the "UI" property to a class constructed, via the address@hidden