From: <ls...@us...> - 2007-01-31 19:02:54
|
Revision: 3098 http://jnode.svn.sourceforge.net/jnode/?rev=3098&view=rev Author: lsantha Date: 2007-01-31 11:02:43 -0800 (Wed, 31 Jan 2007) Log Message: ----------- Classpath patches. Modified Paths: -------------- trunk/core/src/classpath/java/java/awt/Choice.java trunk/core/src/classpath/java/java/awt/Component.java trunk/core/src/classpath/java/java/awt/Container.java trunk/core/src/classpath/java/java/awt/Frame.java trunk/core/src/classpath/java/java/awt/Label.java trunk/core/src/classpath/java/java/awt/List.java trunk/core/src/classpath/java/java/awt/Menu.java trunk/core/src/classpath/java/java/awt/ScrollPane.java trunk/core/src/classpath/java/java/awt/ScrollPaneAdjustable.java trunk/core/src/classpath/java/java/awt/Scrollbar.java trunk/core/src/classpath/java/java/awt/Window.java Modified: trunk/core/src/classpath/java/java/awt/Choice.java =================================================================== --- trunk/core/src/classpath/java/java/awt/Choice.java 2007-01-28 21:36:49 UTC (rev 3097) +++ trunk/core/src/classpath/java/java/awt/Choice.java 2007-01-31 19:02:43 UTC (rev 3098) @@ -1,5 +1,5 @@ /* Choice.java -- Java choice button widget. - Copyright (C) 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002, 2004, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -58,35 +58,31 @@ public class Choice extends Component implements ItemSelectable, Serializable, Accessible { - -/* - * Static Variables + /** + * The number used to generate the name returned by getName. */ + private static transient long next_choice_number; -// Serialization constant -private static final long serialVersionUID = -4075310674757313071L; + // Serialization constant + private static final long serialVersionUID = -4075310674757313071L; -/*************************************************************************/ - -/* - * Instance Variables - */ - -/** + /** * @serial A list of items for the choice box, which can be <code>null</code>. * This is package-private to avoid an accessor method. */ -Vector pItems = new Vector(); + Vector pItems = new Vector(); -/** + /** * @serial The index of the selected item in the choice box. */ -private int selectedIndex = -1; + private int selectedIndex = -1; -// Listener chain -private ItemListener item_listeners; + /** + * ItemListener chain + */ + private ItemListener item_listeners; -/** + /** * This class provides accessibility support for the * combo box. * @@ -181,19 +177,12 @@ if (i < 0 || i >= pItems.size()) return false; - Choice.this.processItemEvent(new ItemEvent(Choice.this, - ItemEvent.ITEM_STATE_CHANGED, - this, ItemEvent.SELECTED)); + Choice.this.select( i ); + return true; } } -/*************************************************************************/ - -/* - * Constructors - */ - /** * Initializes a new instance of <code>Choice</code>. * @@ -206,56 +195,41 @@ throw new HeadlessException (); } -/*************************************************************************/ - -/* - * Instance Methods - */ - -/** + /** * Returns the number of items in the list. * * @return The number of items in the list. */ -public int -getItemCount() -{ + public int getItemCount() + { return countItems (); -} + } -/*************************************************************************/ - -/** + /** * Returns the number of items in the list. * * @return The number of items in the list. * * @deprecated This method is deprecated in favor of <code>getItemCount</code>. */ -public int -countItems() -{ - return(pItems.size()); -} + public int countItems() + { + return pItems.size(); + } -/*************************************************************************/ - -/** + /** * Returns the item at the specified index in the list. * * @param index The index into the list to return the item from. * * @exception ArrayIndexOutOfBoundsException If the index is invalid. */ -public String -getItem(int index) -{ - return((String)pItems.elementAt(index)); -} + public String getItem(int index) + { + return (String)pItems.elementAt(index); + } -/*************************************************************************/ - -/** + /** * Adds the specified item to this choice box. * * @param item The item to add. @@ -264,45 +238,36 @@ * * @since 1.1 */ -public synchronized void -add(String item) -{ + public synchronized void add(String item) + { if (item == null) throw new NullPointerException ("item must be non-null"); pItems.addElement(item); - int i = pItems.size () - 1; if (peer != null) - { - ChoicePeer cp = (ChoicePeer) peer; - cp.add (item, i); - } - else if (selectedIndex == -1) - select(0); -} + ((ChoicePeer) peer).add(item, getItemCount() - 1); -/*************************************************************************/ + if (selectedIndex == -1) + select( 0 ); + } -/** + /** * Adds the specified item to this choice box. * - * This method is oboslete since Java 2 platform 1.1. Please use @see add - * instead. + * This method is oboslete since Java 2 platform 1.1. Please use + * {@link #add(String)} instead. * * @param item The item to add. * * @exception NullPointerException If the item's value is equal to null */ -public synchronized void -addItem(String item) -{ + public synchronized void addItem(String item) + { add(item); -} + } -/*************************************************************************/ - -/** Inserts an item into this Choice. Existing items are shifted + /** Inserts an item into this Choice. Existing items are shifted * upwards. If the new item is the only item, then it is selected. * If the currently selected item is shifted, then the first item is * selected. If the currently selected item is not shifted, then it @@ -313,9 +278,8 @@ * * @exception IllegalArgumentException If index is less than 0 */ -public synchronized void -insert(String item, int index) -{ + public synchronized void insert(String item, int index) + { if (index < 0) throw new IllegalArgumentException ("index may not be less then 0"); @@ -325,75 +289,61 @@ pItems.insertElementAt(item, index); if (peer != null) - { - ChoicePeer cp = (ChoicePeer) peer; - cp.add (item, index); - } - else if (selectedIndex == -1 || selectedIndex >= index) + ((ChoicePeer) peer).add (item, index); + + if (selectedIndex == -1 || selectedIndex >= index) select(0); -} + } -/*************************************************************************/ - -/** + /** * Removes the specified item from the choice box. * * @param item The item to remove. * * @exception IllegalArgumentException If the specified item doesn't exist. */ -public synchronized void -remove(String item) -{ + public synchronized void remove(String item) + { int index = pItems.indexOf(item); if (index == -1) throw new IllegalArgumentException ("item \"" + item + "\" not found in Choice"); remove(index); -} + } -/*************************************************************************/ - -/** + /** * Removes the item at the specified index from the choice box. * * @param index The index of the item to remove. * * @exception IndexOutOfBoundsException If the index is not valid. */ -public synchronized void -remove(int index) -{ - if ((index < 0) || (index > getItemCount())) - throw new IllegalArgumentException("Bad index: " + index); - + public synchronized void remove(int index) + { pItems.removeElementAt(index); if (peer != null) - { - ChoicePeer cp = (ChoicePeer) peer; - cp.remove (index); - } - else - { - if (getItemCount() == 0) + ((ChoicePeer) peer).remove( index ); + + if( getItemCount() == 0 ) selectedIndex = -1; - else if (index == selectedIndex) - select(0); - } + else + { + if( selectedIndex > index ) + selectedIndex--; + else if( selectedIndex == index ) + selectedIndex = 0; - if (selectedIndex > index) - --selectedIndex; -} + if( peer != null ) + ((ChoicePeer)peer).select( selectedIndex ); + } + } -/*************************************************************************/ - -/** + /** * Removes all of the objects from this choice box. */ -public synchronized void -removeAll() -{ + public synchronized void removeAll() + { if (getItemCount() <= 0) return; @@ -406,197 +356,159 @@ } selectedIndex = -1; -} + } -/*************************************************************************/ - -/** + /** * Returns the currently selected item, or null if no item is * selected. * * @return The currently selected item. */ -public synchronized String -getSelectedItem() -{ + public synchronized String getSelectedItem() + { return (selectedIndex == -1 ? null : ((String)pItems.elementAt(selectedIndex))); -} + } -/*************************************************************************/ - -/** + /** * Returns an array with one row containing the selected item. * * @return An array containing the selected item. */ -public synchronized Object[] -getSelectedObjects() -{ + public synchronized Object[] getSelectedObjects() + { if (selectedIndex == -1) return null; Object[] objs = new Object[1]; objs[0] = pItems.elementAt(selectedIndex); - return(objs); -} + return objs; + } -/*************************************************************************/ - -/** + /** * Returns the index of the selected item. * * @return The index of the selected item. */ -public int -getSelectedIndex() -{ - return(selectedIndex); -} + public int getSelectedIndex() + { + return selectedIndex; + } -/*************************************************************************/ - -/** + /** * Forces the item at the specified index to be selected. * * @param index The index of the row to make selected. * * @exception IllegalArgumentException If the specified index is invalid. */ -public synchronized void -select(int index) -{ + public synchronized void select(int index) + { if ((index < 0) || (index >= getItemCount())) throw new IllegalArgumentException("Bad index: " + index); - if (pItems.size() > 0) { + if( selectedIndex == index ) + return; + selectedIndex = index; - ChoicePeer cp = (ChoicePeer) peer; - if (cp != null) { - cp.select(index); + if( peer != null ) + ((ChoicePeer)peer).select( index ); } - } -} -/*************************************************************************/ - -/** + /** * Forces the named item to be selected. * * @param item The item to be selected. * * @exception IllegalArgumentException If the specified item does not exist. */ -public synchronized void -select(String item) -{ + public synchronized void select(String item) + { int index = pItems.indexOf(item); - if (index >= 0) - select(index); -} + if( index >= 0 ) + select( index ); + } -/*************************************************************************/ - -/** + /** * Creates the native peer for this object. */ -public void -addNotify() -{ + public void addNotify() + { if (peer == null) peer = getToolkit ().createChoice (this); super.addNotify (); -} + } -/*************************************************************************/ - -/** + /** * Adds the specified listener to the list of registered listeners for * this object. * * @param listener The listener to add. */ -public synchronized void -addItemListener(ItemListener listener) -{ + public synchronized void addItemListener(ItemListener listener) + { item_listeners = AWTEventMulticaster.add(item_listeners, listener); -} + } -/*************************************************************************/ - -/** + /** * Removes the specified listener from the list of registered listeners for * this object. * * @param listener The listener to remove. */ -public synchronized void -removeItemListener(ItemListener listener) -{ + public synchronized void removeItemListener(ItemListener listener) + { item_listeners = AWTEventMulticaster.remove(item_listeners, listener); -} + } -/*************************************************************************/ - -/** + /** * Processes this event by invoking <code>processItemEvent()</code> if the * event is an instance of <code>ItemEvent</code>, otherwise the event * is passed to the superclass. * * @param event The event to process. */ -protected void -processEvent(AWTEvent event) -{ + protected void processEvent(AWTEvent event) + { if (event instanceof ItemEvent) processItemEvent((ItemEvent)event); else super.processEvent(event); -} + } -void -dispatchEventImpl(AWTEvent e) -{ - if (e.id <= ItemEvent.ITEM_LAST - && e.id >= ItemEvent.ITEM_FIRST - && (item_listeners != null || (eventMask & AWTEvent.ITEM_EVENT_MASK) != 0)) - processEvent(e); - else + void dispatchEventImpl(AWTEvent e) + { super.dispatchEventImpl(e); -} -/*************************************************************************/ + if( e.id <= ItemEvent.ITEM_LAST && e.id >= ItemEvent.ITEM_FIRST && + ( item_listeners != null || + ( eventMask & AWTEvent.ITEM_EVENT_MASK ) != 0 ) ) + processEvent(e); + } -/** + /** * Processes item event by dispatching to any registered listeners. * * @param event The event to process. */ -protected void -processItemEvent(ItemEvent event) -{ + protected void processItemEvent(ItemEvent event) + { int index = pItems.indexOf((String) event.getItem()); - // Don't call back into the peers when selecting index here - if (event.getStateChange() == ItemEvent.SELECTED) - this.selectedIndex = index; if (item_listeners != null) item_listeners.itemStateChanged(event); -} + } -/*************************************************************************/ - -/** + /** * Returns a debugging string for this object. * * @return A debugging string for this object. */ -protected String -paramString() -{ - return ("selectedIndex=" + selectedIndex + "," + super.paramString()); -} + protected String paramString() + { + return "selectedIndex=" + selectedIndex + "," + super.paramString(); + } /** * Returns an array of all the objects currently registered as FooListeners @@ -608,7 +520,7 @@ * * @since 1.3 */ - public EventListener[] getListeners (Class listenerType) + public <T extends EventListener> T[] getListeners (Class<T> listenerType) { if (listenerType == ItemListener.class) return AWTEventMulticaster.getListeners (item_listeners, listenerType); @@ -639,4 +551,19 @@ accessibleContext = new AccessibleAWTChoice(); return accessibleContext; } -} // class Choice + + /** + * Generate a unique name for this <code>Choice</code>. + * + * @return A unique name for this <code>Choice</code>. + */ + String generateName() + { + return "choice" + getUniqueLong(); + } + + private static synchronized long getUniqueLong() + { + return next_choice_number++; + } +} // class Choice Modified: trunk/core/src/classpath/java/java/awt/Component.java =================================================================== --- trunk/core/src/classpath/java/java/awt/Component.java 2007-01-28 21:36:49 UTC (rev 3097) +++ trunk/core/src/classpath/java/java/awt/Component.java 2007-01-31 19:02:43 UTC (rev 3098) @@ -39,6 +39,10 @@ package java.awt; +//import gnu.java.awt.dnd.peer.gtk.GtkDropTargetContextPeer; + +import gnu.java.awt.ComponentReshapeEvent; + import java.awt.dnd.DropTarget; import java.awt.event.ActionEvent; import java.awt.event.AdjustmentEvent; @@ -70,6 +74,7 @@ import java.awt.image.VolatileImage; import java.awt.peer.ComponentPeer; import java.awt.peer.LightweightPeer; +import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.io.IOException; @@ -213,6 +218,12 @@ */ static final Object treeLock = new String("AWT_TREE_LOCK"); + /** + * The default maximum size. + */ + private static final Dimension DEFAULT_MAX_SIZE + = new Dimension(Short.MAX_VALUE, Short.MAX_VALUE); + // Serialized fields from the serialization spec. /** @@ -427,6 +438,24 @@ Dimension minSize; /** + * Flag indicating whether the minimum size for the component has been set + * by a call to {@link #setMinimumSize(Dimension)} with a non-null value. + */ + boolean minSizeSet; + + /** + * The maximum size for the component. + * @see #setMaximumSize(Dimension) + */ + Dimension maxSize; + + /** + * A flag indicating whether the maximum size for the component has been set + * by a call to {@link #setMaximumSize(Dimension)} with a non-null value. + */ + boolean maxSizeSet; + + /** * Cached information on the preferred size. Should have been transient. * * @serial ignore @@ -569,6 +598,17 @@ transient BufferStrategy bufferStrategy; /** + * The number of hierarchy listeners of this container plus all of its + * children. This is needed for efficient handling of HierarchyEvents. + * These must be propagated to all child components with HierarchyListeners + * attached. To avoid traversal of the whole subtree, we keep track of + * the number of HierarchyListeners here and only walk the paths that + * actually have listeners. + */ + int numHierarchyListeners; + int numHierarchyBoundsListeners; + + /** * true if requestFocus was called on this component when its * top-level ancestor was not focusable. */ @@ -613,16 +653,19 @@ } /** - * Sets the name of this component to the specified name. + * Sets the name of this component to the specified name (this is a bound + * property with the name 'name'). * - * @param name the new name of this component + * @param name the new name (<code>null</code> permitted). * @see #getName() * @since 1.1 */ public void setName(String name) { nameExplicitlySet = true; + String old = this.name; this.name = name; + firePropertyChange("name", old, name); } /** @@ -659,6 +702,9 @@ public void setDropTarget(DropTarget dt) { this.dropTarget = dt; + + if (peer != null) + dropTarget.addNotify(peer); } /** @@ -1590,6 +1636,7 @@ * * @return the component's preferred size * @see #getMinimumSize() + * @see #setPreferredSize(Dimension) * @see LayoutManager */ public Dimension getPreferredSize() @@ -1600,7 +1647,7 @@ /** * Sets the preferred size that will be returned by * {@link #getPreferredSize()} always, and sends a - * {@link java.beans.PropertyChangeEvent} (with the property name 'preferredSize') to + * {@link PropertyChangeEvent} (with the property name 'preferredSize') to * all registered listeners. * * @param size the preferred size (<code>null</code> permitted). @@ -1662,6 +1709,39 @@ } /** + * Sets the minimum size that will be returned by {@link #getMinimumSize()} + * always, and sends a {@link PropertyChangeEvent} (with the property name + * 'minimumSize') to all registered listeners. + * + * @param size the minimum size (<code>null</code> permitted). + * + * @since 1.5 + * + * @see #getMinimumSize() + */ + public void setMinimumSize(Dimension size) + { + Dimension old = minSizeSet ? minSize : null; + minSize = size; + minSizeSet = (size != null); + firePropertyChange("minimumSize", old, size); + } + + /** + * Returns <code>true</code> if the current minimum size is not + * <code>null</code> and was set by a call to + * {@link #setMinimumSize(Dimension)}, otherwise returns <code>false</code>. + * + * @return A boolean. + * + * @since 1.5 + */ + public boolean isMinimumSizeSet() + { + return minSizeSet; + } + + /** * Returns the component's minimum size. * * @return the component's minimum size @@ -1676,10 +1756,38 @@ } /** + * The actual calculation is pulled out of minimumSize() so that + * we can call it from Container.preferredSize() and + * Component.preferredSizeImpl and avoid creating a + * new intermediate Dimension object. + * + * @return the minimum size of the component + */ + Dimension minimumSizeImpl() + { + Dimension size = minSize; + if (size == null || !(valid || minSizeSet)) + { + // We need to lock here, because the calculation depends on the + // component structure not changing. + synchronized (getTreeLock()) + { + ComponentPeer p = peer; + if (p != null) + size = peer.minimumSize(); + else + size = size(); + } + } + return size; + } + + /** * Returns the component's maximum size. * * @return the component's maximum size * @see #getMinimumSize() + * @see #setMaximumSize(Dimension) * @see #getPreferredSize() * @see LayoutManager */ @@ -1689,6 +1797,56 @@ } /** + * This is pulled out from getMaximumSize(), so that we can access it + * from Container.getMaximumSize() without creating an additional + * intermediate Dimension object. + * + * @return the maximum size of the component + */ + Dimension maximumSizeImpl() + { + Dimension size; + if (maxSizeSet) + size = maxSize; + else + size = DEFAULT_MAX_SIZE; + return size; + } + + /** + * Sets the maximum size that will be returned by {@link #getMaximumSize()} + * always, and sends a {@link PropertyChangeEvent} (with the property name + * 'maximumSize') to all registered listeners. + * + * @param size the maximum size (<code>null</code> permitted). + * + * @since 1.5 + * + * @see #getMaximumSize() + */ + public void setMaximumSize(Dimension size) + { + Dimension old = maxSizeSet ? maxSize : null; + maxSize = size; + maxSizeSet = (size != null); + firePropertyChange("maximumSize", old, size); + } + + /** + * Returns <code>true</code> if the current maximum size is not + * <code>null</code> and was set by a call to + * {@link #setMaximumSize(Dimension)}, otherwise returns <code>false</code>. + * + * @return A boolean. + * + * @since 1.5 + */ + public boolean isMaximumSizeSet() + { + return maxSizeSet; + } + + /** * Returns the preferred horizontal alignment of this component. The value * returned will be between {@link #LEFT_ALIGNMENT} and * {@link #RIGHT_ALIGNMENT}, inclusive. @@ -1873,11 +2031,9 @@ } /** - * Updates this component. This is called in response to - * <code>repaint</code>. This method fills the component with the - * background color, then sets the foreground color of the specified - * graphics context to the foreground color of this component and calls - * the <code>paint()</code> method. The coordinates of the graphics are + * Updates this component. This is called for heavyweight components in + * response to {@link #repaint()}. The default implementation simply forwards + * to {@link #paint(Graphics)}. The coordinates of the graphics are * relative to this component. Subclasses should call either * <code>super.update(g)</code> or <code>paint(g)</code>. * @@ -1885,11 +2041,6 @@ * * @see #paint(Graphics) * @see #repaint() - * - * @specnote In contrast to what the spec says, tests show that the exact - * behaviour is to clear the background on lightweight and - * top-level components only. Heavyweight components are not - * affected by this method and only call paint(). */ public void update(Graphics g) { @@ -2004,10 +2155,7 @@ } /** - * Prints this component, including all sub-components. This method is - * provided so that printing can be done in a different manner from - * painting. However, the implementation in this class simply calls the - * <code>paintAll()</code> method. + * Prints this component, including all sub-components. * * @param g the graphics context of the print device * @@ -2365,6 +2513,17 @@ } /** + * By default, no old mouse events should be ignored. + * This can be overridden by subclasses. + * + * @return false, no mouse events are ignored. + */ + static boolean ignoreOldMouseEvents() + { + return false; + } + + /** * AWT 1.0 event handler. * * This method simply calls handleEvent and returns the result. @@ -2581,6 +2740,40 @@ } /** + * Fires a HierarchyEvent or HierarchyChangeEvent on this component. + * + * @param id the event id + * @param changed the changed component + * @param parent the parent + * @param flags the event flags + */ + void fireHierarchyEvent(int id, Component changed, Container parent, + long flags) + { + boolean enabled = false; + switch (id) + { + case HierarchyEvent.HIERARCHY_CHANGED: + enabled = hierarchyListener != null + || (eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0; + break; + case HierarchyEvent.ANCESTOR_MOVED: + case HierarchyEvent.ANCESTOR_RESIZED: + enabled = hierarchyBoundsListener != null + || (eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0; + break; + default: + assert false : "Should not reach here"; + } + if (enabled) + { + HierarchyEvent ev = new HierarchyEvent(this, id, changed, parent, + flags); + dispatchEvent(ev); + } + } + + /** * Adds the specified listener to this component. This is harmless if the * listener is null, but if the listener has already been registered, it * will now be registered twice. @@ -3636,7 +3829,8 @@ * @see KeyboardFocusManager#UP_CYCLE_TRAVERSAL_KEYS * @since 1.4 */ - public void setFocusTraversalKeys(int id, Set keystrokes) + public void setFocusTraversalKeys(int id, + Set<? extends AWTKeyStroke> keystrokes) { if (keystrokes == null) { @@ -3728,14 +3922,14 @@ * * @since 1.4 */ - public Set getFocusTraversalKeys (int id) + public Set<AWTKeyStroke> getFocusTraversalKeys (int id) { if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS && id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS && id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS) throw new IllegalArgumentException(); - Set s = null; + Set<AWTKeyStroke> s = null; if (focusTraversalKeys != null) s = focusTraversalKeys[id]; @@ -4740,8 +4934,7 @@ * {@link #applyComponentOrientation(ComponentOrientation)} affects the * entire hierarchy. * - * @param o the new orientation - * @throws NullPointerException if o is null + * @param o the new orientation (<code>null</code> is accepted) * @see #getComponentOrientation() */ public void setComponentOrientation(ComponentOrientation o) @@ -4756,7 +4949,7 @@ /** * Determines the text layout orientation used by this component. * - * @return the component orientation + * @return the component orientation (this can be <code>null</code>) * @see #setComponentOrientation(ComponentOrientation) */ public ComponentOrientation getComponentOrientation() @@ -5046,7 +5239,7 @@ oldKey = Event.UP; break; default: - oldKey = (int) ((KeyEvent) e).getKeyChar(); + oldKey = ((KeyEvent) e).getKeyChar(); } translated = new Event (target, when, oldID, @@ -5089,11 +5282,10 @@ * * @param e the event to dispatch */ - void dispatchEventImpl(AWTEvent e) { - // This boolean tells us not to process focus events when the focus - // opposite component is the same as the focus component. + // Update the component's knowledge about the size. + // Important: Please look at the big comment in ComponentReshapeEvent boolean ignoreFocus = (e instanceof FocusEvent && ((FocusEvent)e).getComponent() == ((FocusEvent)e).getOppositeComponent()); @@ -5385,7 +5577,7 @@ */ public void componentHidden(ComponentEvent event) { - if (!isShowing()) + if (isShowing()) peer.hide(); } } Modified: trunk/core/src/classpath/java/java/awt/Container.java =================================================================== --- trunk/core/src/classpath/java/java/awt/Container.java 2007-01-28 21:36:49 UTC (rev 3097) +++ trunk/core/src/classpath/java/java/awt/Container.java 2007-01-31 19:02:43 UTC (rev 3098) @@ -42,7 +42,9 @@ import java.awt.event.ComponentListener; import java.awt.event.ContainerEvent; import java.awt.event.ContainerListener; +import java.awt.event.HierarchyEvent; import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; import java.awt.peer.ComponentPeer; import java.awt.peer.ContainerPeer; import java.awt.peer.LightweightPeer; @@ -68,10 +70,11 @@ * * @author original author unknown * @author Eric Blake (eb...@em...) + * @author Andrew John Hughes (gnu...@me...) * * @since 1.0 * - * @status still missing 1.4 support + * @status still missing 1.4 support, some generics from 1.5 */ public class Container extends Component { @@ -97,6 +100,13 @@ */ boolean focusCycleRoot; + /** + * Indicates if this container provides a focus traversal policy. + * + * @since 1.5 + */ + private boolean focusTraversalPolicyProvider; + int containerSerializedDataVersion; /* Anything else is non-serializable, and should be declared "transient". */ @@ -927,10 +937,10 @@ * * @since 1.3 */ - public EventListener[] getListeners(Class listenerType) + public <T extends EventListener> T[] getListeners(Class<T> listenerType) { if (listenerType == ContainerListener.class) - return getContainerListeners(); + return (T[]) getContainerListeners(); return super.getListeners(listenerType); } @@ -1549,6 +1559,42 @@ } /** + * Set to <code>true</code> if this container provides a focus traversal + * policy, <code>false</code> when the root container's focus + * traversal policy should be used. + * + * @return <code>true</code> if this container provides a focus traversal + * policy, <code>false</code> when the root container's focus + * traversal policy should be used + * + * @see #setFocusTraversalPolicyProvider(boolean) + * + * @since 1.5 + */ + public final boolean isFocusTraversalPolicyProvider() + { + return focusTraversalPolicyProvider; + } + + /** + * Set to <code>true</code> if this container provides a focus traversal + * policy, <code>false</code> when the root container's focus + * traversal policy should be used. + * + * @param b <code>true</code> if this container provides a focus traversal + * policy, <code>false</code> when the root container's focus + * traversal policy should be used + * + * @see #isFocusTraversalPolicyProvider() + * + * @since 1.5 + */ + public final void setFocusTraversalPolicyProvider(boolean b) + { + focusTraversalPolicyProvider = b; + } + + /** * Check whether this Container is a focus cycle root. * * @return true if this is a focus cycle root, false otherwise @@ -1850,6 +1896,48 @@ } } + /** + * Fires hierarchy events to the children of this container and this + * container itself. This overrides {@link Component#fireHierarchyEvent} + * in order to forward this event to all children. + */ + void fireHierarchyEvent(int id, Component changed, Container parent, + long flags) + { + // Only propagate event if there is actually a listener waiting for it. + if ((id == HierarchyEvent.HIERARCHY_CHANGED && numHierarchyListeners > 0) + || ((id == HierarchyEvent.ANCESTOR_MOVED + || id == HierarchyEvent.ANCESTOR_RESIZED) + && numHierarchyBoundsListeners > 0)) + { + for (int i = 0; i < ncomponents; i++) + component[i].fireHierarchyEvent(id, changed, parent, flags); + super.fireHierarchyEvent(id, changed, parent, flags); + } + } + + /** + * Adjusts the number of hierarchy listeners of this container and all of + * its parents. This is called by the add/remove listener methods and + * structure changing methods in Container. + * + * @param type the type, either {@link AWTEvent#HIERARCHY_BOUNDS_EVENT_MASK} + * or {@link AWTEvent#HIERARCHY_EVENT_MASK} + * @param delta the number of listeners added or removed + */ + void updateHierarchyListenerCount(long type, int delta) + { + if (type == AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) + numHierarchyBoundsListeners += delta; + else if (type == AWTEvent.HIERARCHY_EVENT_MASK) + numHierarchyListeners += delta; + else + assert false : "Should not reach here"; + + if (parent != null) + parent.updateHierarchyListenerCount(type, delta); + } + private void addNotifyContainerChildren() { synchronized (getTreeLock ()) Modified: trunk/core/src/classpath/java/java/awt/Frame.java =================================================================== --- trunk/core/src/classpath/java/java/awt/Frame.java 2007-01-28 21:36:49 UTC (rev 3097) +++ trunk/core/src/classpath/java/java/awt/Frame.java 2007-01-31 19:02:43 UTC (rev 3098) @@ -340,12 +340,15 @@ parent.remove(menuBar); menuBar.setParent(this); - if (peer != null) + // Create local copy for thread safety. + FramePeer p = (FramePeer) peer; + if (p != null) { if (menuBar != null) menuBar.addNotify(); - invalidateTree(); - ((FramePeer) peer).setMenuBar(menuBar); + if (valid) + invalidate(); + p.setMenuBar(menuBar); } } } @@ -485,8 +488,11 @@ private static void noteFrame(Frame f) { + synchronized (weakFrames) + { weakFrames.add(new WeakReference(f)); } + } public static Frame[] getFrames() { @@ -533,8 +539,7 @@ public int getState() { - // FIXME: State might have changed in the peer... Must check. - return (state & ICONIFIED) != 0 ? ICONIFIED : NORMAL; + return (getExtendedState() & ICONIFIED) != 0 ? ICONIFIED : NORMAL; } /** @@ -542,14 +547,23 @@ */ public void setExtendedState(int state) { + if (getToolkit().isFrameStateSupported(state)) + { this.state = state; + FramePeer p = (FramePeer) peer; + if (p != null) + p.setState(state); } + } /** * @since 1.4 */ public int getExtendedState() { + FramePeer p = (FramePeer) peer; + if (p != null) + state = p.getState(); return state; } Modified: trunk/core/src/classpath/java/java/awt/Label.java =================================================================== --- trunk/core/src/classpath/java/java/awt/Label.java 2007-01-28 21:36:49 UTC (rev 3097) +++ trunk/core/src/classpath/java/java/awt/Label.java 2007-01-31 19:02:43 UTC (rev 3098) @@ -1,5 +1,6 @@ /* Label.java -- Java label widget - Copyright (C) 1999, 2000, 2002, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2002, 2004, 2005, 2006, Free Software + Foundation, Inc. This file is part of GNU Classpath. @@ -55,66 +56,47 @@ public class Label extends Component implements Accessible { -/* - * Static Variables - */ - -/** + /** * Alignment constant aligning the text to the left of its window. */ -public static final int LEFT = 0; + public static final int LEFT = 0; -/** + /** * Alignment constant aligning the text in the center of its window. */ -public static final int CENTER = 1; + public static final int CENTER = 1; -/** + /** * Alignment constant aligning the text to the right of its window. */ -public static final int RIGHT = 2; + public static final int RIGHT = 2; -// Serialization version constant: -private static final long serialVersionUID = 3094126758329070636L; + // Serialization version constant: + private static final long serialVersionUID = 3094126758329070636L; -/*************************************************************************/ - -/* - * Instance Variables - */ - -/** + /** * @serial Indicates the alignment of the text within this label's window. * This is one of the constants in this class. The default value is * <code>LEFT</code>. */ -private int alignment; + private int alignment; -/** + /** * @serial The text displayed in the label */ -private String text; + private String text; -/*************************************************************************/ - -/* - * Constructors - */ - -/** + /** * Initializes a new instance of <code>Label</code> with no text. * * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. */ -public -Label() -{ + public Label() + { this("", LEFT); -} + } -/*************************************************************************/ - -/** + /** * Initializes a new instance of <code>Label</code> with the specified * text that is aligned to the left. * @@ -122,15 +104,12 @@ * * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. */ -public -Label(String text) -{ + public Label(String text) + { this(text, LEFT); -} + } -/*************************************************************************/ - -/** + /** * Initializes a new instance of <code>Label</code> with the specified * text and alignment. * @@ -141,80 +120,63 @@ * * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. */ -public -Label(String text, int alignment) -{ - setAlignment (alignment); - setText (text); + public Label(String text, int alignment) + { + setAlignment(alignment); + setText(text); if (GraphicsEnvironment.isHeadless()) - throw new HeadlessException (); -} + throw new HeadlessException(); + } -/*************************************************************************/ - -/* - * Instance Variables - */ - -/** + /** * Returns the constant indicating the alignment of the text in this * label. The value returned will be one of the alignment constants * from this class. * * @return The alignment of the text in the label. */ -public int -getAlignment() -{ + public int getAlignment() + { return(alignment); -} + } -/*************************************************************************/ - -/** + /** * Sets the text alignment of this label to the specified value. * * @param alignment The desired alignment for the text in this label, * which must be one of <code>LEFT</code>, <code>CENTER</code>, or * <code>RIGHT</code>. */ -public synchronized void -setAlignment(int alignment) -{ + public synchronized void setAlignment(int alignment) + { if (alignment != CENTER && alignment != LEFT && alignment != RIGHT) - throw new IllegalArgumentException ("invalid alignment: " + alignment); + throw new IllegalArgumentException("invalid alignment: " + alignment); this.alignment = alignment; if (peer != null) { LabelPeer lp = (LabelPeer) peer; - lp.setAlignment (alignment); + lp.setAlignment(alignment); + } } -} -/*************************************************************************/ - -/** + /** * Returns the text displayed in this label. * * @return The text for this label. */ -public String -getText() -{ - return(text); -} + public String getText() + { + return text; + } -/*************************************************************************/ - -/** + /** * Sets the text in this label to the specified value. * * @param text The new text for this label. */ -public synchronized void -setText(String text) -{ + public synchronized void setText(String text) + { if ((this.text == null && text != null) || (this.text != null && ! this.text.equals(text))) { @@ -223,47 +185,41 @@ if (peer != null) { LabelPeer lp = (LabelPeer) peer; - lp.setText (text); + lp.setText(text); } invalidate(); } -} + } -/*************************************************************************/ - -/** + /** * Notifies this label that it has been added to a container, causing * the peer to be created. This method is called internally by the AWT * system. */ -public void -addNotify() -{ + public void addNotify() + { if (peer == null) - peer = getToolkit ().createLabel (this); - super.addNotify (); -} + peer = getToolkit().createLabel(this); + super.addNotify(); + } -/*************************************************************************/ - -/** + /** * Returns a parameter string useful for debugging. * * @return A debugging string. */ -protected String -paramString() -{ + protected String paramString() + { return ("text=" + getText() + ",alignment=" + getAlignment() + "," + super.paramString()); -} + } -/** + /** * This class provides accessibility support for the label. */ -protected class AccessibleAWTLabel + protected class AccessibleAWTLabel extends AccessibleAWTComponent -{ + { /** * For compatability with Sun's JDK 1.4.2 rev. 5 */ @@ -299,21 +255,41 @@ return AccessibleRole.LABEL; } -} + } -/** + /** * Gets the AccessibleContext associated with this <code>Label</code>. * The context is created, if necessary. * * @return the associated context */ -public AccessibleContext getAccessibleContext() -{ + public AccessibleContext getAccessibleContext() + { /* Create the context if this is the first request */ if (accessibleContext == null) accessibleContext = new AccessibleAWTLabel(); return accessibleContext; -} + } -} // class Label + /** + * Generate a unique name for this button. + * + * @return A unique name for this button. + */ + String generateName() + { + return "label" + getUniqueLong(); + } + /** + * The number used to generate the name returned by getName. + */ + private static transient long nextLabelNumber; + + private static synchronized long getUniqueLong() + { + return nextLabelNumber++; + } + +} + Modified: trunk/core/src/classpath/java/java/awt/List.java =================================================================== --- trunk/core/src/classpath/java/java/awt/List.java 2007-01-28 21:36:49 UTC (rev 3097) +++ trunk/core/src/classpath/java/java/awt/List.java 2007-01-31 19:02:43 UTC (rev 3098) @@ -1,5 +1,5 @@ /* List.java -- A listbox widget - Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2004, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -62,77 +62,63 @@ implements ItemSelectable, Accessible { -/* - * Static Variables + /** + * The number used to generate the name returned by getName. */ + private static transient long next_list_number; -// Serialization constant -private static final long serialVersionUID = -3304312411574666869L; + // Serialization constant + private static final long serialVersionUID = -3304312411574666869L; -/*************************************************************************/ + // FIXME: Need read/writeObject -/* - * Instance Variables - */ - -// FIXME: Need read/writeObject - -/** + /** * @serial The items in the list. */ -private Vector items = new Vector(); + private Vector items = new Vector(); -/** + /** * @serial Indicates whether or not multiple items can be selected * simultaneously. */ -private boolean multipleMode; + private boolean multipleMode; -/** + /** * @serial The number of rows in the list. This is set on creation * only and cannot be modified. */ -private int rows; + private int rows; -/** + /** * @serial An array of the item indices that are selected. */ -private int[] selected; + private int[] selected; -/** + /** * @serial An index value used by <code>makeVisible()</code> and * <code>getVisibleIndex</code>. */ -private int visibleIndex; + private int visibleIndex = -1; -// The list of ItemListeners for this object. -private ItemListener item_listeners; + // The list of ItemListeners for this object. + private ItemListener item_listeners; -// The list of ActionListeners for this object. -private ActionListener action_listeners; + // The list of ActionListeners for this object. + private ActionListener action_listeners; - -/*************************************************************************/ - -/* - * Constructors - */ - -/** + /** * Initializes a new instance of <code>List</code> with no visible lines * and multi-select disabled. * * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. + * @since 1.1 */ -public -List() -{ + public List() + { this(4, false); -} + } -/*************************************************************************/ - -/** + /** * Initializes a new instance of <code>List</code> with the specified * number of visible lines and multi-select disabled. * @@ -140,15 +126,12 @@ * * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. */ -public -List(int rows) -{ + public List(int rows) + { this(rows, false); -} + } -/*************************************************************************/ - -/** + /** * Initializes a new instance of <code>List</code> with the specified * number of lines and the specified multi-select setting. * @@ -158,37 +141,34 @@ * * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true. */ -public -List(int rows, boolean multipleMode) -{ + public List(int rows, boolean multipleMode) + { + if (rows == 0) + this.rows = 4; + else this.rows = rows; + this.multipleMode = multipleMode; selected = new int[0]; if (GraphicsEnvironment.isHeadless()) - throw new HeadlessException (); -} + throw new HeadlessException(); -/*************************************************************************/ + } -/* - * Instance Variables - */ - -/** + /** * Returns the number of items in this list. * * @return The number of items in this list. + * + * @since 1.1 */ -public int -getItemCount() -{ - return countItems (); -} + public int getItemCount() + { + return countItems(); + } -/*************************************************************************/ - -/** + /** * Returns the number of items in this list. * * @return The number of items in this list. @@ -196,73 +176,62 @@ * @deprecated This method is deprecated in favor of * <code>getItemCount()</code> */ -public int -countItems() -{ - return items.size (); -} + public int countItems() + { + return items.size(); + } -/*************************************************************************/ - -/** + /** * Returns the complete list of items. * * @return The complete list of items in the list. + * + * @since 1.1 */ -public synchronized String[] -getItems() -{ + public synchronized String[] getItems() + { String[] l_items = new String[getItemCount()]; items.copyInto(l_items); return(l_items); -} + } -/*************************************************************************/ - -/** + /** * Returns the item at the specified index. * * @param index The index of the item to retrieve. * * @exception IndexOutOfBoundsException If the index value is not valid. */ -public String -getItem(int index) -{ - return((String)items.elementAt(index)); -} + public String getItem(int index) + { + return((String) items.elementAt(index)); + } -/*************************************************************************/ - -/** + /** * Returns the number of visible rows in the list. * * @return The number of visible rows in the list. */ -public int -getRows() -{ + public int getRows() + { return(rows); -} + } -/*************************************************************************/ - -/** + /** * Tests whether or not multi-select mode is enabled. * * @return <code>true</code> if multi-select mode is enabled, * <code>false</code> otherwise. + * + * @since 1.1 */ -public boolean -isMultipleMode() -{ + public boolean isMultipleMode() + { return allowsMultipleSelections (); -} + } -/*************************************************************************/ - -/** + /** * Tests whether or not multi-select mode is enabled. * * @return <code>true</code> if multi-select mode is enabled, @@ -271,30 +240,26 @@ * @deprecated This method is deprecated in favor of * <code>isMultipleMode()</code>. */ -public boolean -allowsMultipleSelections() -{ + public boolean allowsMultipleSelections() + { return multipleMode; -} + } -/*************************************************************************/ - -/** + /** * This method enables or disables multiple selection mode for this * list. * * @param multipleMode <code>true</code> to enable multiple mode, * <code>false</code> otherwise. + * + * @since 1.1 */ -public void -setMultipleMode(boolean multipleMode) -{ + public void setMultipleMode(boolean multipleMode) + { setMultipleSelections (multipleMode); -} + } -/*************************************************************************/ - -/** + /** * This method enables or disables multiple selection mode for this * list. * @@ -303,32 +268,29 @@ * * @deprecated */ -public void -setMultipleSelections(boolean multipleMode) -{ + public void setMultipleSelections(boolean multipleMode) + { this.multipleMode = multipleMode; - ListPeer peer = (ListPeer) getPeer (); + ListPeer peer = (ListPeer) getPeer(); if (peer != null) - peer.setMultipleMode (multipleMode); -} + peer.setMultipleMode(multipleMode); -/*************************************************************************/ + } -/** + /** * Returns the minimum size of this component. * * @return The minimum size of this component. + * + * @since 1.1 */ -public Dimension -getMinimumSize() -{ - return getMinimumSize (getRows ()); -} + public Dimension getMinimumSize() + { + return getMinimumSize(getRows()); + } -/*************************************************************************/ - -/** + /** * Returns the minimum size of this component. * * @return The minimum size of this component. @@ -336,31 +298,27 @@ * @deprecated This method is deprecated in favor of * <code>getMinimumSize</code>. */ -public Dimension -minimumSize() -{ - return minimumSize (getRows ()); -} + public Dimension minimumSize() + { + return minimumSize(getRows()); + } -/*************************************************************************/ - -/** + /** * Returns the minimum size of this component assuming it had the specified * number of rows. * * @param rows The number of rows to size for. * * @return The minimum size of this component. + * + * @since 1.1 */ -public Dimension -getMinimumSize(int rows) -{ - return minimumSize (rows); -} + public Dimension getMinimumSize(int rows) + { + return minimumSize(rows); + } -/*************************************************************************/ - -/** + /** * Returns the minimum size of this component assuming it had the specified * number of rows. * @@ -371,32 +329,28 @@ * @deprecated This method is deprecated in favor of * <code>getMinimumSize(int)</code>> */ -public Dimension -minimumSize(int rows) -{ - ListPeer peer = (ListPeer) getPeer (); + public Dimension minimumSize(int rows) + { + ListPeer peer = (ListPeer) getPeer(); if (peer != null) - return peer.minimumSize (rows); + return peer.minimumSize(rows); else - return new Dimension (0, 0); -} + return new Dimension(0, 0); + } -/*************************************************************************/ - -/** + /** * Returns the preferred size of this component. * * @return The preferred size of this component. + * + * @since 1.1 */ -public Dimension -getPreferredSize() -{ - return getPreferredSize (getRows ()); -} + public Dimension getPreferredSize() + { + return getPreferredSize(getRows()); + } -/*************************************************************************/ - -/** + /** * Returns the preferred size of this component. * * @return The preferred size of this component. @@ -404,31 +358,27 @@ * @deprecated This method is deprecated in favor of * <code>getPreferredSize</code>. */ -public Dimension -preferredSize() -{ - return preferredSize (getRows ()); -} + public Dimension preferredSize() + { + return preferredSize(getRows()); + } -/*************************************************************************/ - -/** + /** * Returns the preferred size of this component assuming it had the specified * number of rows. * * @param rows The number of rows to size for. * * @return The preferred size of this component. + * + * @since 1.1 */ -public Dimension -getPreferredSize(int rows) -{ - return preferredSize (rows); -} + public Dimension getPreferredSize(int rows) + { + return preferredSize(rows); + } -/*************************************************************************/ - -/** + /** * Returns the preferred size of this component assuming it had the specified * number of rows. * @@ -439,47 +389,40 @@ * @deprecated This method is deprecated in favor of * <code>getPreferredSize(int)</code>> */ -public Dimension -preferredSize(int rows) -{ - ListPeer peer = (ListPeer) getPeer (); + public Dimension preferredSize(int rows) + { + ListPeer peer = (ListPeer)getPeer(); if (peer != null) - return peer.preferredSize (rows); + return peer.preferredSize(rows); else return getSize(); -} + } -/*************************************************************************/ - -/** + /** * This method adds the specified item to the end of the list. * * @param item The item to add to the list. + * + * @since 1.1 */ -public void -add(String item) -{ + public void add(String item) + { add (item, -1); -} + } -/*************************************************************************/ - -/** + /** * This method adds the specified item to the end of the list. * * @param item The item to add to the list. * * @deprecated Use add() instead. */ -public void -addItem(String item) -{ - addItem (item, -1); -} + public void addItem(String item) + { + addItem(item, -1); + } -/*************************************************************************/ - -/** + /** * Adds the specified item to the specified location in the list. * If the desired index is -1 or greater than the number of rows * in the list, then the item is added to the end. @@ -487,16 +430,15 @@ * @param item The item to add to the list. * @param index The location in the list to add the item, or -1 to add * to the end. + * + * @since 1.1 */ -public void -add(String item, int index) -{ - addItem (item, index); -} + public void add(String item, int index) + { + addItem(item, index); + } -/*************************************************************************/ - -/** + /** * Adds the specified item to the specified location in the list. * If the desired index is -1 or greater than the number of rows * in the list, then the item is added to the end. @@ -507,22 +449,25 @@ * * @deprecated Use add() instead. */ -public void -addItem(String item, int index) -{ + public void addItem(String item, int index) + { + if (item == null) + item = ""; + + if (index < -1) + index = -1; + if ((index == -1) || (index >= items.size ())) items.addElement (item); else - items.insertElementAt (item, index); + items.insertElementAt(item, index); - ListPeer peer = (ListPeer) getPeer (); + ListPeer peer = (ListPeer) getPeer(); if (peer != null) peer.add (item, index); -} + } -/*************************************************************************/ - -/** + /** * Deletes the item at the specified index. * * @param index The index of the item to delete. @@ -531,34 +476,40 @@ * * @deprecated */ -public void -delItem(int index) throws IllegalArgumentException -{ + public void delItem(int index) throws IllegalArgumentException + { + boolean selected = false; + if (isSelected(index)) + { + selected = true; + deselect(index); + } + items.removeElementAt (index); - ListPeer peer = (ListPeer) getPeer (); + if (selected) + select(index); + + ListPeer peer = (ListPeer) getPeer(); if (peer != null) peer.delItems (index, index); -} + } -/*************************************************************************/ - -/** + /** * Deletes the item at the specified index. * * @param index The index of the item to delete. * * @exception IllegalArgumentException If the index is not valid + * + * @since 1.1 */ -public void -remove(int index) throws IllegalArgumentException -{ - delItem (index); -} + public void remove(int index) throws IllegalArgumentException + { + delItem(index); + } -/*************************************************************************/ - -/** + /** * Deletes all items in the specified index range. * * @param start The beginning index of the range to delete. @@ -568,18 +519,9 @@ * * @deprecated This method is deprecated for some unknown reason. */ -public synchronized void -delItems(int start, int end) throws IllegalArgumentException -{ - if ((start < 0) || (start >= items.size())) - throw new IllegalArgumentException("Bad list start index value: " + start); - - if ((start < 0) || (start >= items.size())) - throw new IllegalArgumentException("Bad list start index value: " + start); - - if (start > end) - throw new IllegalArgumentException("Start is greater than end!"); - + public synchronized void delItems(int start, int end) + throws IllegalArgumentException + { // We must run the loop in reverse direction. for (int i = end; i >= start; --i) items.removeElementAt (i); @@ -588,70 +530,65 @@ ListPeer l = (ListPeer) peer; l.delItems (start, end); } -} + } -/*************************************************************************/ - -/** + /** * Deletes the first occurrence of the specified item from the list. * * @param item The item to delete. * * @exception IllegalArgumentException If the specified item does not exist. + * + * @since 1.1 */ -public synchronized void -remove(String item) throws IllegalArgumentException -{ + public synchronized void remove(String item) throws IllegalArgumentException + { int index = items.indexOf(item); if (index == -1) throw new IllegalArgumentException("List element to delete not found"); remove(index); -} + } -/*************************************************************************/ - -/** + /** * Deletes all of the items from the list. + * + * @since 1.1 */ -public synchronized void -removeAll() -{ - clear (); -} + public synchronized void removeAll() + { + clear(); + } -/*************************************************************************/ - -/** + /** * Deletes all of the items from the list. * * @deprecated This method is deprecated in favor of <code>removeAll()</code>. */ -public... [truncated message content] |