This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[GUI] Patch: javax.swing - more cleanups
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Tue, 8 Jun 2004 10:46:16 +0200
- Subject: [GUI] Patch: javax.swing - more cleanups
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi list,
I commited the attached patch to java-gui-branch to do more cleanups.
2004-06-08 Michael Koch <konqueror@gmx.de>
* javax/swing/Box.java
(AccessibleBoxFiller): Extends AccessibleAWTComponent.
(AccessibleBoxFiller.serialVersionUID): New member variable.
* javax/swing/DefaultButtonModel.java
(stateMask): Made protected.
(listenerList): Likewise.
(changeEvent): Likewise.
(group): Likewise.
(mnemonic): Likewise.
(actionCommand): Likewise.
(getListeners): New method.
(getActionListeners): New method.
(getItemListeners): New method.
(getChangeListeners): New method.
(fireItemStateChanged): Simplified.
(fireActionPerformed): Simplified.
(fireStateChanged): Simplified.
* javax/swing/JFrame.java
(JFrame): Implements WindowContants.
(HIDE_ON_CLOSE): Removed.
(EXIT_ON_CLOSE): Removed.
(DISPOSE_ON_CLOSE): Removed.
(DO_NOTHING_ON_CLOSE): Removed.
(processWindowEvent): Exit with code 0.
(setDefaultCloseOperation): Do security check before setting value.
* javax/swing/JOptionPane.java
(message): Initialize only in constructor.
* javax/swing/JToolTip.java: Removed unused imports.
* javax/swing/JViewport.java
(serialVersionUID): New member variable.
(SIMPLE_SCROLL_MODE): Made final, fixed value.
(BLIT_SCROLL_MODE): Likewise.
(BACKINGSTORE_SCROLL_MODE): Likewise.
(scrollUnderway): Made protected.
(isViewSizeSet): Likewise.
* javax/swing/ListModel.java: Fixed javadoc.
* javax/swing/Popup.java: Likewise.
* javax/swing/RepaintManager.java
(paintDirtyRegions): Don't use internal classes of
java.util.AbstractMap.
* javax/swing/ScrollPaneConstants.java: Reindented.
* javax/swing/ScrollPaneLayout.java
(viewport): Made protected.
(verticalScrollBar): Made protected, renamed to vsb.
(horizontalScrollBar): Made protected, renamed to hsb.
(rowHeader): Made protected, renamed to rowHead.
(columnHeader): Made protected, renamed to colHead.
(lowerLeft): Made protected.
(lowerRight): Made protected.
(upperLeft): Made protected.
(upperRight): Made protected.
(verticalScrollBarPolicy): Made protected, renamed to vsbPolicy.
(horizontalScrollBarPolicy): Made protected, renamed to hsbPolicy.
- --
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFAxXzYWSOgCCdjSDsRApAsAKCIxZ03C1/Z1es1a+ad0GXh9UyTOQCgnKRv
quMGw6b6kCRnXDyE8MZhWb4=
=XNzB
-----END PGP SIGNATURE-----
Index: javax/swing/Box.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/Box.java,v
retrieving revision 1.3.2.5
diff -u -b -B -r1.3.2.5 Box.java
--- javax/swing/Box.java 7 Jun 2004 12:41:08 -0000 1.3.2.5
+++ javax/swing/Box.java 8 Jun 2004 08:33:40 -0000
@@ -73,8 +73,10 @@
{
private static final long serialVersionUID = -1204263191910183998L;
- protected class AccessibleBoxFiller// extends AccessibleAWTComponent
+ protected class AccessibleBoxFiller extends AccessibleAWTComponent
{
+ private static final long serialVersionUID = 164963348357479321L;
+
protected AccessibleBoxFiller()
{
}
Index: javax/swing/DefaultButtonModel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/DefaultButtonModel.java,v
retrieving revision 1.5.2.1
diff -u -b -B -r1.5.2.1 DefaultButtonModel.java
--- javax/swing/DefaultButtonModel.java 7 Jun 2004 14:00:32 -0000 1.5.2.1
+++ javax/swing/DefaultButtonModel.java 8 Jun 2004 08:33:40 -0000
@@ -102,27 +102,27 @@
/** Represents the "state properties" (armed, enabled, pressed, rollover
and selected) by a bitwise combination of integer constants. */
- int stateMask;
+ protected int stateMask;
/** List of ItemListeners, ChangeListeners, and ActionListeners
registered on this model. */
- EventListenerList listenerList;
+ protected EventListenerList listenerList;
/** The single ChangeEvent this model (re)uses to call its
ChangeListeners. */
- ChangeEvent changeEvent;
+ protected ChangeEvent changeEvent;
/** The group this model belongs to. Only one button in a group may be
selected at any given time. */
- ButtonGroup group;
+ protected ButtonGroup group;
/** The key code (one of {@link java.awt.event.KeyEvent} VK_*) used to
press this button via a keyboard interface. */
- int mnemonic;
+ protected int mnemonic;
/** The string used as the "command" property of any ActionEvent this
model sends. */
- String actionCommand;
+ protected String actionCommand;
public DefaultButtonModel()
{
@@ -144,6 +144,18 @@
}
/**
+ * Returns a specified class of listeners.
+ *
+ * @param listenerType the type of listener to return
+ *
+ * @return array of listeners
+ */
+ public EventListener[] getListeners(Class listenerType)
+ {
+ return listenerList.getListeners(listenerType);
+ }
+
+ /**
* Add an ActionListener to the model. Usually only called to subscribe
* an AbstractButton's listener to the model.
*
@@ -166,6 +178,16 @@
}
/**
+ * Returns all registered <code>ActionListener</code> objects.
+ *
+ * @return array of <code>ActionListener</code> objects
+ */
+ public ActionListener[] getActionListeners()
+ {
+ return (ActionListener[]) listenerList.getListeners(ActionListener.class);
+ }
+
+ /**
* Add an ItemListener to the model. Usually only called to subscribe
* an AbstractButton's listener to the model.
*
@@ -188,6 +210,16 @@
}
/**
+ * Returns all registered <code>ItemListener</code> objects.
+ *
+ * @return array of <code>ItemListener</code> objects
+ */
+ public ItemListener[] getItemListeners()
+ {
+ return (ItemListener[]) listenerList.getListeners(ItemListener.class);
+ }
+
+ /**
* Add a ChangeListener to the model. Usually only called to subscribe
* an AbstractButton's listener to the model.
*
@@ -210,6 +242,16 @@
}
/**
+ * Returns all registered <code>ChangeListener</code> objects.
+ *
+ * @return array of <code>ChangeListener</code> objects
+ */
+ public ChangeListener[] getChangeListeners()
+ {
+ return (ChangeListener[]) listenerList.getListeners(ChangeListener.class);
+ }
+
+ /**
* Inform each ItemListener in the {@link listenerList} that an ItemEvent
* has occurred. This happens in response to any change to the {@link
* stateMask} field.
@@ -218,9 +260,10 @@
*/
public void fireItemStateChanged(ItemEvent e)
{
- EventListener[] ll = listenerList.getListeners(ItemListener.class);
+ ItemListener[] ll = getItemListeners();
+
for (int i = 0; i < ll.length; i++)
- ((ItemListener)ll[i]).itemStateChanged(e);
+ ll[i].itemStateChanged(e);
}
/**
@@ -233,9 +276,10 @@
*/
public void fireActionPerformed(ActionEvent e)
{
- EventListener[] ll = listenerList.getListeners(ActionListener.class);
+ ActionListener[] ll = getActionListeners();
+
for (int i = 0; i < ll.length; i++)
- ((ActionListener)ll[i]).actionPerformed(e);
+ ll[i].actionPerformed(e);
}
/**
@@ -247,9 +291,10 @@
*/
public void fireStateChanged(ChangeEvent e)
{
- EventListener[] ll = listenerList.getListeners(ChangeListener.class);
+ ChangeListener[] ll = getChangeListeners();
+
for (int i = 0; i < ll.length; i++)
- ((ChangeListener)ll[i]).stateChanged(e);
+ ll[i].stateChanged(e);
}
/**
Index: javax/swing/JFrame.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JFrame.java,v
retrieving revision 1.4.2.3
diff -u -b -B -r1.4.2.3 JFrame.java
--- javax/swing/JFrame.java 7 Jun 2004 14:00:33 -0000 1.4.2.3
+++ javax/swing/JFrame.java 8 Jun 2004 08:33:40 -0000
@@ -57,18 +57,13 @@
*
* @author Ronald Veldema (rveldema@cs.vu.nl)
*/
-public class JFrame extends Frame implements RootPaneContainer
+public class JFrame extends Frame implements WindowConstants, RootPaneContainer
{
private static final long serialVersionUID = -3362141868504252139L;
- public final static int HIDE_ON_CLOSE = 0;
- public final static int EXIT_ON_CLOSE = 1;
- public final static int DISPOSE_ON_CLOSE = 2;
- public final static int DO_NOTHING_ON_CLOSE = 3;
-
protected AccessibleContext accessibleContext;
- private int close_action = EXIT_ON_CLOSE;
+ private int close_action = HIDE_ON_CLOSE;
/***************************************************
@@ -214,7 +209,7 @@
{
case EXIT_ON_CLOSE:
{
- System.exit(1);
+ System.exit(0);
break;
}
case DISPOSE_ON_CLOSE:
@@ -243,8 +238,30 @@
}
}
+ /**
+ * Defines what happens when this frame is closed. Can be one off
+ * <code>EXIT_ON_CLOSE</code>,
+ * <code>DISPOSE_ON_CLOSE</code>,
+ * <code>HIDE_ON_CLOSE</code> or
+ * <code>DO_NOTHING_ON_CLOSE</code>.
+ * The default is <code>HIDE_ON_CLOSE</code>.
+ * When <code>EXIT_ON_CLOSE</code> is specified this method calls
+ * <code>SecurityManager.checkExit(0)</code> which might throw a
+ * <code>SecurityException</code>. When the specified operation is
+ * not one of the above a <code>IllegalArgumentException</code> is
+ * thrown.
+ */
+ public void setDefaultCloseOperation(int operation)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null && operation == EXIT_ON_CLOSE)
+ sm.checkExit(0);
+
+ if (operation != EXIT_ON_CLOSE && operation != DISPOSE_ON_CLOSE
+ && operation != HIDE_ON_CLOSE && operation != DO_NOTHING_ON_CLOSE)
+ throw new IllegalArgumentException("operation = " + operation);
- void setDefaultCloseOperation(int operation)
- { close_action = operation; }
+ close_action = operation;
+ }
}
Index: javax/swing/JOptionPane.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JOptionPane.java,v
retrieving revision 1.3.2.2
diff -u -b -B -r1.3.2.2 JOptionPane.java
--- javax/swing/JOptionPane.java 7 Jun 2004 12:41:10 -0000 1.3.2.2
+++ javax/swing/JOptionPane.java 8 Jun 2004 08:33:40 -0000
@@ -207,7 +207,7 @@
protected Object inputValue = UNINITIALIZED_VALUE;
/** The message displayed in the dialog/internal frame. */
- protected Object message = "JOptionPane message";
+ protected Object message;
/** The type of message displayed. */
protected int messageType = PLAIN_MESSAGE;
@@ -239,7 +239,7 @@
*/
public JOptionPane()
{
- this(this.message, PLAIN_MESSAGE, DEFAULT_OPTION, null, null, null);
+ this("JOptionPane message", PLAIN_MESSAGE, DEFAULT_OPTION, null, null, null);
}
/**
Index: javax/swing/JToolTip.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JToolTip.java,v
retrieving revision 1.2.18.1
diff -u -b -B -r1.2.18.1 JToolTip.java
--- javax/swing/JToolTip.java 7 Jun 2004 12:41:11 -0000 1.2.18.1
+++ javax/swing/JToolTip.java 8 Jun 2004 08:33:40 -0000
@@ -39,7 +39,6 @@
package javax.swing;
import javax.accessibility.Accessible;
-import javax.accessibility.AccessibleContext;
public class JToolTip extends JComponent implements Accessible
{
Index: javax/swing/JViewport.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JViewport.java,v
retrieving revision 1.3.2.4
diff -u -b -B -r1.3.2.4 JViewport.java
--- javax/swing/JViewport.java 7 Jun 2004 14:00:35 -0000 1.3.2.4
+++ javax/swing/JViewport.java 8 Jun 2004 08:33:40 -0000
@@ -94,16 +94,18 @@
*/
public class JViewport extends JComponent
{
- public static int BACKINGSTORE_SCROLL_MODE = 1;
- public static int BLIT_SCROLL_MODE = 2;
- public static int SIMPLE_SCROLL_MODE = 3;
+ private static final long serialVersionUID = -6925142919680527970L;
+
+ public static final int SIMPLE_SCROLL_MODE = 0;
+ public static final int BLIT_SCROLL_MODE = 1;
+ public static final int BACKINGSTORE_SCROLL_MODE = 2;
ChangeEvent changeEvent = new ChangeEvent(this);
int scrollMode;
- boolean scrollUnderway;
- boolean isViewSizeSet;
+ protected boolean scrollUnderway;
+ protected boolean isViewSizeSet;
/**
* The width and height of the Viewport's area in terms of view
Index: javax/swing/ListModel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/ListModel.java,v
retrieving revision 1.2.8.1
diff -u -b -B -r1.2.8.1 ListModel.java
--- javax/swing/ListModel.java 26 Feb 2004 00:34:02 -0000 1.2.8.1
+++ javax/swing/ListModel.java 8 Jun 2004 08:33:40 -0000
@@ -42,7 +42,7 @@
* This is an interface to general list-like data, typically used as the
* model object of a {@link JList} component.
*
- * @author Graydon Hoare (graydon&064;redhat.com)
+ * @author Graydon Hoare (graydon@redhat.com)
*/
public interface ListModel
{
Index: javax/swing/Popup.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/Popup.java,v
retrieving revision 1.1
diff -u -b -B -r1.1 Popup.java
--- javax/swing/Popup.java 27 Jun 2003 12:41:52 -0000 1.1
+++ javax/swing/Popup.java 8 Jun 2004 08:33:40 -0000
@@ -163,7 +163,7 @@
/**
- * Displays the popup’s <code>JWindow</code> on the screen.
+ * Displays the popup's <code>JWindow</code> on the screen.
* Nothing happens if it is already visible.
*/
public void show()
@@ -173,7 +173,7 @@
/**
- * Removes the popup’s <code>JWindow</code> from the
+ * Removes the popup's <code>JWindow</code> from the
* screen. Nothing happens if it is currently not visible.
*/
public void hide()
Index: javax/swing/RepaintManager.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/RepaintManager.java,v
retrieving revision 1.2.18.1
diff -u -b -B -r1.2.18.1 RepaintManager.java
--- javax/swing/RepaintManager.java 21 May 2004 23:34:13 -0000 1.2.18.1
+++ javax/swing/RepaintManager.java 8 Jun 2004 08:33:40 -0000
@@ -41,11 +41,11 @@
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Rectangle;
-import java.util.AbstractMap;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import java.util.Vector;
@@ -438,10 +438,10 @@
dirtyComponents.clear();
// step 2: paint those roots
- Iterator i = roots.iterator(AbstractMap.ENTRIES);
+ Iterator i = roots.entrySet().iterator();
while(i.hasNext())
{
- AbstractMap.BasicMapEntry ent = (AbstractMap.BasicMapEntry) i.next();
+ Map.Entry ent = (Map.Entry) i.next();
JRootPane root = (JRootPane) ent.getKey();
Rectangle rect = (Rectangle) ent.getValue();
root.paintImmediately(rect);
Index: javax/swing/ScrollPaneConstants.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/ScrollPaneConstants.java,v
retrieving revision 1.2
diff -u -b -B -r1.2 ScrollPaneConstants.java
--- javax/swing/ScrollPaneConstants.java 12 Oct 2003 13:20:49 -0000 1.2
+++ javax/swing/ScrollPaneConstants.java 8 Jun 2004 08:33:40 -0000
@@ -1,5 +1,5 @@
/* ScrollPaneConstants.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,12 +42,8 @@
* @author Andrew Selkirk
* @version 1.0
*/
-public interface ScrollPaneConstants {
-
- //-------------------------------------------------------------
- // Variables --------------------------------------------------
- //-------------------------------------------------------------
-
+public interface ScrollPaneConstants
+{
/**
* VIEWPORT
*/
@@ -152,6 +148,4 @@
* HORIZONTAL_SCROLLBAR_ALWAYS
*/
int HORIZONTAL_SCROLLBAR_ALWAYS = 32;
-
-
-} // ScrollPaneConstants
+}
Index: javax/swing/ScrollPaneLayout.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/ScrollPaneLayout.java,v
retrieving revision 1.3.18.2
diff -u -b -B -r1.3.18.2 ScrollPaneLayout.java
--- javax/swing/ScrollPaneLayout.java 21 May 2004 23:34:13 -0000 1.3.18.2
+++ javax/swing/ScrollPaneLayout.java 8 Jun 2004 08:33:40 -0000
@@ -1,5 +1,5 @@
/* ScrollPaneLayout.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -63,17 +63,17 @@
}
}
- JViewport viewport;
- JScrollBar verticalScrollBar;
- JScrollBar horizontalScrollBar;
- JViewport rowHeader;
- JViewport columnHeader;
- Component lowerLeft;
- Component lowerRight;
- Component upperLeft;
- Component upperRight;
- int verticalScrollBarPolicy;
- int horizontalScrollBarPolicy;
+ protected JViewport viewport;
+ protected JScrollBar vsb;
+ protected JScrollBar hsb;
+ protected JViewport rowHead;
+ protected JViewport colHead;
+ protected Component lowerLeft;
+ protected Component lowerRight;
+ protected Component upperLeft;
+ protected Component upperRight;
+ protected int vsbPolicy;
+ protected int hsbPolicy;
public ScrollPaneLayout() {