harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r454042 [4/6] - in /incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common: java/awt/ org/apache/harmony/awt/
Date Sat, 07 Oct 2006 23:10:24 GMT
Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/KeyboardFocusManager.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/KeyboardFocusManager.java?view=diff&rev=454042&r1=454041&r2=454042
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/KeyboardFocusManager.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/KeyboardFocusManager.java Sat Oct  7 16:10:23 2006
@@ -14,10 +14,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Dmitry A. Durnev
- * @version $Revision$
- */
+
 package java.awt;
 
 import java.awt.event.FocusEvent;
@@ -30,15 +27,12 @@
 import java.beans.VetoableChangeSupport;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.Vector;
 
-
 public abstract class KeyboardFocusManager implements KeyEventDispatcher, KeyEventPostProcessor {
-
     public static final int FORWARD_TRAVERSAL_KEYS = 0;
 
     public static final int BACKWARD_TRAVERSAL_KEYS = 1;
@@ -47,23 +41,17 @@
 
     public static final int DOWN_CYCLE_TRAVERSAL_KEYS = 3;
 
-    final static int[] compTraversalIDs = { FORWARD_TRAVERSAL_KEYS,
-                                           BACKWARD_TRAVERSAL_KEYS,
-                                           UP_CYCLE_TRAVERSAL_KEYS };
-
-    final static int[] contTraversalIDs = { FORWARD_TRAVERSAL_KEYS,
-                                           BACKWARD_TRAVERSAL_KEYS,
-                                           UP_CYCLE_TRAVERSAL_KEYS,
-                                           DOWN_CYCLE_TRAVERSAL_KEYS };
+    final static int[] compTraversalIDs = { FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS,
+            UP_CYCLE_TRAVERSAL_KEYS };
 
-    private final Map<Integer, Set<AWTKeyStroke>> defaultFocusTraversalKeys =
-        new HashMap<Integer, Set<AWTKeyStroke>>();
+    final static int[] contTraversalIDs = { FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS,
+            UP_CYCLE_TRAVERSAL_KEYS, DOWN_CYCLE_TRAVERSAL_KEYS };
 
-    private FocusTraversalPolicy defaultFocusTraversalPolicy =
-        new DefaultFocusTraversalPolicy();
+    private final Map<Integer, Set<? extends AWTKeyStroke>> defaultFocusTraversalKeys = new HashMap<Integer, Set<? extends AWTKeyStroke>>();
 
-    // focus state is static, i. e. 1 per class loader:
+    private FocusTraversalPolicy defaultFocusTraversalPolicy = new DefaultFocusTraversalPolicy();
 
+    // focus state is static, i. e. 1 per class loader:
     static Component focusOwner;
 
     static Component actualFocusOwner;
@@ -92,13 +80,10 @@
 
     private VetoableChangeSupport vetoableChangeSupport;
 
-
-//    private final Toolkit toolkit = Toolkit.getDefaultToolkit();
-
+    //    private final Toolkit toolkit = Toolkit.getDefaultToolkit();
     public KeyboardFocusManager() {
         for (int element : contTraversalIDs) {
-            defaultFocusTraversalKeys.put(new Integer(element),
-                    null);
+            defaultFocusTraversalKeys.put(new Integer(element), null);
         }
     }
 
@@ -110,10 +95,8 @@
         keyEventPostProcessors.add(processor);
     }
 
-    public void addPropertyChangeListener(String propertyName,
-                                          PropertyChangeListener listener) {
-        getPropertyChangeSupport().addPropertyChangeListener(propertyName,
-                listener);
+    public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+        getPropertyChangeSupport().addPropertyChangeListener(propertyName, listener);
     }
 
     public void addPropertyChangeListener(PropertyChangeListener listener) {
@@ -124,16 +107,13 @@
         getVetoableChangeSupport().addVetoableChangeListener(listener);
     }
 
-    public void addVetoableChangeListener(String propertyName,
-                                          VetoableChangeListener listener) {
-        getVetoableChangeSupport().addVetoableChangeListener(propertyName,
-                listener);
+    public void addVetoableChangeListener(String propertyName, VetoableChangeListener listener) {
+        getVetoableChangeSupport().addVetoableChangeListener(propertyName, listener);
     }
 
     public void clearGlobalFocusOwner() {
         if (focusOwner != null) {
-            setFocus(focusOwner, focusOwner.getWindowAncestor(),
-                                    false, null, false, true);
+            setFocus(focusOwner, focusOwner.getWindowAncestor(), false, null, false, true);
         }
     }
 
@@ -156,17 +136,13 @@
 
     protected abstract void enqueueKeyEvents(long a0, Component a1);
 
-    protected void firePropertyChange(String propertyName, Object oldValue,
-                                      Object newValue) {
-        getPropertyChangeSupport().firePropertyChange(propertyName, oldValue,
-                                                      newValue);
+    protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+        getPropertyChangeSupport().firePropertyChange(propertyName, oldValue, newValue);
     }
 
-    protected void fireVetoableChange(String propertyName, Object oldValue,
-                                      Object newValue)
+    protected void fireVetoableChange(String propertyName, Object oldValue, Object newValue)
             throws PropertyVetoException {
-        getVetoableChangeSupport().fireVetoableChange(propertyName, oldValue,
-                                                      newValue);
+        getVetoableChangeSupport().fireVetoableChange(propertyName, oldValue, newValue);
     }
 
     public final void focusNextComponent() {
@@ -202,10 +178,11 @@
         }
     }
 
+    @SuppressWarnings("unchecked")
     public Set<AWTKeyStroke> getDefaultFocusTraversalKeys(int id) {
         Integer kId = Integer.valueOf(id);
         checkTraversalKeysID(defaultFocusTraversalKeys, kId);
-        return defaultFocusTraversalKeys.get(kId);
+        return (Set<AWTKeyStroke>) defaultFocusTraversalKeys.get(kId);
     }
 
     public FocusTraversalPolicy getDefaultFocusTraversalPolicy() {
@@ -249,9 +226,8 @@
      */
     private void checkInstance() throws SecurityException {
         if (getCurrentKeyboardFocusManager() != this) {
-            throw new SecurityException(
-                    "this KeyboardFocusManager is not installed "
-                            + "in the current thread's context");
+            throw new SecurityException("this KeyboardFocusManager is not installed "
+                    + "in the current thread's context");
         }
     }
 
@@ -262,13 +238,10 @@
         return focusedWindow;
     }
 
-    protected Component getGlobalPermanentFocusOwner()
-        throws SecurityException {
-
+    protected Component getGlobalPermanentFocusOwner() throws SecurityException {
         checkInstance();
         // TODO: get global permanent focus owner somehow
         // (not from the current class loader)
-
         return permanentFocusOwner;
     }
 
@@ -312,7 +285,7 @@
     }
 
     public void removeKeyEventDispatcher(KeyEventDispatcher dispatcher) {
-       keyEventDispatchers.remove(dispatcher);
+        keyEventDispatchers.remove(dispatcher);
     }
 
     public void removeKeyEventPostProcessor(KeyEventPostProcessor processor) {
@@ -320,9 +293,8 @@
     }
 
     public void removePropertyChangeListener(String propertyName,
-                                             PropertyChangeListener listener) {
-        getPropertyChangeSupport().removePropertyChangeListener(propertyName,
-                                                                listener);
+            PropertyChangeListener listener) {
+        getPropertyChangeSupport().removePropertyChangeListener(propertyName, listener);
     }
 
     public void removePropertyChangeListener(PropertyChangeListener listener) {
@@ -334,9 +306,8 @@
     }
 
     public void removeVetoableChangeListener(String propertyName,
-                                             VetoableChangeListener listener) {
-        getVetoableChangeSupport().removeVetoableChangeListener(propertyName,
-                                                                listener);
+            VetoableChangeListener listener) {
+        getVetoableChangeSupport().removeVetoableChangeListener(propertyName, listener);
     }
 
     public static void setCurrentKeyboardFocusManager(KeyboardFocusManager newManager)
@@ -351,9 +322,8 @@
                 secMan.checkPermission(new AWTPermission(permission));
             }
             oldManager = toolkit.currentKeyboardFocusManager;
-            toolkit.currentKeyboardFocusManager =
-                ((newManager != null) ? newManager :
-                 new DefaultKeyboardFocusManager());
+            toolkit.currentKeyboardFocusManager = ((newManager != null) ? newManager
+                    : new DefaultKeyboardFocusManager());
         } finally {
             toolkit.unlockAWT();
         }
@@ -369,38 +339,37 @@
 
     public void setDefaultFocusTraversalKeys(int id, Set<? extends AWTKeyStroke> keystrokes) {
         Integer kId = Integer.valueOf(id);
-        Set<AWTKeyStroke> oldKeyStrokes = defaultFocusTraversalKeys.get(kId);
+        Set<? extends AWTKeyStroke> oldKeyStrokes = defaultFocusTraversalKeys.get(kId);
         checkTraversalKeysID(defaultFocusTraversalKeys, kId);
-        checkKeyStrokes(contTraversalIDs, defaultFocusTraversalKeys, kId,
-                        (Set<AWTKeyStroke>) keystrokes);
-        defaultFocusTraversalKeys.put(kId, (Set<AWTKeyStroke>) keystrokes);
+        checkKeyStrokes(contTraversalIDs, defaultFocusTraversalKeys, kId, keystrokes);
+        defaultFocusTraversalKeys.put(kId, keystrokes);
         String propName = null;
         switch (id) {
-        case FORWARD_TRAVERSAL_KEYS:
-            propName = "forwardDefaultFocusTraversalKeys";
-            break;
-        case BACKWARD_TRAVERSAL_KEYS:
-            propName = "backwardDefaultFocusTraversalKeys";
-            break;
-        case UP_CYCLE_TRAVERSAL_KEYS:
-            propName = "upCycleDefaultFocusTraversalKeys";
-            break;
-        case DOWN_CYCLE_TRAVERSAL_KEYS:
-            propName = "downCycleDefaultFocusTraversalKeys";
-            break;
+            case FORWARD_TRAVERSAL_KEYS:
+                propName = "forwardDefaultFocusTraversalKeys";
+                break;
+            case BACKWARD_TRAVERSAL_KEYS:
+                propName = "backwardDefaultFocusTraversalKeys";
+                break;
+            case UP_CYCLE_TRAVERSAL_KEYS:
+                propName = "upCycleDefaultFocusTraversalKeys";
+                break;
+            case DOWN_CYCLE_TRAVERSAL_KEYS:
+                propName = "downCycleDefaultFocusTraversalKeys";
+                break;
         }
         firePropertyChange(propName, oldKeyStrokes, keystrokes);
     }
 
     public void setDefaultFocusTraversalPolicy(FocusTraversalPolicy defaultPolicy) {
         if (defaultPolicy == null) {
-            throw new IllegalArgumentException("default focus traversal policy" +
-                    " cannot be null");
+            throw new IllegalArgumentException("default focus traversal policy"
+                    + " cannot be null");
         }
         FocusTraversalPolicy oldPolicy = defaultFocusTraversalPolicy;
         defaultFocusTraversalPolicy = defaultPolicy;
         firePropertyChange("defaultFocusTraversalPolicy", oldPolicy,
-                           defaultFocusTraversalPolicy);
+                defaultFocusTraversalPolicy);
     }
 
     protected void setGlobalActiveWindow(Window activeWindow) {
@@ -408,8 +377,7 @@
         // fire Vetoable change[before it is reflected in Java focus state],
         // catch veto exception
         try {
-            fireVetoableChange(propName, KeyboardFocusManager.activeWindow,
-                               activeWindow);
+            fireVetoableChange(propName, KeyboardFocusManager.activeWindow, activeWindow);
         } catch (PropertyVetoException e) {
             // abort the change, i. e.
             // don't reflect the change in KFM, don't report to property change
@@ -418,26 +386,21 @@
         }
         Window oldActiveWindow = KeyboardFocusManager.activeWindow;
         KeyboardFocusManager.activeWindow = activeWindow;
-        firePropertyChange(propName, oldActiveWindow,
-                           KeyboardFocusManager.activeWindow);
+        firePropertyChange(propName, oldActiveWindow, KeyboardFocusManager.activeWindow);
     }
 
     public void setGlobalCurrentFocusCycleRoot(Container newFocusCycleRoot) {
         Container oldFocusCycleRoot = currentFocusCycleRoot;
         currentFocusCycleRoot = newFocusCycleRoot;
-        firePropertyChange("currentFocusCycleRoot", oldFocusCycleRoot,
-                           currentFocusCycleRoot);
+        firePropertyChange("currentFocusCycleRoot", oldFocusCycleRoot, currentFocusCycleRoot);
     }
 
     protected void setGlobalFocusOwner(Component focusOwner) {
         String propName = "focusOwner";
-
         // fire Vetoable change[before it is reflected in Java focus state],
         // catch veto exception
-
         try {
-            fireVetoableChange(propName, KeyboardFocusManager.focusOwner,
-                               focusOwner);
+            fireVetoableChange(propName, KeyboardFocusManager.focusOwner, focusOwner);
         } catch (PropertyVetoException e) {
             // abort the change, i. e.
             // don't reflect the change in KFM, don't report to property change
@@ -451,70 +414,55 @@
                 //don't clear current focus cycle root every time a component
                 //is losing focus
                 //TODO: do it[clear] somewhere else(maybe Window.dispose()??)
-                Container root =
-                     ( (focusOwner instanceof Window) ? (Window)focusOwner :
-                        focusOwner.getFocusCycleRootAncestor() );
-
+                Container root = ((focusOwner instanceof Window) ? (Window) focusOwner
+                        : focusOwner.getFocusCycleRootAncestor());
                 if (root == null || root.isFocusCycleRoot()) {
                     setGlobalCurrentFocusCycleRoot(root);
                 }
             }
         }
-
-        firePropertyChange(propName, oldFocusOwner,
-                           KeyboardFocusManager.focusOwner);
+        firePropertyChange(propName, oldFocusOwner, KeyboardFocusManager.focusOwner);
     }
 
     protected void setGlobalFocusedWindow(Window focusedWindow) {
         String propName = "focusedWindow";
-
         // fire Vetoable change[before it is reflected in Java focus state],
         // catch veto exception
-
         try {
-            fireVetoableChange(propName, KeyboardFocusManager.focusedWindow,
-                               focusedWindow);
+            fireVetoableChange(propName, KeyboardFocusManager.focusedWindow, focusedWindow);
         } catch (PropertyVetoException e) {
             // abort the change, i. e.
             // don't reflect the change in KFM, don't report to property change
             // listeners
             return;
         }
-
         Window oldFocusedWindow = KeyboardFocusManager.focusedWindow;
         if (focusedWindow == null || focusedWindow.isFocusableWindow()) {
             KeyboardFocusManager.focusedWindow = focusedWindow;
         }
-
-        firePropertyChange(propName, oldFocusedWindow,
-                           KeyboardFocusManager.focusedWindow);
-
+        firePropertyChange(propName, oldFocusedWindow, KeyboardFocusManager.focusedWindow);
     }
 
     protected void setGlobalPermanentFocusOwner(Component permanentFocusOwner) {
         String propName = "permanentFocusOwner";
-
         // fire Vetoable change[before it is reflected in Java focus state],
         // catch veto exception
-
         try {
             fireVetoableChange(propName, KeyboardFocusManager.permanentFocusOwner,
-                               permanentFocusOwner);
+                    permanentFocusOwner);
         } catch (PropertyVetoException e) {
             // abort the change, i. e.
             // don't reflect the change in KFM,
             // don't report to property change listeners
             return;
         }
-        Component oldPermanentFocusOwner =
-            KeyboardFocusManager.permanentFocusOwner;
-        if ((permanentFocusOwner == null) ||
-             permanentFocusOwner.isFocusable()) {
+        Component oldPermanentFocusOwner = KeyboardFocusManager.permanentFocusOwner;
+        if ((permanentFocusOwner == null) || permanentFocusOwner.isFocusable()) {
             KeyboardFocusManager.permanentFocusOwner = permanentFocusOwner;
             setGlobalFocusOwner(permanentFocusOwner);
         }
         firePropertyChange(propName, oldPermanentFocusOwner,
-                           KeyboardFocusManager.permanentFocusOwner);
+                KeyboardFocusManager.permanentFocusOwner);
     }
 
     public final void upFocusCycle() {
@@ -525,57 +473,42 @@
 
     static void checkTraversalKeysID(Map<?, ?> keysMap, Integer id) {
         if (!keysMap.containsKey(id)) {
-            throw new IllegalArgumentException(
-                    "invalid focus traversal key identifier");
+            throw new IllegalArgumentException("invalid focus traversal key identifier");
         }
     }
 
-    static void checkKeyStrokes(int[] traversalIDs, Map<Integer, Set<AWTKeyStroke>> traversalKeys,
-                                Integer kId, Set<AWTKeyStroke> keystrokes) {
-        if (keystrokes == null) {
+    static void checkKeyStrokes(int[] traversalIDs,
+            Map<Integer, Set<? extends AWTKeyStroke>> traversalKeys, Integer kId,
+            Set<? extends AWTKeyStroke> keystrokes) {
+        if (keystrokes == null || keystrokes.isEmpty()) {
             return;
         }
-
-        Iterator<AWTKeyStroke> i = keystrokes.iterator();
-        while (i.hasNext()) {
-            Object o = i.next();
-            AWTKeyStroke key = o instanceof AWTKeyStroke ? (AWTKeyStroke) o
-                                                        : null;
+        for (AWTKeyStroke key : keystrokes) {
             if (key == null) {
-                throw new IllegalArgumentException(
-                        o == null ? "cannot set null focus traversal key"
-                                 : "cannot set focus traversal key " +
-                                        "to non-AWTKeyStroke");
+                throw new IllegalArgumentException("cannot set null focus traversal key");
             } // actually throw ClassCastException ??
             if (key.getKeyEventType() == KeyEvent.KEY_TYPED) {
                 throw new IllegalArgumentException(
                         "focus traversal keys cannot map to KEY_TYPED events");
             }
-
             // throw exception if such a KeyStroke is already present for
             // another id
-
             for (int element : traversalIDs) {
-                Integer theID = new Integer(element);
-                Object val = traversalKeys.get(theID);
+                Integer theID = Integer.valueOf(element);
+                Set<? extends AWTKeyStroke> val = traversalKeys.get(theID);
                 if ((!theID.equals(kId)) &&
-                    (val instanceof Set) &&
-                    ((Set)val).contains(key)) {
-
-                    throw new IllegalArgumentException(
-                            "focus traversal keys must be unique" +
-                            " for a Component");
+                        val != null && 
+                        val.contains(key)) {
+                    throw new IllegalArgumentException("focus traversal keys must be unique"
+                            + " for a Component");
                 }
             }
         }
-
     }
 
-    boolean requestFocus(Component c, boolean temporary,
-                         boolean crossWindow, boolean callCB) {
+    boolean requestFocus(Component c, boolean temporary, boolean crossWindow, boolean callCB) {
         Window wnd = ((c != null) ? c.getWindowAncestor() : null);
         return requestFocus(c, wnd, temporary, crossWindow, callCB);
-
     }
 
     /**
@@ -584,12 +517,10 @@
      * Component's request focus callCB is set to true, when called directly
      * from native event dispatching code - to false.
      */
-    boolean requestFocus(Component c, Window wnd, boolean temporary,
-                         boolean crossWindow, boolean callCB) {
-
+    boolean requestFocus(Component c, Window wnd, boolean temporary, boolean crossWindow,
+            boolean callCB) {
         Window focusedWnd = actualFocusedWindow;
         Window activeWnd = actualActiveWindow;
-
         // don't take focus from other applications:
         // change active window from null only if native
         // event is received(i. e. callCB is false)
@@ -601,29 +532,23 @@
             }
             return false;
         }
-
         if (callCB && !checkWindow(wnd)) {
             return false;
         }
-
         setFocus(actualFocusOwner, wnd, false, c, temporary, callCB);
-
         // in case of cross-window focus transfer
         // remember that this component had requested focus in that window
-
         if (crossWindow && (focusedWnd != wnd)) {
             wnd.setRequestedFocus(c);
             wnd.behaviour.setFocus(true, focusedWnd); // try to change
             // focusedWindow(?)
         }
-
         //        if (!wnd.isFocused()) {
         //            return false; //async focus - wait until window actually gains
         //            // focus
         //        }
         wnd.setRequestedFocus(c);
         setFocus(c, wnd, true, actualPrevFocusOwner, temporary, callCB);
-
         if (wnd != null) {
             wnd.setFocusOwner(c);
             wnd.setRequestedFocus(null);
@@ -641,12 +566,10 @@
         if (wnd == null) {
             return false;
         }
-
         if (wnd instanceof EmbeddedWindow) {
             // TODO: query state of EmbeddedWindow's owner
             return true;
         }
-
         // FIXME: explicitly deny focus requests for components
         // inside iconified/shaded windows:
         if ((getOwningFrame(wnd).getExtendedState() & Frame.ICONIFIED) != 0) {
@@ -657,11 +580,10 @@
 
     Frame getOwningFrame(Window w) {
         Window wnd;
-        for (wnd = w; (wnd != null) && !(wnd instanceof Frame);
-             wnd = wnd.getOwner()) {
+        for (wnd = w; (wnd != null) && !(wnd instanceof Frame); wnd = wnd.getOwner()) {
             ;
         }
-        return (Frame)wnd;
+        return (Frame) wnd;
     }
 
     /**
@@ -672,48 +594,35 @@
      * proper order
      */
     void setFocus(Component c, Window wnd, boolean focus, Component opposite,
-                  boolean temporary, boolean callCB) {
+            boolean temporary, boolean callCB) {
         Window focusedWnd = actualFocusedWindow;
-
-
-        Window oppositeAncestorWnd =
-            ( (opposite != null) ? opposite.getWindowAncestor() :
-              (focus ? focusedWnd : null) );
+        Window oppositeAncestorWnd = ((opposite != null) ? opposite.getWindowAncestor()
+                : (focus ? focusedWnd : null));
         Window ancestorWnd = (!focus ? focusedWnd : wnd);
-
         if (!focus && (ancestorWnd == null)) {
             ancestorWnd = actualActiveWindow;
         }
-
         if (focus) {
             postWindowEvent(ancestorWnd, oppositeAncestorWnd, focus);
         }
-
         if (c != null) {
             // when losing focus to some component in other window
             // post temporary event:
             if (!focus && (opposite != null) && !callCB) {
-                temporary =
-                    (c.getWindowAncestor() != opposite.getWindowAncestor());
+                temporary = (c.getWindowAncestor() != opposite.getWindowAncestor());
             }
-            FocusEvent newEvent = new FocusEvent(c,
-                    focus ? FocusEvent.FOCUS_GAINED : FocusEvent.FOCUS_LOST,
-                    temporary, opposite);
-
+            FocusEvent newEvent = new FocusEvent(c, focus ? FocusEvent.FOCUS_GAINED
+                    : FocusEvent.FOCUS_LOST, temporary, opposite);
             // remember previous focus owner to be able to post it as opposite
             // later
             // [when opposite component gains focus]
             // but clear it if application loses focus
             if (!focus) {
-                actualPrevFocusOwner =
-                    ( (opposite != null) ? actualFocusOwner : null );
+                actualPrevFocusOwner = ((opposite != null) ? actualFocusOwner : null);
             }
-            actualFocusOwner = ( focus ? c :
-                ((c == actualFocusOwner) ? null : actualFocusOwner) );
-
+            actualFocusOwner = (focus ? c : ((c == actualFocusOwner) ? null : actualFocusOwner));
             c.postEvent(newEvent);
         }
-
         // post window events when losing focus only if
         // there's opposite component or
         // events come from native layer[if opposite is null],
@@ -725,7 +634,6 @@
         if (focus && callCB) {
             c.behaviour.setFocus(focus, opposite);
         }
-
     }
 
     /**
@@ -733,11 +641,9 @@
      * as if it is the focused Window
      */
     boolean requestFocusInWindow(Window wnd, boolean callCB) {
-
         if (wnd == null) {
             return false;
         }
-        
         Component lastReqFocus = wnd.getRequestedFocus();
         if ((lastReqFocus != null) && (lastReqFocus.getWindowAncestor() != wnd)) {
             lastReqFocus = null;
@@ -747,18 +653,13 @@
         if ((lastFocusOwner != null) && lastFocusOwner.getWindowAncestor() != wnd) {
             lastFocusOwner = null;
         }
-        Component compToFocus = ((lastReqFocus != null) ? lastReqFocus :
-                                                          lastFocusOwner);
-                
-
+        Component compToFocus = ((lastReqFocus != null) ? lastReqFocus : lastFocusOwner);
         if (compToFocus != null) {
             return requestFocus(compToFocus, wnd, false, false, callCB);
         }
-
         // even if there's no component to focus
         // we can try to focus window itself
         return requestFocus(wnd, wnd, false, false, callCB);
-
     }
 
     /**
@@ -773,47 +674,29 @@
      */
     boolean postWindowEvent(Window wnd, Window opposite, boolean focus) {
         Window focusedWnd = actualFocusedWindow;
-
         Window decorWnd = ((wnd != null) ? wnd.getFrameDialogOwner() : null);
-        int focusEventId =
-            (focus ? WindowEvent.WINDOW_GAINED_FOCUS :
-             WindowEvent.WINDOW_LOST_FOCUS);
-        int activationEventId =
-            (focus ? WindowEvent.WINDOW_ACTIVATED :
-             WindowEvent.WINDOW_DEACTIVATED);
-
+        int focusEventId = (focus ? WindowEvent.WINDOW_GAINED_FOCUS
+                : WindowEvent.WINDOW_LOST_FOCUS);
+        int activationEventId = (focus ? WindowEvent.WINDOW_ACTIVATED
+                : WindowEvent.WINDOW_DEACTIVATED);
         if ((opposite == null) && (prevFocusedWindow != null)) {
             opposite = prevFocusedWindow;
         }
-        Window oppositeDecorWnd = ((opposite != null) ?
-                                   opposite.getFrameDialogOwner() :
-                                   null);
-
-        boolean focusedWindowChanged =
-            ( (wnd != null) &&
-              (focus ? focusedWnd != wnd :
-               opposite != wnd) );
-        boolean activeWindowChanged =
-            ( (decorWnd != null) &&
-              (focus ? actualActiveWindow != decorWnd :
-               oppositeDecorWnd != decorWnd) );
-        WindowEvent activationEvent =
-            ( activeWindowChanged ?
-              new WindowEvent(decorWnd,
-                              activationEventId,
-                              oppositeDecorWnd) :
-              null );
-
+        Window oppositeDecorWnd = ((opposite != null) ? opposite.getFrameDialogOwner() : null);
+        boolean focusedWindowChanged = ((wnd != null) && (focus ? focusedWnd != wnd
+                : opposite != wnd));
+        boolean activeWindowChanged = ((decorWnd != null) && (focus ? actualActiveWindow != decorWnd
+                : oppositeDecorWnd != decorWnd));
+        WindowEvent activationEvent = (activeWindowChanged ? new WindowEvent(decorWnd,
+                activationEventId, oppositeDecorWnd) : null);
         if (activeWindowChanged && focus) {
             decorWnd.postEvent(activationEvent);
             actualActiveWindow = decorWnd;
         }
-
         if (focusedWindowChanged) {
             wnd.postEvent(new WindowEvent(wnd, focusEventId, opposite));
             actualFocusedWindow = (focus ? wnd : null);
         }
-
         if (activeWindowChanged && !focus) {
             decorWnd.postEvent(activationEvent);
             actualActiveWindow = null;
@@ -834,4 +717,4 @@
         }
         return vetoableChangeSupport;
     }
-}
\ No newline at end of file
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/List.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/List.java?view=diff&rev=454042&r1=454041&r2=454042
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/List.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/List.java Sat Oct  7 16:10:23 2006
@@ -14,10 +14,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Dmitry A. Durnev
- * @version $Revision$
- */
+
 package java.awt;
 
 import java.awt.event.ActionEvent;
@@ -36,56 +33,63 @@
 import java.util.Iterator;
 import java.util.ArrayList;
 import java.util.Locale;
-
 import javax.accessibility.Accessible;
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleRole;
 import javax.accessibility.AccessibleSelection;
 import javax.accessibility.AccessibleState;
 import javax.accessibility.AccessibleStateSet;
-
 import org.apache.harmony.awt.ScrollStateController;
 import org.apache.harmony.awt.Scrollable;
 import org.apache.harmony.awt.state.ListState;
 
-
 public class List extends Component implements ItemSelectable, Accessible {
-
     private static final long serialVersionUID = -3304312411574666869L;
+
     private final static int BORDER_SIZE = 2;
-    private final AWTListenerList actionListeners = new AWTListenerList(this);
-    private final AWTListenerList itemListeners = new AWTListenerList(this);
+
+    private final AWTListenerList<ActionListener> actionListeners = new AWTListenerList<ActionListener>(
+            this);
+
+    private final AWTListenerList<ItemListener> itemListeners = new AWTListenerList<ItemListener>(
+            this);
 
     private int rows;
 
     private boolean multipleMode;
 
     private final ArrayList<String> items = new ArrayList<String>();
+
     private final ArrayList<Integer> selection = new ArrayList<Integer>();
 
     private int visibleIndex = -1;
+
     private int currentIndex; // "focused" item index
 
     private final ListStateController stateController;
+
     private final ListScrollable scrollable;
+
     private final State state;
 
     private final ScrollPaneAdjustable hAdjustable;
+
     private final ScrollPaneAdjustable vAdjustable;
 
     private transient Point scrollLocation;
-    private transient int prefWidth;
 
-    protected class AccessibleAWTList extends AccessibleAWTComponent
-    implements AccessibleSelection, ItemListener, ActionListener {
+    private transient int prefWidth;
 
+    protected class AccessibleAWTList extends AccessibleAWTComponent implements
+            AccessibleSelection, ItemListener, ActionListener {
         private static final long serialVersionUID = 7924617370136012829L;
 
-        protected class AccessibleAWTListChild extends AccessibleAWTComponent
-        implements Accessible {
-
+        protected class AccessibleAWTListChild extends AccessibleAWTComponent implements
+                Accessible {
             private static final long serialVersionUID = 4412022926028300317L;
-            private int accessibleIndexInParent;
+
+            private final int accessibleIndexInParent;
+
             private List parent;
 
             public AccessibleAWTListChild(List parent, int indexInParent) {
@@ -278,6 +282,7 @@
             addActionListener(this);
             addItemListener(this);
         }
+
         public int getAccessibleSelectionCount() {
             return getSelectedIndexes().length;
         }
@@ -308,7 +313,6 @@
             } finally {
                 toolkit.unlockAWT();
             }
-
         }
 
         public void addAccessibleSelection(int i) {
@@ -343,12 +347,10 @@
 
         public void itemStateChanged(ItemEvent e) {
             // TODO: find out why listen to ItemEvents
-
         }
 
         public void actionPerformed(ActionEvent e) {
             // TODO: find out why listen to ActionEvents
-
         }
 
         @Override
@@ -396,11 +398,10 @@
         }
     }
 
-    class ListStateController extends ScrollStateController
-    implements MouseListener, KeyListener, FocusListener,
-    MouseMotionListener {
-
+    class ListStateController extends ScrollStateController implements MouseListener,
+            KeyListener, FocusListener, MouseMotionListener {
         boolean scrollPressed;
+
         public ListStateController(Scrollable scrollable) {
             super(scrollable);
         }
@@ -413,12 +414,10 @@
 
         public void mouseEntered(MouseEvent e) {
             // nothing to do
-
         }
 
         public void mouseExited(MouseEvent e) {
             // nothing to do
-
         }
 
         public void mousePressed(MouseEvent e) {
@@ -436,8 +435,7 @@
                 if (checkIdx(idx)) {
                     requestFocus();
                     boolean selected = isIndexSelected(idx);
-                    int sel = selected ? ItemEvent.DESELECTED
-                                      : ItemEvent.SELECTED;
+                    int sel = selected ? ItemEvent.DESELECTED : ItemEvent.SELECTED;
                     if (!selected) {
                         select(idx);
                     } else {
@@ -445,11 +443,10 @@
                     }
                     fireItemEvent(sel);
                 }
-            } else if (vAdjustable.getBounds().contains(pt) ||
-                       hAdjustable.getBounds().contains(pt)) {
+            } else if (vAdjustable.getBounds().contains(pt)
+                    || hAdjustable.getBounds().contains(pt)) {
                 scrollPressed = true;
             }
-
         }
 
         public void mouseReleased(MouseEvent e) {
@@ -460,48 +457,46 @@
             assert isFocusOwner() : "Key event for unfocused component";
             int keyCode = e.getKeyCode();
             switch (keyCode) {
-            case KeyEvent.VK_UP:
-                scrollByUnit(vAdjustable, -1);
-                break;
-            case KeyEvent.VK_LEFT:
-                scrollByUnit(hAdjustable, -1);
-                break;
-            case KeyEvent.VK_DOWN:
-                scrollByUnit(vAdjustable, 1);
-                break;
-            case KeyEvent.VK_RIGHT:
-                scrollByUnit(hAdjustable, 1);
-                break;
-            case KeyEvent.VK_PAGE_UP:
-                scrollByBlock(-1);
-                break;
-            case KeyEvent.VK_PAGE_DOWN:
-                scrollByBlock(1);
-                break;
-            case KeyEvent.VK_HOME:
-                selectVisible(0);
-                break;
-            case KeyEvent.VK_END:
-                int lastIdx = getItemCount() - 1;
-                selectVisible(lastIdx);
-                break;
-            case KeyEvent.VK_ENTER:
-                fireActionEvent(e.getWhen(), e.getModifiers());
-                break;
-            case KeyEvent.VK_SPACE:
-                if (isMultipleMode()) {
-                    boolean deselect = isIndexSelected(currentIndex);
-                    if (deselect) {
-                        deselect(currentIndex);
-                    } else {
-                        select(currentIndex);
+                case KeyEvent.VK_UP:
+                    scrollByUnit(vAdjustable, -1);
+                    break;
+                case KeyEvent.VK_LEFT:
+                    scrollByUnit(hAdjustable, -1);
+                    break;
+                case KeyEvent.VK_DOWN:
+                    scrollByUnit(vAdjustable, 1);
+                    break;
+                case KeyEvent.VK_RIGHT:
+                    scrollByUnit(hAdjustable, 1);
+                    break;
+                case KeyEvent.VK_PAGE_UP:
+                    scrollByBlock(-1);
+                    break;
+                case KeyEvent.VK_PAGE_DOWN:
+                    scrollByBlock(1);
+                    break;
+                case KeyEvent.VK_HOME:
+                    selectVisible(0);
+                    break;
+                case KeyEvent.VK_END:
+                    int lastIdx = getItemCount() - 1;
+                    selectVisible(lastIdx);
+                    break;
+                case KeyEvent.VK_ENTER:
+                    fireActionEvent(e.getWhen(), e.getModifiers());
+                    break;
+                case KeyEvent.VK_SPACE:
+                    if (isMultipleMode()) {
+                        boolean deselect = isIndexSelected(currentIndex);
+                        if (deselect) {
+                            deselect(currentIndex);
+                        } else {
+                            select(currentIndex);
+                        }
+                        fireItemEvent(deselect ? ItemEvent.DESELECTED : ItemEvent.SELECTED);
                     }
-                    fireItemEvent(deselect ? ItemEvent.DESELECTED :
-                        ItemEvent.SELECTED);
-                }
-                break;
+                    break;
             }
-
         }
 
         private void selectVisible(int idx) {
@@ -520,7 +515,6 @@
         private void scrollByBlock(int val) {
             int itemsPerBlock = getClient().height / getItemSize().height;
             scrollByUnit(vAdjustable, val * itemsPerBlock);
-
         }
 
         private void scrollByUnit(Adjustable adj, int val) {
@@ -539,12 +533,10 @@
 
         public void keyReleased(KeyEvent e) {
             // nothing to do
-
         }
 
         public void keyTyped(KeyEvent e) {
             // nothing to do
-
         }
 
         public void fireActionEvent(long when, int mod) {
@@ -552,12 +544,12 @@
                 return;
             }
             postEvent(new ActionEvent(List.this, ActionEvent.ACTION_PERFORMED,
-                                      getItem(currentIndex), when, mod));
+                    getItem(currentIndex), when, mod));
         }
 
         public void fireItemEvent(int sel) {
             postEvent(new ItemEvent(List.this, ItemEvent.ITEM_STATE_CHANGED,
-                                    getItem(currentIndex), sel));
+                    getItem(currentIndex), sel));
         }
 
         public void focusGained(FocusEvent e) {
@@ -577,7 +569,6 @@
             if (checkIdx(idx)) {
                 selectVisible(idx);
             }
-
         }
 
         private boolean checkIdx(int idx) {
@@ -587,11 +578,9 @@
         public void mouseMoved(MouseEvent e) {
             // nothing to do
         }
-
     }
 
     class ListScrollable implements Scrollable {
-
         public Adjustable getVAdjustable() {
             return vAdjustable;
         }
@@ -633,7 +622,6 @@
 
         public void setAdjustableSizes(Adjustable adj, int vis, int min, int max) {
             ((ScrollPaneAdjustable) adj).setSizes(vis, min, max);
-
         }
 
         public int getAdjustableMode(Adjustable adj) {
@@ -664,11 +652,9 @@
         public void doRepaint(Rectangle r) {
             List.this.doRepaint(r);
         }
-
     }
 
     class State extends ComponentState implements ListState {
-
         public Rectangle getItemBounds(int idx) {
             return List.this.getItemBounds(idx);
         }
@@ -692,8 +678,8 @@
         public int getCurrentIndex() {
             return List.this.getCurrentIndex();
         }
-
     }
+
     public List(int rows) throws HeadlessException {
         this(rows, false);
         toolkit.lockAWT();
@@ -716,16 +702,14 @@
         toolkit.lockAWT();
         try {
             Toolkit.checkHeadless();
-            this.rows = ( (rows != 0) ? rows : 4);
+            this.rows = ((rows != 0) ? rows : 4);
             this.multipleMode = multipleMode;
-
             scrollLocation = new Point();
             hAdjustable = new ScrollPaneAdjustable(this, Adjustable.HORIZONTAL);
             vAdjustable = new ScrollPaneAdjustable(this, Adjustable.VERTICAL);
             scrollable = new ListScrollable();
             stateController = new ListStateController(scrollable);
             state = new State();
-
             addAWTMouseListener(stateController);
             addAWTMouseMotionListener(stateController);
             addAWTKeyListener(stateController);
@@ -746,7 +730,6 @@
         } finally {
             toolkit.unlockAWT();
         }
-
     }
 
     public void add(String item, int index) {
@@ -786,7 +769,7 @@
             items.remove(position);
             // decrease all selected indices greater than position
             // by 1, because items list is shifted to the left
-            for (int i=0; i < selection.size(); i++) {
+            for (int i = 0; i < selection.size(); i++) {
                 Integer idx = selection.get(i);
                 int val = idx.intValue();
                 if (val > position) {
@@ -837,7 +820,6 @@
         } finally {
             toolkit.unlockAWT();
         }
-
     }
 
     public String getItem(int index) {
@@ -909,15 +891,12 @@
             if (!isDisplayable()) {
                 return new Dimension();
             }
-
             int maxItemWidth = minSize.width;
-            FontRenderContext frc =
-                ((Graphics2D)getGraphics()).getFontRenderContext();
+            FontRenderContext frc = ((Graphics2D) getGraphics()).getFontRenderContext();
             Font font = getFont();
             for (int i = 0; i < items.size(); i++) {
                 String item = getItem(i);
-                int itemWidth =
-                    font.getStringBounds(item, frc).getBounds().width;
+                int itemWidth = font.getStringBounds(item, frc).getBounds().width;
                 if (itemWidth > maxItemWidth) {
                     maxItemWidth = itemWidth;
                 }
@@ -1155,7 +1134,7 @@
             Integer[] selArr = new Integer[selection.size()];
             selection.toArray(selArr);
             int[] intArr = new int[selArr.length];
-            for(int i = 0; i < selArr.length; i++) {
+            for (int i = 0; i < selArr.length; i++) {
                 intArr[i] = selArr[i].intValue();
             }
             return intArr;
@@ -1184,7 +1163,7 @@
             String[] selItemsArr = new String[size];
             Integer[] selArr = new Integer[size];
             selection.toArray(selArr);
-            for(int i = 0; i < selItemsArr.length; i++) {
+            for (int i = 0; i < selItemsArr.length; i++) {
                 selItemsArr[i] = items.get(selArr[i].intValue());
             }
             return selItemsArr;
@@ -1246,7 +1225,7 @@
         toolkit.lockAWT();
         try {
             visibleIndex = index;
-            if (!isDisplayable() || !isIdxValid(index) ) {
+            if (!isDisplayable() || !isIdxValid(index)) {
                 return;
             }
             // scroll if necessary
@@ -1256,8 +1235,7 @@
             if (dy < 0) {
                 stateController.updateAdjValue(vAdjustable, dy);
             }
-            dy = itemRect.y + itemRect.height -
-            (clientRect.y + clientRect.height);
+            dy = itemRect.y + itemRect.height - (clientRect.y + clientRect.height);
             if (dy > 0) {
                 stateController.updateAdjValue(vAdjustable, dy);
             }
@@ -1296,7 +1274,6 @@
             // repaint only item's rectangle & old "focused" item's rect
             doRepaint(getMinRect(index, currentIndex));
             currentIndex = index;
-
         } finally {
             toolkit.unlockAWT();
         }
@@ -1332,6 +1309,7 @@
         }
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
         if (ActionListener.class.isAssignableFrom(listenerType)) {
@@ -1352,8 +1330,7 @@
     }
 
     public ActionListener[] getActionListeners() {
-        return (ActionListener[])
-        actionListeners.getUserListeners(new ActionListener[0]);
+        return actionListeners.getUserListeners(new ActionListener[0]);
     }
 
     public void addItemListener(ItemListener l) {
@@ -1365,14 +1342,12 @@
     }
 
     public ItemListener[] getItemListeners() {
-        return (ItemListener[])
-        itemListeners.getUserListeners(new ItemListener[0]);
+        return itemListeners.getUserListeners(new ItemListener[0]);
     }
 
     @Override
     protected void processEvent(AWTEvent e) {
         long eventMask = toolkit.eventTypeLookup.getEventMask(e);
-
         if (eventMask == AWTEvent.ACTION_EVENT_MASK) {
             processActionEvent((ActionEvent) e);
         } else if (eventMask == AWTEvent.ITEM_EVENT_MASK) {
@@ -1385,11 +1360,10 @@
     protected void processItemEvent(ItemEvent e) {
         for (Iterator<?> i = itemListeners.getUserIterator(); i.hasNext();) {
             ItemListener listener = (ItemListener) i.next();
-
             switch (e.getID()) {
-            case ItemEvent.ITEM_STATE_CHANGED:
-                listener.itemStateChanged(e);
-                break;
+                case ItemEvent.ITEM_STATE_CHANGED:
+                    listener.itemStateChanged(e);
+                    break;
             }
         }
     }
@@ -1397,11 +1371,10 @@
     protected void processActionEvent(ActionEvent e) {
         for (Iterator<?> i = actionListeners.getUserIterator(); i.hasNext();) {
             ActionListener listener = (ActionListener) i.next();
-
             switch (e.getID()) {
-            case ActionEvent.ACTION_PERFORMED:
-                listener.actionPerformed(e);
-                break;
+                case ActionEvent.ACTION_PERFORMED:
+                    listener.actionPerformed(e);
+                    break;
             }
         }
     }
@@ -1462,13 +1435,13 @@
 
     private Rectangle getItemBounds(int pos) {
         Dimension itemSize = getItemSize();
-        Point p = new Point(BORDER_SIZE,
-                            pos * itemSize.height + BORDER_SIZE);
+        Point p = new Point(BORDER_SIZE, pos * itemSize.height + BORDER_SIZE);
         Rectangle itemRect = new Rectangle(p, itemSize);
         itemRect.translate(scrollLocation.x, scrollLocation.y);
-        return  itemRect;
+        return itemRect;
     }
 
+    @SuppressWarnings("deprecation")
     private Dimension getItemSize() {
         FontMetrics fm = toolkit.getFontMetrics(getFont());
         int itemHeight = fm.getHeight() + 2;
@@ -1476,7 +1449,7 @@
     }
 
     private int getItemIndex(int y) {
-       return (y - BORDER_SIZE - scrollLocation.y) / getItemSize().height;
+        return (y - BORDER_SIZE - scrollLocation.y) / getItemSize().height;
     }
 
     private int getCurrentIndex() {
@@ -1485,10 +1458,8 @@
 
     private Rectangle getClient() {
         Insets ins = getNativeInsets();
-
-        return new Rectangle(ins.left, ins.top,
-                             getWidth() - (ins.left + ins.right),
-                             getHeight() - (ins.top + ins.bottom));
+        return new Rectangle(ins.left, ins.top, getWidth() - (ins.left + ins.right),
+                getHeight() - (ins.top + ins.bottom));
     }
 
     @Override
@@ -1496,9 +1467,7 @@
         if (!isDisplayable()) {
             return super.getInsets();
         }
-        Insets insets = new Insets(BORDER_SIZE, BORDER_SIZE,
-                                   BORDER_SIZE, BORDER_SIZE);
-
+        Insets insets = new Insets(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE);
         return insets;
     }
 
@@ -1545,4 +1514,3 @@
         return new AccessibleAWTList();
     }
 }
-

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Menu.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Menu.java?view=diff&rev=454042&r1=454041&r2=454042
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Menu.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Menu.java Sat Oct  7 16:10:23 2006
@@ -14,46 +14,41 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Pavel Dolgov
- * @version $Revision$
- */
+
 package java.awt;
 
 import java.awt.event.KeyEvent;
 import java.awt.event.MouseEvent;
 import java.util.ArrayList;
 import java.util.HashSet;
-
 import javax.accessibility.Accessible;
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleRole;
-
 import org.apache.harmony.awt.gl.MultiRectArea;
 import org.apache.harmony.awt.state.MenuState;
 
-
-
 public class Menu extends MenuItem implements MenuContainer, Accessible {
-
     private static final long serialVersionUID = -8809584163345499784L;
+
     final static int LAST_ELEMENT = Integer.MAX_VALUE;
+
     private final ArrayList<MenuItem> menuItems = new ArrayList<MenuItem>();
+
     private final Point location = new Point();
+
     private final Dimension size = new Dimension();
 
     private final boolean tearOff;
+
     final MenuPopupBox popupBox = new MenuPopupBox();
 
     protected class AccessibleAWTMenu extends AccessibleAWTMenuItem {
-
         private static final long serialVersionUID = 5228160894980069094L;
 
         @Override
         public AccessibleRole getAccessibleRole() {
             return AccessibleRole.MENU;
         }
-
     }
 
     /**
@@ -64,30 +59,38 @@
         public int getWidth() {
             return Menu.this.getWidth();
         }
+
         @Override
         public int getHeight() {
             return Menu.this.getHeight();
         }
+
         @Override
         public Font getFont() {
             return Menu.this.getFont();
         }
+
         @Override
         public int getItemCount() {
             return Menu.this.getItemCount();
         }
+
         @Override
         public int getSelectedItemIndex() {
             return Menu.this.getSelectedItemIndex();
         }
+
         @Override
         public boolean isFontSet() {
             return Menu.this.isFontSet();
         }
+
+        @SuppressWarnings("deprecation")
         @Override
         public FontMetrics getFontMetrics(Font f) {
             return Menu.this.toolkit.getFontMetrics(f);
         }
+
         @Override
         public Point getLocation() {
             return Menu.this.location;
@@ -174,7 +177,7 @@
         toolkit.lockAWT();
         try {
             while (!menuItems.isEmpty()) {
-                removeImpl(menuItems.size()-1);
+                removeImpl(menuItems.size() - 1);
             }
         } finally {
             toolkit.unlockAWT();
@@ -210,7 +213,6 @@
         if (oldParent != null) {
             oldParent.remove(item);
         }
-
         item.setParent(this);
         if (index >= menuItems.size()) {
             menuItems.add(item);
@@ -354,30 +356,27 @@
         location.x = x;
         location.y = y;
         selectItem(-1, true);
-
         PopupBox parentBox = null;
         if (parent instanceof MenuComponent) {
-            parentBox = ((MenuComponent)parent).getPopupBox();
+            parentBox = ((MenuComponent) parent).getPopupBox();
         }
-
         size.setSize(toolkit.theme.calculateMenuSize(menuState));
-
         popupBox.setParent(parentBox);
         popupBox.setModal(modal);
         popupBox.show(location, size, getOwnerWindow());
     }
 
     Window getOwnerWindow() {
-        for (MenuContainer cont = getParent(); cont != null; ) {
+        for (MenuContainer cont = getParent(); cont != null;) {
             if (cont instanceof Component) {
-                return ((Component)cont).getWindowAncestor();
+                return ((Component) cont).getWindowAncestor();
             }
             if (cont instanceof Menu) {
-                cont = ((Menu)cont).parent;
+                cont = ((Menu) cont).parent;
                 continue;
             }
             if (cont instanceof MenuBar) {
-                return (Window)((MenuBar)cont).parent;
+                return (Window) ((MenuBar) cont).parent;
             }
         }
         return null;
@@ -389,7 +388,6 @@
         for (int i = 0; i < getItemCount(); i++) {
             getItem(i).hide();
         }
-
         popupBox.hide();
     }
 
@@ -405,15 +403,12 @@
 
     @Override
     void onMouseEvent(int eventId, Point where, int mouseButton, long when, int modifiers) {
-        if (eventId == MouseEvent.MOUSE_PRESSED ||
-                eventId == MouseEvent.MOUSE_MOVED ||
-                eventId == MouseEvent.MOUSE_DRAGGED) {
+        if (eventId == MouseEvent.MOUSE_PRESSED || eventId == MouseEvent.MOUSE_MOVED
+                || eventId == MouseEvent.MOUSE_DRAGGED) {
             int index = toolkit.theme.getMenuItemIndex(menuState, where);
-
             if (index >= 0 || getSelectedSubmenu() == null) {
                 selectItem(index);
             }
-
         } else if (eventId == MouseEvent.MOUSE_RELEASED) {
             int index = toolkit.theme.getMenuItemIndex(menuState, where);
             selectItem(index);
@@ -453,7 +448,7 @@
             case KeyEvent.VK_LEFT:
                 if (parent instanceof Menu) {
                     hide();
-                }else {
+                } else {
                     menuBar = getMenuBar();
                     if (menuBar != null) {
                         menuBar.onKeyEvent(eventId, vKey, when, modifiers);
@@ -465,7 +460,7 @@
                 selectNextItem(vKey == KeyEvent.VK_DOWN, false);
                 break;
             case KeyEvent.VK_ENTER:
-                if (selected >=0) {
+                if (selected >= 0) {
                     fireItemAction(selected, when, modifiers);
                 } else {
                     hide();
@@ -499,10 +494,10 @@
     }
 
     void collectShortcuts(HashSet<MenuShortcut> shortcuts) {
-        for (int i=0; i<menuItems.size(); i++) {
+        for (int i = 0; i < menuItems.size(); i++) {
             MenuItem item = menuItems.get(i);
             if (item instanceof Menu) {
-                ((Menu)item).collectShortcuts(shortcuts);
+                ((Menu) item).collectShortcuts(shortcuts);
             } else {
                 MenuShortcut ms = item.getShortcut();
                 if (ms != null) {
@@ -512,4 +507,3 @@
         }
     }
 }
-

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/MenuComponent.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/MenuComponent.java?view=diff&rev=454042&r1=454041&r2=454042
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/MenuComponent.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/MenuComponent.java Sat Oct  7 16:10:23 2006
@@ -14,10 +14,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Pavel Dolgov
- * @version $Revision$
- */
+
 package java.awt;
 
 import java.awt.event.FocusListener;
@@ -25,39 +22,35 @@
 import java.awt.peer.MenuComponentPeer;
 import java.io.Serializable;
 import java.util.Locale;
-
 import javax.accessibility.Accessible;
 import javax.accessibility.AccessibleComponent;
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleRole;
 import javax.accessibility.AccessibleSelection;
 import javax.accessibility.AccessibleStateSet;
-
 import org.apache.harmony.awt.gl.MultiRectArea;
 import org.apache.harmony.awt.state.MenuItemState;
 import org.apache.harmony.awt.state.MenuState;
 
-
 public abstract class MenuComponent implements Serializable {
-
     private static final long serialVersionUID = -4536902356223894379L;
 
-
     private String name;
+
     private Font font;
+
     MenuContainer parent;
 
     boolean deprecatedEventHandler = true;
 
     private int selectedItemIndex;
+
     private AccessibleContext accessibleContext;
 
     final Toolkit toolkit = Toolkit.getDefaultToolkit();
 
-    protected abstract class AccessibleAWTMenuComponent extends
-            AccessibleContext implements Serializable, AccessibleComponent,
-            AccessibleSelection {
-
+    protected abstract class AccessibleAWTMenuComponent extends AccessibleContext implements
+            Serializable, AccessibleComponent, AccessibleSelection {
         private static final long serialVersionUID = -4269533416223798698L;
 
         public void addFocusListener(FocusListener listener) {
@@ -210,7 +203,6 @@
                 if (aParent instanceof MenuComponent) {
                     MenuComponent parent = (MenuComponent) aParent;
                     int count = parent.getItemCount();
-
                     for (int i = 0; i < count; i++) {
                         MenuComponent comp = parent.getItem(i);
                         if (comp instanceof Accessible) {
@@ -276,7 +268,6 @@
      * utilized by the visual theme
      */
     class State implements MenuState {
-
         Dimension size;
 
         Dimension getSize() {
@@ -289,34 +280,43 @@
         public int getWidth() {
             return getSize().width;
         }
+
         public int getHeight() {
             return getSize().height;
         }
+
         public Font getFont() {
             return MenuComponent.this.getFont();
         }
+
         public int getItemCount() {
             return MenuComponent.this.getItemCount();
         }
+
         public int getSelectedItemIndex() {
             return MenuComponent.this.getSelectedItemIndex();
         }
+
         public boolean isFontSet() {
             return MenuComponent.this.isFontSet();
         }
+
+        @SuppressWarnings("deprecation")
         public FontMetrics getFontMetrics(Font f) {
             return MenuComponent.this.toolkit.getFontMetrics(f);
         }
+
         public Point getLocation() {
             return MenuComponent.this.getLocation();
         }
+
         public MenuItemState getItem(int index) {
             MenuItem item = MenuComponent.this.getItem(index);
             return item.itemState;
         }
+
         public void setSize(int w, int h) {
             this.size = new Dimension(w, h);
-
         }
 
         void calculate() {
@@ -325,8 +325,8 @@
         }
 
         void reset() {
-            for (int i=0; i < getItemCount(); i++) {
-                ((MenuItem.State)getItem(i)).reset();
+            for (int i = 0; i < getItemCount(); i++) {
+                ((MenuItem.State) getItem(i)).reset();
             }
         }
     }
@@ -336,7 +336,6 @@
      * keyboard and mouse events to the menu component itself
      */
     class MenuPopupBox extends PopupBox {
-
         private final Point lastMousePos = new Point();
 
         @Override
@@ -355,14 +354,12 @@
         }
 
         @Override
-        void onMouseEvent(int eventId, Point where, int mouseButton, long when,
-                int modifiers, int wheelRotation) {
-
+        void onMouseEvent(int eventId, Point where, int mouseButton, long when, int modifiers,
+                int wheelRotation) {
             // prevent conflict of mouse and keyboard
             // when sub-menu drops down due to keyboard navigation
-            if (lastMousePos.equals(where) &&
-                    (eventId == MouseEvent.MOUSE_MOVED ||
-                     eventId == MouseEvent.MOUSE_ENTERED)) {
+            if (lastMousePos.equals(where)
+                    && (eventId == MouseEvent.MOUSE_MOVED || eventId == MouseEvent.MOUSE_ENTERED)) {
                 return;
             }
             lastMousePos.setLocation(where);
@@ -374,7 +371,6 @@
         toolkit.lockAWT();
         try {
             Toolkit.checkHeadless();
-
             name = autoName();
             selectedItemIndex = -1;
         } finally {
@@ -423,7 +419,6 @@
         toolkit.lockAWT();
         try {
             processEvent(event);
-
             if (deprecatedEventHandler) {
                 postDeprecatedEvent(event);
             }
@@ -459,9 +454,7 @@
         return toolkit.awtTreeLock;
     }
 
-    /**
-     * @deprecated
-     */
+    @SuppressWarnings("deprecation")
     @Deprecated
     public boolean postEvent(Event e) {
         toolkit.lockAWT();
@@ -512,9 +505,8 @@
     }
 
     boolean isFontSet() {
-        return font != null ||
-                ((parent instanceof MenuComponent) &&
-                ((MenuComponent)parent).isFontSet());
+        return font != null
+                || ((parent instanceof MenuComponent) && ((MenuComponent) parent).isFontSet());
     }
 
     boolean hasDefaultFont() {
@@ -524,7 +516,7 @@
     protected void processEvent(AWTEvent event) {
         toolkit.lockAWT();
         try {
-        // do nothing
+            // do nothing
         } finally {
             toolkit.unlockAWT();
         }
@@ -579,7 +571,7 @@
         for (int i = 0; i < getItemCount(); i++) {
             MenuItem mi = getItem(i);
             if (mi instanceof Menu) {
-                mi = ((Menu)mi).getShortcutMenuItemImpl(ms);
+                mi = ((Menu) mi).getShortcutMenuItemImpl(ms);
                 if (mi != null) {
                     return mi;
                 }
@@ -649,7 +641,7 @@
             return null;
         }
         MenuItem item = getItem(selectedItemIndex);
-        return (item instanceof Menu) ? (Menu)item : null;
+        return (item instanceof Menu) ? (Menu) item : null;
     }
 
     /**
@@ -670,17 +662,14 @@
             return;
         }
         if (selectedItemIndex >= 0 && getItem(selectedItemIndex) instanceof Menu) {
-            ((Menu)getItem(selectedItemIndex)).hide();
+            ((Menu) getItem(selectedItemIndex)).hide();
         }
-
         MultiRectArea clip = getUpdateClip(index, selectedItemIndex);
         selectedItemIndex = index;
-
         Graphics gr = getGraphics(clip);
         if (gr != null) {
             paint(gr);
         }
-
         if (showSubMenu) {
             showSubMenu(selectedItemIndex);
         }
@@ -704,9 +693,8 @@
         }
         int i = selected;
         do {
-            i = (forward ? (i+1) : (i+count-1)) % count;
+            i = (forward ? (i + 1) : (i + count - 1)) % count;
             i %= count;
-
             MenuItem item = getItem(i);
             if (!"-".equals(item.getLabel())) {
                 selectItem(i, showSubMenu);
@@ -721,7 +709,7 @@
         }
         MenuItem item = getItem(index);
         if (item instanceof Menu) {
-            Menu menu = ((Menu)getItem(index));
+            Menu menu = ((Menu) getItem(index));
             if (menu.getItemCount() == 0) {
                 return;
             }
@@ -736,10 +724,10 @@
      */
     MenuBar getMenuBar() {
         if (parent instanceof MenuBar) {
-            return (MenuBar)parent;
+            return (MenuBar) parent;
         }
         if (parent instanceof MenuComponent) {
-            return ((MenuComponent)parent).getMenuBar();
+            return ((MenuComponent) parent).getMenuBar();
         }
         return null;
     }
@@ -762,7 +750,6 @@
      */
     final MultiRectArea getUpdateClip(int index1, int index2) {
         MultiRectArea clip = new MultiRectArea();
-
         if (index1 >= 0) {
             clip.add(getItemRect(index1));
         }
@@ -784,7 +771,7 @@
     void hide() {
         selectedItemIndex = -1;
         if (parent instanceof MenuComponent) {
-            ((MenuComponent)parent).itemHidden(this);
+            ((MenuComponent) parent).itemHidden(this);
         }
     }
 
@@ -818,14 +805,11 @@
 
     String autoName() {
         String name = getClass().getName();
-
         if (name.indexOf("$") != -1) {
             return null;
         }
-
         int number = toolkit.autoNumber.nextMenuComponent++;
         name = name.substring(name.lastIndexOf(".") + 1) + Integer.toString(number);
-
         return name;
     }
 
@@ -833,7 +817,7 @@
      * Creates the Graphics object for the pop-up box of this menu component
      * @param clip - the clip to set on this Graphics
      * @return - the created Graphics object, 
-     * or null if such object is not avaiable.
+     * or null if such object is not available.
      */
     Graphics getGraphics(MultiRectArea clip) {
         // to be overridden
@@ -847,4 +831,3 @@
         return null;
     }
 }
-

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/MenuItem.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/MenuItem.java?view=diff&rev=454042&r1=454041&r2=454042
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/MenuItem.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/MenuItem.java Sat Oct  7 16:10:23 2006
@@ -14,40 +14,37 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Pavel Dolgov
- * @version $Revision$
- */
+
 package java.awt;
 
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.lang.reflect.Array;
 import java.util.EventListener;
-import java.util.Iterator;
-
 import javax.accessibility.Accessible;
 import javax.accessibility.AccessibleAction;
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleRole;
 import javax.accessibility.AccessibleValue;
-
 import org.apache.harmony.awt.state.MenuItemState;
 
-
 public class MenuItem extends MenuComponent implements Accessible {
-
     private static final long serialVersionUID = -21757335363267194L;
 
     private String label;
+
     private MenuShortcut shortcut;
+
     private long enabledEvents;
+
     private boolean enabled;
+
     private String actionCommand;
-    private final AWTListenerList actionListeners = new AWTListenerList(null);
 
-    protected class AccessibleAWTMenuItem extends AccessibleAWTMenuComponent
-            implements AccessibleAction, AccessibleValue {
+    private final AWTListenerList<ActionListener> actionListeners = new AWTListenerList<ActionListener>();
 
+    protected class AccessibleAWTMenuItem extends AccessibleAWTMenuComponent implements
+            AccessibleAction, AccessibleValue {
         private static final long serialVersionUID = -217847831945965825L;
 
         @Override
@@ -108,7 +105,6 @@
         public boolean setCurrentAccessibleValue(Number n) {
             return false;
         }
-
     }
 
     /**
@@ -116,53 +112,68 @@
      */
     class State implements MenuItemState {
         private Rectangle textBounds;
+
         private Rectangle shortcutBounds;
+
         private Rectangle itemBounds;
 
         public String getText() {
             return MenuItem.this.getLabel();
         }
+
         public Rectangle getTextBounds() {
             return textBounds;
         }
+
         public void setTextBounds(int x, int y, int w, int h) {
             textBounds = new Rectangle(x, y, w, h);
         }
+
         public boolean isMenu() {
             return MenuItem.this instanceof Menu;
         }
+
         public boolean isChecked() {
-            return (MenuItem.this instanceof CheckboxMenuItem) &&
-                    ((CheckboxMenuItem)MenuItem.this).getState();
+            return (MenuItem.this instanceof CheckboxMenuItem)
+                    && ((CheckboxMenuItem) MenuItem.this).getState();
         }
+
         public boolean isEnabled() {
             return enabled;
         }
+
         public String getShortcut() {
             return (shortcut != null ? shortcut.toString() : "");
         }
+
         public Rectangle getShortcutBounds() {
             return shortcutBounds;
         }
+
         public void setShortcutBounds(int x, int y, int w, int h) {
             shortcutBounds = new Rectangle(x, y, w, h);
         }
+
         public boolean isCheckBox() {
             return (MenuItem.this instanceof CheckboxMenuItem);
         }
+
         public boolean isSeparator() {
             String label = MenuItem.this.getLabel();
             return label != null && label.equals("-");
         }
+
         public Dimension getMenuSize() {
             if (MenuItem.this instanceof Menu) {
-                return ((Menu)MenuItem.this).getSize();
+                return ((Menu) MenuItem.this).getSize();
             }
             return null;
         }
+
         public Rectangle getItemBounds() {
             return itemBounds;
         }
+
         public void setItemBounds(int x, int y, int w, int h) {
             itemBounds = new Rectangle(x, y, w, h);
         }
@@ -245,13 +256,14 @@
         }
     }
 
+    @SuppressWarnings("unchecked")
     public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
         toolkit.lockAWT();
         try {
             if (ActionListener.class.isAssignableFrom(listenerType)) {
                 return (T[]) getActionListeners();
             }
-            return (T[]) java.lang.reflect.Array.newInstance(listenerType, 0);
+            return (T[]) Array.newInstance(listenerType, 0);
         } finally {
             toolkit.unlockAWT();
         }
@@ -259,16 +271,14 @@
 
     @Override
     public String paramString() {
-        /* The format of paramString is based on 1.5 release behavior 
-         * which can be revealed using the following code:
-         *
-         * MenuItem obj = new MenuItem("Label", 
-         *      new MenuShortcut(KeyEvent.VK_A));
-         * obj.setActionCommand("Action");
-         * obj.disable();
-         * System.out.println(obj.toString());
+        /*
+         * The format of paramString is based on 1.5 release behavior which can
+         * be revealed using the following code:
+         * 
+         * MenuItem obj = new MenuItem("Label", new
+         * MenuShortcut(KeyEvent.VK_A)); obj.setActionCommand("Action");
+         * obj.disable(); System.out.println(obj.toString());
          */
-
         toolkit.lockAWT();
         try {
             String result = super.paramString() + ",label=" + label;
@@ -375,17 +385,15 @@
     }
 
     public ActionListener[] getActionListeners() {
-        return (ActionListener[]) actionListeners.getUserListeners(new ActionListener[0]);
+        return actionListeners.getUserListeners(new ActionListener[0]);
     }
 
     protected void processActionEvent(ActionEvent event) {
-        for (Iterator i = actionListeners.getUserIterator(); i.hasNext();) {
-            ActionListener listener = (ActionListener) i.next();
-
+        for (ActionListener listener : actionListeners.getUserListeners()) {
             switch (event.getID()) {
-            case ActionEvent.ACTION_PERFORMED:
-                listener.actionPerformed(event);
-                break;
+                case ActionEvent.ACTION_PERFORMED:
+                    listener.actionPerformed(event);
+                    break;
             }
         }
     }
@@ -443,13 +451,12 @@
     void itemSelected(long when, int modifiers) {
         AWTEvent event = createEvent(when, modifiers);
         toolkit.getSystemEventQueueImpl().postEvent(event);
-
         super.itemSelected(when, modifiers);
     }
 
     AWTEvent createEvent(long when, int modifiers) {
-        return new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
-                getActionCommand(), when, modifiers);
+        return new ActionEvent(this, ActionEvent.ACTION_PERFORMED, getActionCommand(), when,
+                modifiers);
     }
 
     @Override

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/ScrollPane.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/ScrollPane.java?view=diff&rev=454042&r1=454041&r2=454042
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/ScrollPane.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/ScrollPane.java Sat Oct  7 16:10:23 2006
@@ -14,26 +14,19 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Dmitry A. Durnev
- * @version $Revision$
- */
+
 package java.awt;
 
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseWheelEvent;
-
 import javax.accessibility.Accessible;
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleRole;
-
 import org.apache.harmony.awt.ScrollStateController;
 import org.apache.harmony.awt.Scrollable;
 import org.apache.harmony.awt.theme.DefaultButton;
 
-
 public class ScrollPane extends Container implements Accessible {
-
     private static final long serialVersionUID = 7956609840827222915L;
 
     public static final int SCROLLBARS_AS_NEEDED = 0;
@@ -43,22 +36,27 @@
     public static final int SCROLLBARS_NEVER = 2;
 
     final static int HSCROLLBAR_HEIGHT = 16;
+
     final static int VSCROLLBAR_WIDTH = 16;
+
     final static int BORDER_SIZE = 2;
-    private final static Insets defInsets = new Insets(BORDER_SIZE, BORDER_SIZE,
-                                                       BORDER_SIZE, BORDER_SIZE);
+
+    private final static Insets defInsets = new Insets(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE,
+            BORDER_SIZE);
 
     private int scrollbarDisplayPolicy;
+
     private boolean wheelScrollingEnabled;
 
     private ScrollPaneAdjustable hAdjustable;
+
     private ScrollPaneAdjustable vAdjustable;
 
     private final ScrollStateController stateController;
+
     private final Scrollable scrollable;
 
     protected class AccessibleAWTScrollPane extends AccessibleAWTContainer {
-
         private static final long serialVersionUID = 6100703663886637L;
 
         protected AccessibleAWTScrollPane() {
@@ -71,7 +69,6 @@
     }
 
     class SPScrollable implements Scrollable {
-
         public Adjustable getVAdjustable() {
             return vAdjustable;
         }
@@ -111,7 +108,6 @@
 
         public void doRepaint() {
             ScrollPane.this.doRepaint();
-
         }
 
         public int getAdjustableWidth() {
@@ -124,7 +120,6 @@
 
         public void setAdjustableSizes(Adjustable adj, int vis, int min, int max) {
             ((ScrollPaneAdjustable) adj).setSizes(vis, min, max);
-
         }
 
         public int getAdjustableMode(Adjustable adj) {
@@ -132,8 +127,7 @@
         }
 
         public void setAdjustableBounds(Adjustable adj, Rectangle r) {
-            ((ScrollPaneAdjustable)adj).setBounds(r);
-
+            ((ScrollPaneAdjustable) adj).setBounds(r);
         }
 
         public int getWidth() {
@@ -147,10 +141,8 @@
         public void doRepaint(Rectangle r) {
             ScrollPane.this.doRepaint(r);
         }
-
     }
 
-
     public ScrollPane() throws HeadlessException {
         this(SCROLLBARS_AS_NEEDED);
         toolkit.lockAWT();
@@ -165,13 +157,12 @@
         try {
             Toolkit.checkHeadless();
             switch (scrollbarDisplayPolicy) {
-            case SCROLLBARS_ALWAYS:
-            case SCROLLBARS_AS_NEEDED:
-            case SCROLLBARS_NEVER:
-                break;
-            default:
-                throw new IllegalArgumentException("illegal scrollbar " +
-                        "display policy");
+                case SCROLLBARS_ALWAYS:
+                case SCROLLBARS_AS_NEEDED:
+                case SCROLLBARS_NEVER:
+                    break;
+                default:
+                    throw new IllegalArgumentException("illegal scrollbar " + "display policy");
             }
             this.scrollbarDisplayPolicy = scrollbarDisplayPolicy;
             setWheelScrollingEnabled(true);
@@ -215,35 +206,30 @@
          * which can be revealed by the following code:
          * System.out.println(new ScrollPane());
          */
-
         toolkit.lockAWT();
         try {
             Point scrollPos = new Point();
             try {
                 scrollPos = getScrollPosition();
             } catch (NullPointerException npe) {
-
             }
             Insets ins = getInsets();
-            String strPolicy ="";
+            String strPolicy = "";
             switch (getScrollbarDisplayPolicy()) {
-            case SCROLLBARS_ALWAYS:
-                strPolicy = "always";
-                break;
-            case SCROLLBARS_AS_NEEDED:
-                strPolicy = "as-needed";
-                break;
-            case SCROLLBARS_NEVER:
-                strPolicy = "never";
-                break;
-
-            }
-            return (super.paramString() +
-                    ",ScrollPosition=(" + scrollPos.x + "," + scrollPos.x + ")" +
-                    ",Insets=(" + ins.left + "," + ins.top + "," +
-                    ins.right + "," + ins.bottom + ")" +
-                    ",ScrollbarDisplayPolicy=" + strPolicy +
-                    ",wheelScrollingEnabled=" + isWheelScrollingEnabled());
+                case SCROLLBARS_ALWAYS:
+                    strPolicy = "always";
+                    break;
+                case SCROLLBARS_AS_NEEDED:
+                    strPolicy = "as-needed";
+                    break;
+                case SCROLLBARS_NEVER:
+                    strPolicy = "never";
+                    break;
+            }
+            return (super.paramString() + ",ScrollPosition=(" + scrollPos.x + "," + scrollPos.x
+                    + ")" + ",Insets=(" + ins.left + "," + ins.top + "," + ins.right + ","
+                    + ins.bottom + ")" + ",ScrollbarDisplayPolicy=" + strPolicy
+                    + ",wheelScrollingEnabled=" + isWheelScrollingEnabled());
         } finally {
             toolkit.unlockAWT();
         }
@@ -262,17 +248,13 @@
     protected boolean eventTypeEnabled(int type) {
         toolkit.lockAWT();
         try {
-            return (isWheelScrollingEnabled() &&
-                    (type == MouseEvent.MOUSE_WHEEL));
+            return (isWheelScrollingEnabled() && (type == MouseEvent.MOUSE_WHEEL));
         } finally {
             toolkit.unlockAWT();
         }
-
     }
 
-    /**
-     * @deprecated
-     */
+    @SuppressWarnings("deprecation")
     @Deprecated
     @Override
     public void layout() {
@@ -302,7 +284,6 @@
         }
     }
 
-
     @Override
     protected void processMouseWheelEvent(MouseWheelEvent e) {
         toolkit.lockAWT();
@@ -321,7 +302,6 @@
             if (index > 0) {
                 throw new IllegalArgumentException("position greater than 0");
             }
-
             if (getComponentCount() > 0) {
                 remove(0);
             }
@@ -347,7 +327,6 @@
         } finally {
             toolkit.unlockAWT();
         }
-
     }
 
     public Point getScrollPosition() {
@@ -417,7 +396,7 @@
             super.printComponents(g);
         } finally {
             toolkit.unlockAWT();
-        }       
+        }
     }
 
     @Override
@@ -429,7 +408,6 @@
         } finally {
             toolkit.unlockAWT();
         }
-
     }
 
     public void setScrollPosition(Point p) {
@@ -476,7 +454,6 @@
         } finally {
             toolkit.unlockAWT();
         }
-
     }
 
     @Override
@@ -494,8 +471,7 @@
         g.setColor(getBackground());
         g.fillRect(0, 0, w, h);
         // draw pressed button frame:
-        DefaultButton.drawButtonFrame(g, new Rectangle(new Point(),
-                                                       getSize()), true);
+        DefaultButton.drawButtonFrame(g, new Rectangle(new Point(), getSize()), true);
         vAdjustable.prepaint(g);
         hAdjustable.prepaint(g);
     }
@@ -545,10 +521,8 @@
         doRepaint(new Rectangle(new Point(), getSize()));
     }
 
-
     @Override
     AccessibleContext createAccessibleContext() {
         return new AccessibleAWTScrollPane();
     }
 }
-



Mime
View raw message