From 48ed6852bf333cd1cd230b40712c1ad96adcb446 Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Thu, 18 Jun 2009 11:28:54 +0400 Subject: [PATCH 01/23] 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first Reviewed-by: dcherepanov --- .../ContainerOrderFocusTraversalPolicy.java | 12 ++-- .../swing/SortingFocusTraversalPolicy.java | 9 ++- .../FocusTraversalPolicy/DefaultFTPTest.java | 62 ++++++++++++++++++- .../FocusTraversalPolicy/LayoutFTPTest.java | 62 ++++++++++++++++++- 4 files changed, 131 insertions(+), 14 deletions(-) diff --git a/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java b/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java index 187ddc54931..e3913a7fff9 100644 --- a/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java +++ b/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java @@ -425,15 +425,13 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy } if (log.isLoggable(Level.FINE)) log.fine("### Cycle is " + cycle); - for (int i = 0; i < cycle.size(); i++) { - Component comp = cycle.get(i); + for (Component comp : cycle) { if (accept(comp)) { return comp; - } else if (comp instanceof Container && comp != aContainer) { - Container cont = (Container)comp; - if (cont.isFocusTraversalPolicyProvider()) { - return cont.getFocusTraversalPolicy().getDefaultComponent(cont); - } + } else if (comp != aContainer && + (comp = getComponentDownCycle(comp, FORWARD_TRAVERSAL)) != null) + { + return comp; } } } diff --git a/jdk/src/share/classes/javax/swing/SortingFocusTraversalPolicy.java b/jdk/src/share/classes/javax/swing/SortingFocusTraversalPolicy.java index 73c391faac5..715732fcee0 100644 --- a/jdk/src/share/classes/javax/swing/SortingFocusTraversalPolicy.java +++ b/jdk/src/share/classes/javax/swing/SortingFocusTraversalPolicy.java @@ -444,11 +444,10 @@ public class SortingFocusTraversalPolicy for (Component comp : cycle) { if (accept(comp)) { return comp; - } else if (comp instanceof Container && comp != aContainer) { - Container cont = (Container)comp; - if (cont.isFocusTraversalPolicyProvider()) { - return cont.getFocusTraversalPolicy().getDefaultComponent(cont); - } + } else if (comp != aContainer && + (comp = getComponentDownCycle(comp, FORWARD_TRAVERSAL)) != null) + { + return comp; } } return null; diff --git a/jdk/test/java/awt/Focus/FocusTraversalPolicy/DefaultFTPTest.java b/jdk/test/java/awt/Focus/FocusTraversalPolicy/DefaultFTPTest.java index 6ad3b1af9d0..b7c91667ae8 100644 --- a/jdk/test/java/awt/Focus/FocusTraversalPolicy/DefaultFTPTest.java +++ b/jdk/test/java/awt/Focus/FocusTraversalPolicy/DefaultFTPTest.java @@ -104,7 +104,7 @@ comp[unfocusable] - is set unfocusable. */ public class DefaultFTPTest { - final int TESTS_NUMBER = 10; + final int TESTS_NUMBER = 11; public static void main(String[] args) { DefaultFTPTest app = new DefaultFTPTest(); @@ -928,3 +928,63 @@ class PolicyTest10 extends AbstractPolicyTest { } } } + +/* + * frame [ container(root) [...] comp ] + * - getDefaultComponent() should implicitly down-cycle into the . + * - getFirstComponent() should implicitly down-cycle into the . + */ +class PolicyTest11 extends AbstractPolicyTest { + protected Frame createFrame() { + Frame frame = (Frame) registerComponent("frame", new Frame("Test Frame")); + frame.setLayout(new FlowLayout()); + + Container cont = (Container)registerComponent("panel", new Panel()); + cont.add(registerComponent("btn-1", new Button("button"))); + cont.add(registerComponent("btn-2", new Button("button"))); + + frame.add(cont); + frame.add(registerComponent("btn-3", new Button("button"))); + + return frame; + } + + protected void customizeHierarchy() { + ((Container)getComponent("frame")).setFocusTraversalPolicy(new DefaultFocusTraversalPolicy()); + ((Container)getComponent("panel")).setFocusCycleRoot(true); + } + + protected Map getForwardOrder() { + Map order = new HashMap(); + order.put("frame", "btn-1"); + order.put("btn-1", "btn-2"); + order.put("btn-2", "btn-1"); + order.put("btn-3", "btn-1"); + return order; + } + + protected Map getBackwardOrder() { + Map order = new HashMap(); + order.put("btn-3", "btn-1"); + order.put("btn-2", "btn-1"); + order.put("btn-1", "btn-2"); + order.put("frame", "btn-3"); + return order; + } + + protected String[] getContainersToTest() { + return new String[] {"frame"}; + } + + protected String getDefaultComp(String focusCycleRoot_id) { + return "btn-1"; + } + + protected String getFirstComp(String focusCycleRoot_id) { + return "btn-1"; + } + + protected String getLastComp(String focusCycleRoot_id) { + return "btn-3"; + } +} diff --git a/jdk/test/java/awt/Focus/FocusTraversalPolicy/LayoutFTPTest.java b/jdk/test/java/awt/Focus/FocusTraversalPolicy/LayoutFTPTest.java index 329845c2ac6..12ef3c2789c 100644 --- a/jdk/test/java/awt/Focus/FocusTraversalPolicy/LayoutFTPTest.java +++ b/jdk/test/java/awt/Focus/FocusTraversalPolicy/LayoutFTPTest.java @@ -105,7 +105,7 @@ comp[unfocusable] - is set unfocusable. */ public class LayoutFTPTest { - final int TESTS_NUMBER = 10; + final int TESTS_NUMBER = 11; public static void main(String[] args) { LayoutFTPTest app = new LayoutFTPTest(); @@ -929,3 +929,63 @@ class PolicyTest10 extends AbstractPolicyTest { } } } + +/* + * frame [ container(root) [...] comp ] + * - getDefaultComponent() should implicitly down-cycle into the . + * - getFirstComponent() should implicitly down-cycle into the . + */ +class PolicyTest11 extends AbstractPolicyTest { + protected Frame createFrame() { + JFrame jframe = (JFrame) registerComponent("jframe", new JFrame("Test Frame")); + jframe.setLayout(new FlowLayout()); + + Container cont = (Container)registerComponent("jpanel", new JPanel()); + cont.add(registerComponent("btn-1", new JButton("jbutton"))); + cont.add(registerComponent("btn-2", new JButton("jbutton"))); + + jframe.add(cont); + jframe.add(registerComponent("btn-3", new JButton("jbutton"))); + + return jframe; + } + + protected void customizeHierarchy() { + ((Container)getComponent("jframe")).setFocusTraversalPolicy(new LayoutFocusTraversalPolicy()); + ((Container)getComponent("jpanel")).setFocusCycleRoot(true); + } + + protected Map getForwardOrder() { + Map order = new HashMap(); + order.put("jframe", "btn-1"); + order.put("btn-1", "btn-2"); + order.put("btn-2", "btn-1"); + order.put("btn-3", "btn-1"); + return order; + } + + protected Map getBackwardOrder() { + Map order = new HashMap(); + order.put("btn-3", "btn-1"); + order.put("btn-2", "btn-1"); + order.put("btn-1", "btn-2"); + order.put("jframe", "btn-3"); + return order; + } + + protected String[] getContainersToTest() { + return new String[] {"jframe"}; + } + + protected String getDefaultComp(String focusCycleRoot_id) { + return "btn-1"; + } + + protected String getFirstComp(String focusCycleRoot_id) { + return "btn-1"; + } + + protected String getLastComp(String focusCycleRoot_id) { + return "btn-3"; + } +} From 5cd182518e09fb3a5c6d558e63fb3a52c9e3dc91 Mon Sep 17 00:00:00 2001 From: Lillian Angel Date: Fri, 19 Jun 2009 16:49:50 -0400 Subject: [PATCH 02/23] 6721086: Toolkit beep does not work consistently Flush out after bell is sounded Reviewed-by: anthony --- jdk/src/solaris/classes/sun/awt/X11/XToolkit.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java index 1739e6724f1..01d982dff7a 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java @@ -1177,6 +1177,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable { awtLock(); try { XlibWrapper.XBell(getDisplay(), 0); + XlibWrapper.XFlush(getDisplay()); } finally { awtUnlock(); } From 3006b1fcd0eae804e2219bb9d5523f2521e519b1 Mon Sep 17 00:00:00 2001 From: Peter Zhelezniakov Date: Mon, 22 Jun 2009 18:08:50 +0400 Subject: [PATCH 03/23] 6849277: Nimbus L&F: lots of painter classes were added to JDK7 as public Reviewed-by: malenkov --- jdk/src/share/classes/javax/swing/plaf/nimbus/Defaults.template | 2 +- .../share/classes/javax/swing/plaf/nimbus/PainterImpl.template | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/share/classes/javax/swing/plaf/nimbus/Defaults.template b/jdk/src/share/classes/javax/swing/plaf/nimbus/Defaults.template index a0f5afc22c8..492b53583ed 100644 --- a/jdk/src/share/classes/javax/swing/plaf/nimbus/Defaults.template +++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/Defaults.template @@ -278,7 +278,7 @@ ${UI_DEFAULT_INIT} * offset (if any), and whether it is to be bold, italic, or left in its * default form.

*/ - public static final class DerivedFont implements UIDefaults.ActiveValue { + static final class DerivedFont implements UIDefaults.ActiveValue { private float sizeOffset; private Boolean bold; private Boolean italic; diff --git a/jdk/src/share/classes/javax/swing/plaf/nimbus/PainterImpl.template b/jdk/src/share/classes/javax/swing/plaf/nimbus/PainterImpl.template index 2afa0005b08..cad178ef7e6 100644 --- a/jdk/src/share/classes/javax/swing/plaf/nimbus/PainterImpl.template +++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/PainterImpl.template @@ -31,7 +31,7 @@ import javax.swing.*; import javax.swing.Painter; -public final class ${PAINTER_NAME} extends AbstractRegionPainter { +final class ${PAINTER_NAME} extends AbstractRegionPainter { //package private integers representing the available states that //this painter will paint. These are used when creating a new instance //of ${PAINTER_NAME} to determine which region/state is being painted From beedf39dcee36c5852e1647cd5b717531b0f380f Mon Sep 17 00:00:00 2001 From: Peter Zhelezniakov Date: Tue, 23 Jun 2009 12:24:11 +0400 Subject: [PATCH 04/23] 6844273: jdk/make/docs/CORE_PKGS.gmk does not list Nimbus Reviewed-by: prr --- jdk/make/docs/CORE_PKGS.gmk | 1 + jdk/src/share/classes/javax/swing/plaf/nimbus/package.html | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/jdk/make/docs/CORE_PKGS.gmk b/jdk/make/docs/CORE_PKGS.gmk index 43a380ef836..3694985b1ed 100644 --- a/jdk/make/docs/CORE_PKGS.gmk +++ b/jdk/make/docs/CORE_PKGS.gmk @@ -217,6 +217,7 @@ CORE_PKGS = \ javax.swing.plaf.basic \ javax.swing.plaf.metal \ javax.swing.plaf.multi \ + javax.swing.plaf.nimbus \ javax.swing.plaf.synth \ javax.tools \ javax.transaction \ diff --git a/jdk/src/share/classes/javax/swing/plaf/nimbus/package.html b/jdk/src/share/classes/javax/swing/plaf/nimbus/package.html index bd3a0f4f4f1..4453cc163fe 100644 --- a/jdk/src/share/classes/javax/swing/plaf/nimbus/package.html +++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/package.html @@ -38,7 +38,7 @@ background {@code Painter}, and there may be several painters for different component states.

Nimbus allows customizing many of its properties, including painters, by -altering the {@link UIDefaults} table. Here's an example: +altering the {@link javax.swing.UIDefaults} table. Here's an example:

     UIManager.put("ProgressBar.tileWidth", myTileWidth);
     UIManager.put("ProgressBar[Enabled].backgroundPainter", myBgPainter);

From 2e78b95300dddd20272d383e7f0eb635ac4ac8b6 Mon Sep 17 00:00:00 2001
From: Dmitry Cherepanov 
Date: Tue, 23 Jun 2009 13:35:58 +0400
Subject: [PATCH 05/23] 6824169: Need to remove some AWT class dependencies

Reviewed-by: art, anthony, igor, alexp
---
 jdk/src/share/classes/java/awt/AWTEvent.java  |   7 +
 jdk/src/share/classes/java/awt/Component.java |  36 ++--
 jdk/src/share/classes/java/awt/Dialog.java    |   6 -
 .../share/classes/java/awt/EventQueue.java    |  13 ++
 .../share/classes/java/awt/MenuComponent.java |  17 ++
 jdk/src/share/classes/java/awt/PopupMenu.java |  10 +
 jdk/src/share/classes/java/awt/Window.java    |   6 +-
 .../swing/BufferStrategyPaintManager.java     |   8 +-
 .../classes/javax/swing/JLayeredPane.java     |  10 +-
 .../swing/LayoutFocusTraversalPolicy.java     |   5 +-
 .../classes/javax/swing/LookAndFeel.java      |   3 +-
 .../classes/javax/swing/TransferHandler.java  |  36 +---
 .../share/classes/javax/swing/UIManager.java  |  19 +-
 .../javax/swing/text/JTextComponent.java      |  18 ++
 .../share/classes/sun/awt/AWTAccessor.java    | 148 ++++++++++++++-
 jdk/src/share/classes/sun/awt/SunToolkit.java | 178 +++++++-----------
 .../classes/sun/awt/shell/ShellFolder.java    |  12 +-
 .../classes/sun/swing/AccessibleMethod.java   | 136 -------------
 .../classes/sun/swing/SwingAccessor.java      |  96 ++++++++++
 .../solaris/classes/sun/awt/X11/XToolkit.java |  11 +-
 .../sun/awt/windows/WComponentPeer.java       |  23 ++-
 .../sun/awt/windows/WEmbeddedFrame.java       |   7 +-
 .../sun/awt/windows/WFileDialogPeer.java      |   7 +
 .../sun/awt/windows/WPopupMenuPeer.java       |  28 +--
 .../sun/awt/windows/WPrintDialogPeer.java     |   7 +
 .../java2d/windows/GDIWindowSurfaceData.java  |  14 +-
 26 files changed, 469 insertions(+), 392 deletions(-)
 delete mode 100644 jdk/src/share/classes/sun/swing/AccessibleMethod.java
 create mode 100644 jdk/src/share/classes/sun/swing/SwingAccessor.java

diff --git a/jdk/src/share/classes/java/awt/AWTEvent.java b/jdk/src/share/classes/java/awt/AWTEvent.java
index 768e424643b..3fa01136db8 100644
--- a/jdk/src/share/classes/java/awt/AWTEvent.java
+++ b/jdk/src/share/classes/java/awt/AWTEvent.java
@@ -32,6 +32,7 @@ import java.awt.peer.LightweightPeer;
 import java.lang.reflect.Field;
 import java.util.logging.Logger;
 import java.util.logging.Level;
+import sun.awt.AWTAccessor;
 
 /**
  * The root event class for all AWT events.
@@ -230,6 +231,12 @@ public abstract class AWTEvent extends EventObject {
         if (!GraphicsEnvironment.isHeadless()) {
             initIDs();
         }
+        AWTAccessor.setAWTEventAccessor(
+            new AWTAccessor.AWTEventAccessor() {
+                public void setPosted(AWTEvent ev) {
+                    ev.isPosted = true;
+                }
+            });
     }
 
     private static synchronized Field get_InputEvent_CanAccessSystemClipboard() {
diff --git a/jdk/src/share/classes/java/awt/Component.java b/jdk/src/share/classes/java/awt/Component.java
index 06938ad0115..e07fbe7c5c7 100644
--- a/jdk/src/share/classes/java/awt/Component.java
+++ b/jdk/src/share/classes/java/awt/Component.java
@@ -861,6 +861,17 @@ public abstract class Component implements ImageObserver, MenuContainer,
             public boolean isVisible_NoClientCode(Component comp) {
                 return comp.isVisible_NoClientCode();
             }
+            public void setRequestFocusController
+                (RequestFocusController requestController)
+            {
+                 Component.setRequestFocusController(requestController);
+            }
+            public AppContext getAppContext(Component comp) {
+                 return comp.appContext;
+            }
+            public void setAppContext(Component comp, AppContext appContext) {
+                 comp.appContext = appContext;
+            }
         });
     }
 
@@ -9824,31 +9835,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
 
     // ****************** END OF MIXING CODE ********************************
 
-    private static boolean doesClassImplement(Class cls, String interfaceName) {
-        if (cls == null) return false;
-
-        for (Class c : cls.getInterfaces()) {
-            if (c.getName().equals(interfaceName)) {
-                return true;
-            }
-        }
-        return doesClassImplement(cls.getSuperclass(), interfaceName);
-    }
-
-    /**
-     * Checks that the given object implements the given interface.
-     * @param obj Object to be checked
-     * @param interfaceName The name of the interface. Must be fully-qualified interface name.
-     * @return true, if this object implements the given interface,
-     *         false, otherwise, or if obj or interfaceName is null
-     */
-    static boolean doesImplement(Object obj, String interfaceName) {
-        if (obj == null) return false;
-        if (interfaceName == null) return false;
-
-        return doesClassImplement(obj.getClass(), interfaceName);
-    }
-
     // Note that the method is overriden in the Window class,
     // a window doesn't need to be updated in the Z-order.
     void updateZOrder() {
diff --git a/jdk/src/share/classes/java/awt/Dialog.java b/jdk/src/share/classes/java/awt/Dialog.java
index a67d94a32ae..4660e6ea07c 100644
--- a/jdk/src/share/classes/java/awt/Dialog.java
+++ b/jdk/src/share/classes/java/awt/Dialog.java
@@ -262,12 +262,6 @@ public class Dialog extends Window {
         TOOLKIT_EXCLUDE
     };
 
-    /**
-     * @since 1.6
-     */
-    private final static ModalExclusionType DEFAULT_MODAL_EXCLUSION_TYPE =
-        ModalExclusionType.APPLICATION_EXCLUDE;
-
     /* operations with this list should be synchronized on tree lock*/
     transient static IdentityArrayList modalDialogs = new IdentityArrayList();
 
diff --git a/jdk/src/share/classes/java/awt/EventQueue.java b/jdk/src/share/classes/java/awt/EventQueue.java
index 9697ad5e9f5..45230515330 100644
--- a/jdk/src/share/classes/java/awt/EventQueue.java
+++ b/jdk/src/share/classes/java/awt/EventQueue.java
@@ -43,6 +43,7 @@ import sun.awt.AWTAutoShutdown;
 import sun.awt.PeerEvent;
 import sun.awt.SunToolkit;
 import sun.awt.EventQueueItem;
+import sun.awt.AWTAccessor;
 
 /**
  * EventQueue is a platform-independent class
@@ -154,6 +155,18 @@ public class EventQueue {
 
     private static final Logger eventLog = Logger.getLogger("java.awt.event.EventQueue");
 
+    static {
+        AWTAccessor.setEventQueueAccessor(
+            new AWTAccessor.EventQueueAccessor() {
+                public EventQueue getNextQueue(EventQueue eventQueue) {
+                    return eventQueue.nextQueue;
+                }
+                public Thread getDispatchThread(EventQueue eventQueue) {
+                    return eventQueue.dispatchThread;
+                }
+            });
+    }
+
     public EventQueue() {
         for (int i = 0; i < NUM_PRIORITIES; i++) {
             queues[i] = new Queue();
diff --git a/jdk/src/share/classes/java/awt/MenuComponent.java b/jdk/src/share/classes/java/awt/MenuComponent.java
index 1acb7f7c97e..88ee32d7ac3 100644
--- a/jdk/src/share/classes/java/awt/MenuComponent.java
+++ b/jdk/src/share/classes/java/awt/MenuComponent.java
@@ -30,6 +30,7 @@ import java.io.IOException;
 import java.io.ObjectInputStream;
 import sun.awt.AppContext;
 import sun.awt.SunToolkit;
+import sun.awt.AWTAccessor;
 import javax.accessibility.*;
 
 /**
@@ -109,6 +110,22 @@ public abstract class MenuComponent implements java.io.Serializable {
      */
     private static final long serialVersionUID = -4536902356223894379L;
 
+    static {
+        AWTAccessor.setMenuComponentAccessor(
+            new AWTAccessor.MenuComponentAccessor() {
+                public AppContext getAppContext(MenuComponent menuComp) {
+                    return menuComp.appContext;
+                }
+                public void setAppContext(MenuComponent menuComp,
+                                          AppContext appContext) {
+                    menuComp.appContext = appContext;
+                }
+                public MenuContainer getParent(MenuComponent menuComp) {
+                    return menuComp.parent;
+                }
+            });
+    }
+
     /**
      * Creates a MenuComponent.
      * @exception HeadlessException if
diff --git a/jdk/src/share/classes/java/awt/PopupMenu.java b/jdk/src/share/classes/java/awt/PopupMenu.java
index 64ebe75c2cc..752c271e9a6 100644
--- a/jdk/src/share/classes/java/awt/PopupMenu.java
+++ b/jdk/src/share/classes/java/awt/PopupMenu.java
@@ -28,6 +28,7 @@ package java.awt;
 import java.awt.peer.PopupMenuPeer;
 import javax.accessibility.*;
 
+import sun.awt.AWTAccessor;
 
 /**
  * A class that implements a menu which can be dynamically popped up
@@ -48,6 +49,15 @@ public class PopupMenu extends Menu {
 
     transient boolean isTrayIconPopup = false;
 
+    static {
+        AWTAccessor.setPopupMenuAccessor(
+            new AWTAccessor.PopupMenuAccessor() {
+                public boolean isTrayIconPopup(PopupMenu popupMenu) {
+                    return popupMenu.isTrayIconPopup;
+                }
+            });
+    }
+
     /*
      * JDK 1.1 serialVersionUID
      */
diff --git a/jdk/src/share/classes/java/awt/Window.java b/jdk/src/share/classes/java/awt/Window.java
index 3726b7bad42..aac5d3789da 100644
--- a/jdk/src/share/classes/java/awt/Window.java
+++ b/jdk/src/share/classes/java/awt/Window.java
@@ -3658,7 +3658,7 @@ public class Window extends Container implements Accessible {
     private static void setLayersOpaque(Component component, boolean isOpaque) {
         // Shouldn't use instanceof to avoid loading Swing classes
         //    if it's a pure AWT application.
-        if (Component.doesImplement(component, "javax.swing.RootPaneContainer")) {
+        if (SunToolkit.isInstanceOf(component, "javax.swing.RootPaneContainer")) {
             javax.swing.RootPaneContainer rpc = (javax.swing.RootPaneContainer)component;
             javax.swing.JRootPane root = rpc.getRootPane();
             javax.swing.JLayeredPane lp = root.getLayeredPane();
@@ -3797,6 +3797,10 @@ public class Window extends Container implements Accessible {
             {
                 return window.calculateSecurityWarningPosition(x, y, w, h);
             }
+
+            public void setLWRequestStatus(Window changed, boolean status) {
+                changed.syncLWRequests = status;
+            }
         }); // WindowAccessor
     } // static
 
diff --git a/jdk/src/share/classes/javax/swing/BufferStrategyPaintManager.java b/jdk/src/share/classes/javax/swing/BufferStrategyPaintManager.java
index 3c084afd17f..144ab897459 100644
--- a/jdk/src/share/classes/javax/swing/BufferStrategyPaintManager.java
+++ b/jdk/src/share/classes/javax/swing/BufferStrategyPaintManager.java
@@ -36,6 +36,7 @@ import java.util.logging.*;
 import sun.awt.SubRegionShowable;
 import sun.java2d.SunGraphics2D;
 import sun.security.action.GetPropertyAction;
+import sun.awt.SunToolkit;
 
 /**
  * A PaintManager implementation that uses a BufferStrategy for
@@ -579,8 +580,9 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
         rootJ = c;
         root = c;
         xOffset = yOffset = 0;
-        while (root != null && (!(root instanceof Window) &&
-                                !(root instanceof Applet))) {
+        while (root != null &&
+               (!(root instanceof Window) &&
+                !SunToolkit.isInstanceOf(root, "java.applet.Applet"))) {
             xOffset += root.getX();
             yOffset += root.getY();
             root = root.getParent();
@@ -853,7 +855,7 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
                     new ImageCapabilities(true),
                     type);
             BufferStrategy bs = null;
-            if (root instanceof Applet) {
+            if (SunToolkit.isInstanceOf(root, "java.applet.Applet")) {
                 try {
                     getCreateBufferStrategyMethod().invoke(root, 2, caps);
                     bs = (BufferStrategy)getGetBufferStrategyMethod().
diff --git a/jdk/src/share/classes/javax/swing/JLayeredPane.java b/jdk/src/share/classes/javax/swing/JLayeredPane.java
index 640ef3003f2..5fefb1ab67e 100644
--- a/jdk/src/share/classes/javax/swing/JLayeredPane.java
+++ b/jdk/src/share/classes/javax/swing/JLayeredPane.java
@@ -30,6 +30,7 @@ import java.util.Hashtable;
 import java.awt.Color;
 import java.awt.Graphics;
 import java.awt.Rectangle;
+import sun.awt.SunToolkit;
 
 import javax.accessibility.*;
 
@@ -195,9 +196,12 @@ public class JLayeredPane extends JComponent implements Accessible {
 
             for (Component c : getComponents()) {
                 layer = null;
-                if(c instanceof JInternalFrame || (c instanceof JComponent &&
-                         (layer = (Integer)((JComponent)c).getClientProperty(
-                          LAYER_PROPERTY)) != null)) {
+
+                if(SunToolkit.isInstanceOf(c, "javax.swing.JInternalFrame") ||
+                       (c instanceof JComponent &&
+                        (layer = (Integer)((JComponent)c).
+                                     getClientProperty(LAYER_PROPERTY)) != null))
+                {
                     if(layer != null && layer.equals(FRAME_CONTENT_LAYER))
                         continue;
                     layeredComponentFound = true;
diff --git a/jdk/src/share/classes/javax/swing/LayoutFocusTraversalPolicy.java b/jdk/src/share/classes/javax/swing/LayoutFocusTraversalPolicy.java
index 3515beb05c6..4903a3b0769 100644
--- a/jdk/src/share/classes/javax/swing/LayoutFocusTraversalPolicy.java
+++ b/jdk/src/share/classes/javax/swing/LayoutFocusTraversalPolicy.java
@@ -29,6 +29,7 @@ import java.awt.Container;
 import java.awt.ComponentOrientation;
 import java.util.Comparator;
 import java.io.*;
+import sun.awt.SunToolkit;
 
 
 /**
@@ -226,11 +227,11 @@ public class LayoutFocusTraversalPolicy extends SortingFocusTraversalPolicy
      protected boolean accept(Component aComponent) {
         if (!super.accept(aComponent)) {
             return false;
-        } else if (aComponent instanceof JTable) {
+        } else if (SunToolkit.isInstanceOf(aComponent, "javax.swing.JTable")) {
             // JTable only has ancestor focus bindings, we thus force it
             // to be focusable by returning true here.
             return true;
-        } else if (aComponent instanceof JComboBox) {
+        } else if (SunToolkit.isInstanceOf(aComponent, "javax.swing.JComboBox")) {
             JComboBox box = (JComboBox)aComponent;
             return box.getUI().isFocusTraversable(box);
         } else if (aComponent instanceof JComponent) {
diff --git a/jdk/src/share/classes/javax/swing/LookAndFeel.java b/jdk/src/share/classes/javax/swing/LookAndFeel.java
index 5f195256a07..6b6e5ba43b7 100644
--- a/jdk/src/share/classes/javax/swing/LookAndFeel.java
+++ b/jdk/src/share/classes/javax/swing/LookAndFeel.java
@@ -32,6 +32,7 @@ import java.awt.Color;
 import java.awt.Component;
 import java.awt.SystemColor;
 import java.awt.Toolkit;
+import sun.awt.SunToolkit;
 
 import javax.swing.text.*;
 import javax.swing.border.*;
@@ -271,7 +272,7 @@ public abstract class LookAndFeel
         // this is a special case because the JPasswordField's ancestor heirarchy
         // includes a class outside of javax.swing, thus we cannot call setUIProperty
         // directly.
-        if (c instanceof JPasswordField) {
+        if (SunToolkit.isInstanceOf(c, "javax.swing.JPasswordField")) {
             if (!((JPasswordField)c).customSetUIProperty(propertyName, propertyValue)) {
                 c.setUIProperty(propertyName, propertyValue);
             }
diff --git a/jdk/src/share/classes/javax/swing/TransferHandler.java b/jdk/src/share/classes/javax/swing/TransferHandler.java
index 7469d7cb5d9..cb1e2ccb907 100644
--- a/jdk/src/share/classes/javax/swing/TransferHandler.java
+++ b/jdk/src/share/classes/javax/swing/TransferHandler.java
@@ -40,6 +40,7 @@ import sun.reflect.misc.MethodUtil;
 import sun.swing.SwingUtilities2;
 import sun.awt.AppContext;
 import sun.swing.*;
+import sun.awt.SunToolkit;
 
 /**
  * This class is used to handle the transfer of a Transferable
@@ -283,19 +284,9 @@ public class TransferHandler implements Serializable {
                           ? ((DropTargetDragEvent)source).getLocation()
                           : ((DropTargetDropEvent)source).getLocation();
 
-            if (component instanceof JTextComponent) {
-                try {
-                    AccessibleMethod method
-                        = new AccessibleMethod(JTextComponent.class,
-                                               "dropLocationForPoint",
-                                               Point.class);
-
-                    dropLocation =
-                        (DropLocation)method.invokeNoChecked(component, p);
-                } catch (NoSuchMethodException e) {
-                    throw new AssertionError(
-                        "Couldn't locate method JTextComponent.dropLocationForPoint");
-                }
+            if (SunToolkit.isInstanceOf(component, "javax.swing.text.JTextComponent")) {
+                dropLocation = SwingAccessor.getJTextComponentAccessor().
+                                   dropLocationForPoint((JTextComponent)component, p);
             } else if (component instanceof JComponent) {
                 dropLocation = ((JComponent)component).dropLocationForPoint(p);
             }
@@ -1373,22 +1364,9 @@ public class TransferHandler implements Serializable {
                                         ? null
                                         : support.getDropLocation();
 
-            if (component instanceof JTextComponent) {
-                try {
-                    AccessibleMethod method =
-                        new AccessibleMethod(JTextComponent.class,
-                                             "setDropLocation",
-                                             DropLocation.class,
-                                             Object.class,
-                                             Boolean.TYPE);
-
-                    state =
-                        method.invokeNoChecked(component, dropLocation,
-                                               state, forDrop);
-                } catch (NoSuchMethodException e) {
-                    throw new AssertionError(
-                        "Couldn't locate method JTextComponet.setDropLocation");
-                }
+            if (SunToolkit.isInstanceOf(component, "javax.swing.text.JTextComponent")) {
+                state = SwingAccessor.getJTextComponentAccessor().
+                            setDropLocation((JTextComponent)component, dropLocation, state, forDrop);
             } else if (component instanceof JComponent) {
                 state = ((JComponent)component).setDropLocation(dropLocation, state, forDrop);
             }
diff --git a/jdk/src/share/classes/javax/swing/UIManager.java b/jdk/src/share/classes/javax/swing/UIManager.java
index 44388fe34d5..e4c7c7c687d 100644
--- a/jdk/src/share/classes/javax/swing/UIManager.java
+++ b/jdk/src/share/classes/javax/swing/UIManager.java
@@ -60,6 +60,7 @@ import sun.swing.SwingUtilities2;
 import java.lang.reflect.Method;
 import java.util.HashMap;
 import sun.awt.AppContext;
+import sun.awt.AWTAccessor;
 
 
 /**
@@ -1472,21 +1473,7 @@ public class UIManager implements Serializable
                         return false;
                     }
                 });
-        try {
-            Method setRequestFocusControllerM = java.security.AccessController.doPrivileged(
-                    new java.security.PrivilegedExceptionAction() {
-                        public Method run() throws Exception {
-                            Method method =
-                            Component.class.getDeclaredMethod("setRequestFocusController",
-                                                              sun.awt.RequestFocusController.class);
-                            method.setAccessible(true);
-                            return method;
-                        }
-                    });
-            setRequestFocusControllerM.invoke(null, JComponent.focusController);
-        } catch (Exception e) {
-            // perhaps we should log this
-            assert false;
-        }
+        AWTAccessor.getComponentAccessor().
+            setRequestFocusController(JComponent.focusController);
     }
 }
diff --git a/jdk/src/share/classes/javax/swing/text/JTextComponent.java b/jdk/src/share/classes/javax/swing/text/JTextComponent.java
index 679cd930468..fc24214a844 100644
--- a/jdk/src/share/classes/javax/swing/text/JTextComponent.java
+++ b/jdk/src/share/classes/javax/swing/text/JTextComponent.java
@@ -76,6 +76,7 @@ import sun.awt.AppContext;
 import sun.swing.PrintingStatus;
 import sun.swing.SwingUtilities2;
 import sun.swing.text.TextComponentPrintable;
+import sun.swing.SwingAccessor;
 
 /**
  * JTextComponent is the base class for swing text
@@ -761,6 +762,23 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
         return dropMode;
     }
 
+    static {
+        SwingAccessor.setJTextComponentAccessor(
+            new SwingAccessor.JTextComponentAccessor() {
+                public TransferHandler.DropLocation dropLocationForPoint(JTextComponent textComp,
+                                                                         Point p)
+                {
+                    return textComp.dropLocationForPoint(p);
+                }
+                public Object setDropLocation(JTextComponent textComp,
+                                              TransferHandler.DropLocation location,
+                                              Object state, boolean forDrop)
+                {
+                    return textComp.setDropLocation(location, state, forDrop);
+                }
+            });
+    }
+
 
     /**
      * Calculates a drop location in this component, representing where a
diff --git a/jdk/src/share/classes/sun/awt/AWTAccessor.java b/jdk/src/share/classes/sun/awt/AWTAccessor.java
index f952dbec85a..e427b892517 100644
--- a/jdk/src/share/classes/sun/awt/AWTAccessor.java
+++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java
@@ -30,6 +30,7 @@ import java.awt.geom.Point2D;
 import java.awt.image.BufferedImage;
 
 import sun.misc.Unsafe;
+import java.awt.peer.ComponentPeer;
 
 /**
  * The AWTAccessor utility class.
@@ -98,6 +99,21 @@ public final class AWTAccessor {
          * any client code.
          */
         boolean isVisible_NoClientCode(Component comp);
+
+        /**
+         * Sets the RequestFocusController.
+         */
+        void setRequestFocusController(RequestFocusController requestController);
+
+        /**
+         * Returns the appContext of the component.
+         */
+        AppContext getAppContext(Component comp);
+
+        /**
+         * Sets the appContext of the component.
+         */
+        void setAppContext(Component comp, AppContext appContext);
     }
 
     /*
@@ -153,23 +169,21 @@ public final class AWTAccessor {
          */
         Point2D calculateSecurityWarningPosition(Window window,
                 double x, double y, double w, double h);
+
+        /** Sets the synchronous status of focus requests on lightweight
+         * components in the specified window to the specified value.
+         */
+        void setLWRequestStatus(Window changed, boolean status);
     }
 
     /*
      * An accessor for the AWTEvent class.
      */
     public interface AWTEventAccessor {
-        /*
-         *
-         * Sets the flag on this AWTEvent indicating that it was
-         * generated by the system.
+        /**
+         * Marks the event as posted.
          */
-        void setSystemGenerated(AWTEvent ev);
-        /*
-         *
-         * Indicates whether this AWTEvent was generated by the system.
-         */
-        boolean isSystemGenerated(AWTEvent ev);
+        void setPosted(AWTEvent ev);
     }
 
     /*
@@ -215,6 +229,51 @@ public final class AWTAccessor {
         void removeLastFocusRequest(Component heavyweight);
     }
 
+    /*
+     * An accessor for the MenuComponent class.
+     */
+    public interface MenuComponentAccessor {
+        /**
+         * Returns the appContext of the menu component.
+         */
+        AppContext getAppContext(MenuComponent menuComp);
+
+        /**
+         * Sets the appContext of the menu component.
+         */
+        void setAppContext(MenuComponent menuComp, AppContext appContext);
+
+        /**
+         * Returns the menu container of the menu component
+         */
+        MenuContainer getParent(MenuComponent menuComp);
+    }
+
+    /*
+     * An accessor for the EventQueue class
+     */
+    public interface EventQueueAccessor {
+        /*
+         * Gets the next event queue.
+         */
+        EventQueue getNextQueue(EventQueue eventQueue);
+        /*
+         * Gets the event dispatch thread.
+         */
+        Thread getDispatchThread(EventQueue eventQueue);
+    }
+
+    /*
+     * An accessor for the PopupMenu class
+     */
+    public interface PopupMenuAccessor {
+        /*
+         * Returns whether the popup menu is attached to a tray
+         */
+        boolean isTrayIconPopup(PopupMenu popupMenu);
+    }
+
+
     /*
      * The java.awt.Component class accessor object.
      */
@@ -240,6 +299,21 @@ public final class AWTAccessor {
      */
     private static KeyboardFocusManagerAccessor kfmAccessor;
 
+    /*
+     * The java.awt.MenuComponent class accessor object.
+     */
+    private static MenuComponentAccessor menuComponentAccessor;
+
+    /*
+     * The java.awt.EventQueue class accessor object.
+     */
+    private static EventQueueAccessor eventQueueAccessor;
+
+    /*
+     * The java.awt.PopupMenu class accessor object.
+     */
+    private static PopupMenuAccessor popupMenuAccessor;
+
     /*
      * Set an accessor object for the java.awt.Component class.
      */
@@ -286,6 +360,9 @@ public final class AWTAccessor {
      * Retrieve the accessor object for the java.awt.AWTEvent class.
      */
     public static AWTEventAccessor getAWTEventAccessor() {
+        if (awtEventAccessor == null) {
+            unsafe.ensureClassInitialized(AWTEvent.class);
+        }
         return awtEventAccessor;
     }
 
@@ -322,4 +399,55 @@ public final class AWTAccessor {
         }
         return kfmAccessor;
     }
+
+    /*
+     * Set an accessor object for the java.awt.MenuComponent class.
+     */
+    public static void setMenuComponentAccessor(MenuComponentAccessor mca) {
+        menuComponentAccessor = mca;
+    }
+
+    /*
+     * Retrieve the accessor object for the java.awt.MenuComponent class.
+     */
+    public static MenuComponentAccessor getMenuComponentAccessor() {
+        if (menuComponentAccessor == null) {
+            unsafe.ensureClassInitialized(MenuComponent.class);
+        }
+        return menuComponentAccessor;
+    }
+
+    /*
+     * Set an accessor object for the java.awt.EventQueue class.
+     */
+    public static void setEventQueueAccessor(EventQueueAccessor eqa) {
+        eventQueueAccessor = eqa;
+    }
+
+    /*
+     * Retrieve the accessor object for the java.awt.EventQueue class.
+     */
+    public static EventQueueAccessor getEventQueueAccessor() {
+        if (eventQueueAccessor == null) {
+            unsafe.ensureClassInitialized(EventQueue.class);
+        }
+        return eventQueueAccessor;
+    }
+
+    /*
+     * Set an accessor object for the java.awt.PopupMenu class.
+     */
+    public static void setPopupMenuAccessor(PopupMenuAccessor pma) {
+        popupMenuAccessor = pma;
+    }
+
+    /*
+     * Retrieve the accessor object for the java.awt.PopupMenu class.
+     */
+    public static PopupMenuAccessor getPopupMenuAccessor() {
+        if (popupMenuAccessor == null) {
+            unsafe.ensureClassInitialized(PopupMenu.class);
+        }
+        return popupMenuAccessor;
+    }
 }
diff --git a/jdk/src/share/classes/sun/awt/SunToolkit.java b/jdk/src/share/classes/sun/awt/SunToolkit.java
index fb554ef789f..7f0ac590fa0 100644
--- a/jdk/src/share/classes/sun/awt/SunToolkit.java
+++ b/jdk/src/share/classes/sun/awt/SunToolkit.java
@@ -77,14 +77,7 @@ public abstract class SunToolkit extends Toolkit
      */
     public static final int GRAB_EVENT_MASK = 0x80000000;
 
-    private static Field syncLWRequestsField;
     private static Method  wakeupMethod;
-    private static Field componentKeyField;
-    private static Field menuComponentKeyField;
-    private static Field trayIconKeyField;
-    private static Field componentAppContextField;
-    private static Field menuComponentAppContextField;
-    private static Field isPostedField;
     /* The key to put()/get() the PostEventQueue into/from the AppContext.
      */
     private static final String POST_EVENT_QUEUE_KEY = "PostEventQueue";
@@ -422,32 +415,21 @@ public abstract class SunToolkit extends Toolkit
     private static final Map appContextMap =
         Collections.synchronizedMap(new WeakHashMap());
 
-
     /**
      * Sets the appContext field of target. If target is not a Component or
      * MenuComponent, this returns false.
      */
-    private static boolean setAppContext(Object target, AppContext context)
-    {
-        if (!(target instanceof Component) && !(target instanceof MenuComponent)) {
+    private static boolean setAppContext(Object target,
+                                         AppContext context) {
+        if (target instanceof Component) {
+            AWTAccessor.getComponentAccessor().
+                setAppContext((Component)target, context);
+        } else if (target instanceof MenuComponent) {
+            AWTAccessor.getMenuComponentAccessor().
+                setAppContext((MenuComponent)target, context);
+        } else {
             return false;
         }
-        try{
-            if (target instanceof Component){
-                if (componentAppContextField == null) {
-                    componentAppContextField = getField(Component.class, "appContext");
-                }
-                componentAppContextField.set(target, context);
-            } else if (target instanceof MenuComponent) {
-                if (menuComponentAppContextField == null) {
-                    menuComponentAppContextField = getField(MenuComponent.class, "appContext");
-                }
-                menuComponentAppContextField.set(target, context);
-            }
-        } catch( IllegalAccessException e){
-            assert false;
-        }
-
         return true;
     }
 
@@ -456,23 +438,15 @@ public abstract class SunToolkit extends Toolkit
      * Component or MenuComponent this returns null.
      */
     private static AppContext getAppContext(Object target) {
-        AppContext retObj = null;
-        try{
-            if (target instanceof Component){
-                if (componentAppContextField == null) {
-                    componentAppContextField = getField(Component.class, "appContext");
-                }
-                retObj = (AppContext) componentAppContextField.get(target);
-            } else if (target instanceof MenuComponent) {
-                if (menuComponentAppContextField == null) {
-                    menuComponentAppContextField = getField(MenuComponent.class, "appContext");
-                }
-                retObj = (AppContext) menuComponentAppContextField.get(target);
-            }
-        } catch( IllegalAccessException e){
-            assert false;
+        if (target instanceof Component) {
+            return AWTAccessor.getComponentAccessor().
+                       getAppContext((Component)target);
+        } else if (target instanceof MenuComponent) {
+            return AWTAccessor.getMenuComponentAccessor().
+                       getAppContext((MenuComponent)target);
+        } else {
+            return null;
         }
-        return retObj;
     }
 
     /*
@@ -520,16 +494,7 @@ public abstract class SunToolkit extends Toolkit
       */
 
     public static void setLWRequestStatus(Window changed,boolean status){
-        if (syncLWRequestsField == null){
-            syncLWRequestsField = getField(Window.class, "syncLWRequests");
-        }
-        try{
-            if (syncLWRequestsField != null){
-                syncLWRequestsField.setBoolean(changed, status);
-            }
-        } catch( IllegalAccessException e){
-            assert false;
-        }
+        AWTAccessor.getWindowAccessor().setLWRequestStatus(changed, status);
     };
 
     public static void checkAndSetPolicy(Container cont, boolean isSwingCont)
@@ -637,18 +602,9 @@ public abstract class SunToolkit extends Toolkit
      * Post AWTEvent of high priority.
      */
     public static void postPriorityEvent(final AWTEvent e) {
-        if (isPostedField == null) {
-            isPostedField = getField(AWTEvent.class, "isPosted");
-        }
         PeerEvent pe = new PeerEvent(Toolkit.getDefaultToolkit(), new Runnable() {
                 public void run() {
-                    try {
-                        isPostedField.setBoolean(e, true);
-                    } catch (IllegalArgumentException e) {
-                        assert(false);
-                    } catch (IllegalAccessException e) {
-                        assert(false);
-                    }
+                    AWTAccessor.getAWTEventAccessor().setPosted(e);
                     ((Component)e.getSource()).dispatchEvent(e);
                 }
             }, PeerEvent.ULTIMATE_PRIORITY_EVENT);
@@ -756,36 +712,6 @@ public abstract class SunToolkit extends Toolkit
         }
     }
 
-    /*
-     * Returns next queue for the given EventQueue which has private access
-     */
-    private static EventQueue getNextQueue(final Object o) {
-        EventQueue result = null;
-        try{
-            Field nextQueueField = getField(EventQueue.class,
-                                            "nextQueue");
-            result = (EventQueue)nextQueueField.get(o);
-        } catch( IllegalAccessException e){
-            assert false;
-        }
-        return result;
-    }
-
-    /*
-     * Returns dispatch thread for the given EventQueue which has private access
-     */
-    private static Thread getDispatchThread(final Object o) {
-        Thread result = null;
-        try{
-            Field dispatchThreadField = getField(EventQueue.class,
-                                                 "dispatchThread");
-            result = (Thread)dispatchThreadField.get(o);
-        } catch( IllegalAccessException e){
-            assert false;
-        }
-        return result;
-    }
-
     /*
      * Returns true if the calling thread is the event dispatch thread
      * contained within AppContext which associated with the given target.
@@ -796,13 +722,14 @@ public abstract class SunToolkit extends Toolkit
         AppContext appContext = targetToAppContext(target);
         EventQueue eq = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
 
-        EventQueue next = getNextQueue(eq);
+        AWTAccessor.EventQueueAccessor accessor = AWTAccessor.getEventQueueAccessor();
+        EventQueue next = accessor.getNextQueue(eq);
         while (next != null) {
             eq = next;
-            next = getNextQueue(eq);
+            next = accessor.getNextQueue(eq);
         }
 
-        return (Thread.currentThread() == getDispatchThread(eq));
+        return (Thread.currentThread() == accessor.getDispatchThread(eq));
     }
 
     public Dimension getScreenSize() {
@@ -1356,22 +1283,7 @@ public abstract class SunToolkit extends Toolkit
         return false;
     }
 
-    private static Dialog.ModalExclusionType DEFAULT_MODAL_EXCLUSION_TYPE;
-
-    static {
-        DEFAULT_MODAL_EXCLUSION_TYPE = (Dialog.ModalExclusionType)AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                Dialog.ModalExclusionType defaultType = Dialog.ModalExclusionType.NO_EXCLUDE;
-                try {
-                    java.lang.reflect.Field f = Dialog.class.getDeclaredField("DEFAULT_MODAL_EXCLUSION_TYPE");
-                    f.setAccessible(true);
-                    defaultType = (Dialog.ModalExclusionType)f.get(null);
-                } catch (Exception e) {
-                }
-                return defaultType;
-            }
-        });
-    }
+    private static Dialog.ModalExclusionType DEFAULT_MODAL_EXCLUSION_TYPE = null;
 
     /**
      * Returns whether the XEmbed server feature is requested by
@@ -1430,6 +1342,9 @@ public abstract class SunToolkit extends Toolkit
      */
     public static void setModalExcluded(Window window)
     {
+        if (DEFAULT_MODAL_EXCLUSION_TYPE == null) {
+            DEFAULT_MODAL_EXCLUSION_TYPE = Dialog.ModalExclusionType.APPLICATION_EXCLUDE;
+        }
         window.setModalExclusionType(DEFAULT_MODAL_EXCLUSION_TYPE);
     }
 
@@ -1451,6 +1366,9 @@ public abstract class SunToolkit extends Toolkit
      */
     public static boolean isModalExcluded(Window window)
     {
+        if (DEFAULT_MODAL_EXCLUSION_TYPE == null) {
+            DEFAULT_MODAL_EXCLUSION_TYPE = Dialog.ModalExclusionType.APPLICATION_EXCLUDE;
+        }
         return window.getModalExclusionType().compareTo(DEFAULT_MODAL_EXCLUSION_TYPE) >= 0;
     }
 
@@ -2104,6 +2022,42 @@ public abstract class SunToolkit extends Toolkit
     public int getNumberOfButtons(){
         return 3;
     }
+
+    /**
+     * Checks that the given object implements/extends the given
+     * interface/class.
+     *
+     * Note that using the instanceof operator causes a class to be loaded.
+     * Using this method doesn't load a class and it can be used instead of
+     * the instanceof operator for performance reasons.
+     *
+     * @param obj Object to be checked
+     * @param type The name of the interface/class. Must be
+     * fully-qualified interface/class name.
+     * @return true, if this object implements/extends the given
+     *         interface/class, false, otherwise, or if obj or type is null
+     */
+    public static boolean isInstanceOf(Object obj, String type) {
+        if (obj == null) return false;
+        if (type == null) return false;
+
+        return isInstanceOf(obj.getClass(), type);
+    }
+
+    private static boolean isInstanceOf(Class cls, String type) {
+        if (cls == null) return false;
+
+        if (cls.getName().equals(type)) {
+            return true;
+        }
+
+        for (Class c : cls.getInterfaces()) {
+            if (c.getName().equals(type)) {
+                return true;
+            }
+        }
+        return isInstanceOf(cls.getSuperclass(), type);
+    }
 } // class SunToolkit
 
 
diff --git a/jdk/src/share/classes/sun/awt/shell/ShellFolder.java b/jdk/src/share/classes/sun/awt/shell/ShellFolder.java
index 965dd6f04aa..d38fd98e030 100644
--- a/jdk/src/share/classes/sun/awt/shell/ShellFolder.java
+++ b/jdk/src/share/classes/sun/awt/shell/ShellFolder.java
@@ -202,8 +202,16 @@ public abstract class ShellFolder extends File {
     private static ShellFolderManager shellFolderManager;
 
     static {
-        Class managerClass = (Class)Toolkit.getDefaultToolkit().
-            getDesktopProperty("Shell.shellFolderManager");
+        String managerClassName = (String)Toolkit.getDefaultToolkit().
+                                      getDesktopProperty("Shell.shellFolderManager");
+        Class managerClass = null;
+        try {
+            managerClass = Class.forName(managerClassName);
+        // swallow the exceptions below and use default shell folder
+        } catch(ClassNotFoundException e) {
+        } catch(NullPointerException e) {
+        }
+
         if (managerClass == null) {
             managerClass = ShellFolderManager.class;
         }
diff --git a/jdk/src/share/classes/sun/swing/AccessibleMethod.java b/jdk/src/share/classes/sun/swing/AccessibleMethod.java
deleted file mode 100644
index 228808652b6..00000000000
--- a/jdk/src/share/classes/sun/swing/AccessibleMethod.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-package sun.swing;
-
-import java.security.*;
-import java.lang.reflect.*;
-
-/**
- * A utility for accessing and invoking methods, via reflection,
- * that would otherwise be unaccessible.
- *
- * @author Shannon Hickey
- */
-public class AccessibleMethod {
-
-    private final Method method;
-
-    /**
-     * Construct an instance for the given params.
-     *
-     * @param klass the class to which the method belongs
-     * @param methodName the name of the method
-     * @param paramTypes the paramater type array
-     * @throws NullPointerException if klass
-     *         or name is null
-     * @throws NoSuchMethodException if the method can't be found
-     */
-    public AccessibleMethod(Class klass,
-                            String methodName,
-                            Class ... paramTypes) throws NoSuchMethodException {
-        try {
-            method = AccessController.doPrivileged(
-                new AccessMethodAction(klass, methodName, paramTypes));
-        } catch (PrivilegedActionException e) {
-            throw (NoSuchMethodException)e.getCause();
-        }
-    }
-
-    /**
-     * Invoke the method that this object represents.
-     * Has the same behavior and throws the same exceptions as
-     * java.lang.reflect.Method.invoke with one
-     * exception: This method does not throw
-     * IllegalAccessException since the target
-     * method has already been made accessible.
-     *
-     * @param obj the object the underlying method is invoked from
-     * @param args the arguments used for the method call
-     * @return the result of dispatching the method represented by
-     *         this object on obj with parameters
-     *         args
-     * @see java.lang.reflect.Method#invoke
-     */
-    public Object invoke(Object obj, Object ... args)
-            throws IllegalArgumentException, InvocationTargetException {
-
-        try {
-            return method.invoke(obj, args);
-        } catch (IllegalAccessException e) {
-            // should never happen since we've made it accessible
-            throw new AssertionError("accessible method inaccessible");
-        }
-    }
-
-    /**
-     * Invoke the method that this object represents, with the
-     * expectation that the method being called throws no
-     * checked exceptions.
-     * 

- * Simply calls this.invoke(obj, args) - * but catches any InvocationTargetException - * and returns the cause wrapped in a runtime exception. - * - * @param obj the object the underlying method is invoked from - * @param args the arguments used for the method call - * @return the result of dispatching the method represented by - * this object on obj with parameters - * args - * @see #invoke - */ - public Object invokeNoChecked(Object obj, Object ... args) { - try { - return invoke(obj, args); - } catch (InvocationTargetException ex) { - if (ex.getCause() instanceof RuntimeException) { - throw (RuntimeException)ex.getCause(); - } else { - throw new RuntimeException(ex.getCause()); - } - } - } - - /** The action used to fetch the method and make it accessible */ - private static class AccessMethodAction implements PrivilegedExceptionAction { - private final Class klass; - private final String methodName; - private final Class[] paramTypes; - - public AccessMethodAction(Class klass, - String methodName, - Class ... paramTypes) { - - this.klass = klass; - this.methodName = methodName; - this.paramTypes = paramTypes; - } - - public Method run() throws NoSuchMethodException { - Method method = klass.getDeclaredMethod(methodName, paramTypes); - method.setAccessible(true); - return method; - } - } -} diff --git a/jdk/src/share/classes/sun/swing/SwingAccessor.java b/jdk/src/share/classes/sun/swing/SwingAccessor.java new file mode 100644 index 00000000000..a6eefb0fb46 --- /dev/null +++ b/jdk/src/share/classes/sun/swing/SwingAccessor.java @@ -0,0 +1,96 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package sun.swing; + +import sun.misc.Unsafe; + +import java.awt.Point; + +import javax.swing.text.JTextComponent; +import javax.swing.TransferHandler; + +/** + * The SwingAccessor utility class. + * The main purpose of this class is to enable accessing + * private and package-private fields of classes from + * different classes/packages. See sun.misc.SharedSecretes + * for another example. + */ +public final class SwingAccessor { + private static final Unsafe unsafe = Unsafe.getUnsafe(); + + /** + * We don't need any objects of this class. + * It's rather a collection of static methods + * and interfaces. + */ + private SwingAccessor() { + } + + /** + * An accessor for the JTextComponent class. + * Note that we intentionally introduce the JTextComponentAccessor, + * and not the JComponentAccessor because the needed methods + * aren't override methods. + */ + public interface JTextComponentAccessor { + + /** + * Calculates a custom drop location for the text component, + * representing where a drop at the given point should insert data. + */ + TransferHandler.DropLocation dropLocationForPoint(JTextComponent textComp, Point p); + + /** + * Called to set or clear the drop location during a DnD operation. + */ + Object setDropLocation(JTextComponent textComp, TransferHandler.DropLocation location, + Object state, boolean forDrop); + } + + /** + * The javax.swing.text.JTextComponent class accessor object. + */ + private static JTextComponentAccessor jtextComponentAccessor; + + /** + * Set an accessor object for the javax.swing.text.JTextComponent class. + */ + public static void setJTextComponentAccessor(JTextComponentAccessor jtca) { + jtextComponentAccessor = jtca; + } + + /** + * Retrieve the accessor object for the javax.swing.text.JTextComponent class. + */ + public static JTextComponentAccessor getJTextComponentAccessor() { + if (jtextComponentAccessor == null) { + unsafe.ensureClassInitialized(JTextComponent.class); + } + + return jtextComponentAccessor; + } +} diff --git a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java index 01d982dff7a..038f8534499 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java @@ -1436,9 +1436,14 @@ public final class XToolkit extends UNIXToolkit implements Runnable { return timeStamp; } protected void initializeDesktopProperties() { - desktopProperties.put("DnD.Autoscroll.initialDelay", Integer.valueOf(50)); - desktopProperties.put("DnD.Autoscroll.interval", Integer.valueOf(50)); - desktopProperties.put("DnD.Autoscroll.cursorHysteresis", Integer.valueOf(5)); + desktopProperties.put("DnD.Autoscroll.initialDelay", + Integer.valueOf(50)); + desktopProperties.put("DnD.Autoscroll.interval", + Integer.valueOf(50)); + desktopProperties.put("DnD.Autoscroll.cursorHysteresis", + Integer.valueOf(5)); + desktopProperties.put("Shell.shellFolderManager", + "sun.awt.shell.ShellFolderManager"); // Don't want to call getMultiClickTime() if we are headless if (!GraphicsEnvironment.isHeadless()) { desktopProperties.put("awt.multiClickInterval", diff --git a/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java b/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java index f2b70227379..04b3e99c26b 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java @@ -417,6 +417,15 @@ public abstract class WComponentPeer extends WObjectPeer replaceSurfaceData(this.numBackBuffers, this.backBufferCaps); } + public void createScreenSurface(boolean isResize) + { + Win32GraphicsConfig gc = (Win32GraphicsConfig)getGraphicsConfiguration(); + ScreenUpdateManager mgr = ScreenUpdateManager.getInstance(); + + surfaceData = mgr.createScreenSurface(gc, this, numBackBuffers, isResize); + } + + /** * Multi-buffer version of replaceSurfaceData. This version is called * by createBuffers(), which needs to acquire the same locks in the same @@ -434,13 +443,10 @@ public abstract class WComponentPeer extends WObjectPeer return; } numBackBuffers = newNumBackBuffers; - Win32GraphicsConfig gc = - (Win32GraphicsConfig)getGraphicsConfiguration(); ScreenUpdateManager mgr = ScreenUpdateManager.getInstance(); oldData = surfaceData; mgr.dropScreenSurface(oldData); - surfaceData = - mgr.createScreenSurface(gc, this, numBackBuffers, true); + createScreenSurface(true); if (oldData != null) { oldData.invalidate(); } @@ -449,6 +455,8 @@ public abstract class WComponentPeer extends WObjectPeer if (numBackBuffers > 0) { // set the caps first, they're used when creating the bb backBufferCaps = caps; + Win32GraphicsConfig gc = + (Win32GraphicsConfig)getGraphicsConfiguration(); backBuffer = gc.createBackBuffer(this); } else if (backBuffer != null) { backBufferCaps = null; @@ -711,11 +719,8 @@ public abstract class WComponentPeer extends WObjectPeer create(parentPeer); // fix for 5088782: check if window object is created successfully checkCreation(); - this.winGraphicsConfig = - (Win32GraphicsConfig)getGraphicsConfiguration(); - ScreenUpdateManager mgr = ScreenUpdateManager.getInstance(); - this.surfaceData = mgr.createScreenSurface(winGraphicsConfig, this, - numBackBuffers, false); + + createScreenSurface(false); initialize(); start(); // Initialize enable/disable state, turn on callbacks } diff --git a/jdk/src/windows/classes/sun/awt/windows/WEmbeddedFrame.java b/jdk/src/windows/classes/sun/awt/windows/WEmbeddedFrame.java index fffd5f8a771..0196753161b 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WEmbeddedFrame.java +++ b/jdk/src/windows/classes/sun/awt/windows/WEmbeddedFrame.java @@ -211,9 +211,10 @@ public class WEmbeddedFrame extends EmbeddedFrame { */ public void notifyModalBlocked(Dialog blocker, boolean blocked) { try { - notifyModalBlockedImpl((WEmbeddedFramePeer)ComponentAccessor.getPeer(this), - (WWindowPeer)ComponentAccessor.getPeer(blocker), - blocked); + ComponentPeer thisPeer = (ComponentPeer)WToolkit.targetToPeer(this); + ComponentPeer blockerPeer = (ComponentPeer)WToolkit.targetToPeer(blocker); + notifyModalBlockedImpl((WEmbeddedFramePeer)thisPeer, + (WWindowPeer)blockerPeer, blocked); } catch (Exception z) { z.printStackTrace(System.err); } diff --git a/jdk/src/windows/classes/sun/awt/windows/WFileDialogPeer.java b/jdk/src/windows/classes/sun/awt/windows/WFileDialogPeer.java index 979308ab545..9575b2475d6 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WFileDialogPeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WFileDialogPeer.java @@ -237,4 +237,11 @@ public class WFileDialogPeer extends WWindowPeer implements FileDialogPeer { public void setOpacity(float opacity) {} public void setOpaque(boolean isOpaque) {} public void updateWindow(java.awt.image.BufferedImage backBuffer) {} + + // the file/print dialogs are native dialogs and + // the native system does their own rendering + @Override + public void createScreenSurface(boolean isResize) {} + @Override + public void replaceSurfaceData() {} } diff --git a/jdk/src/windows/classes/sun/awt/windows/WPopupMenuPeer.java b/jdk/src/windows/classes/sun/awt/windows/WPopupMenuPeer.java index 71c0292fa2d..8b8da6e6367 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WPopupMenuPeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WPopupMenuPeer.java @@ -29,33 +29,25 @@ import java.awt.peer.*; import java.lang.reflect.Field; import sun.awt.SunToolkit; +import sun.awt.AWTAccessor; public class WPopupMenuPeer extends WMenuPeer implements PopupMenuPeer { // We can't use target.getParent() for TrayIcon popup // because this method should return null for the TrayIcon // popup regardless of that whether it has parent or not. - private static Field f_parent; - private static Field f_isTrayIconPopup; - - static { - f_parent = SunToolkit.getField(MenuComponent.class, "parent"); - f_isTrayIconPopup = SunToolkit.getField(PopupMenu.class, "isTrayIconPopup"); - } public WPopupMenuPeer(PopupMenu target) { this.target = target; MenuContainer parent = null; - boolean isTrayIconPopup = false; - try { - isTrayIconPopup = ((Boolean)f_isTrayIconPopup.get(target)).booleanValue(); - if (isTrayIconPopup) { - parent = (MenuContainer)f_parent.get(target); - } else { - parent = target.getParent(); - } - } catch (IllegalAccessException iae) { - iae.printStackTrace(); - return; + + // We can't use target.getParent() for TrayIcon popup + // because this method should return null for the TrayIcon + // popup regardless of that whether it has parent or not. + boolean isTrayIconPopup = AWTAccessor.getPopupMenuAccessor().isTrayIconPopup(target); + if (isTrayIconPopup) { + parent = AWTAccessor.getMenuComponentAccessor().getParent(target); + } else { + parent = target.getParent(); } if (parent instanceof Component) { diff --git a/jdk/src/windows/classes/sun/awt/windows/WPrintDialogPeer.java b/jdk/src/windows/classes/sun/awt/windows/WPrintDialogPeer.java index db1bedc9118..d4ec57302fa 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WPrintDialogPeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WPrintDialogPeer.java @@ -150,4 +150,11 @@ public class WPrintDialogPeer extends WWindowPeer implements DialogPeer { public void setOpacity(float opacity) {} public void setOpaque(boolean isOpaque) {} public void updateWindow(java.awt.image.BufferedImage backBuffer) {} + + // the file/print dialogs are native dialogs and + // the native system does their own rendering + @Override + public void createScreenSurface(boolean isResize) {} + @Override + public void replaceSurfaceData() {} } diff --git a/jdk/src/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java b/jdk/src/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java index 4d12fe680fc..e246a7fc63d 100644 --- a/jdk/src/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java +++ b/jdk/src/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java @@ -38,8 +38,6 @@ import sun.awt.SunHints; import sun.awt.Win32GraphicsConfig; import sun.awt.Win32GraphicsDevice; import sun.awt.windows.WComponentPeer; -import sun.awt.windows.WFileDialogPeer; -import sun.awt.windows.WPrintDialogPeer; import sun.java2d.ScreenUpdateManager; import sun.java2d.SunGraphics2D; import sun.java2d.SurfaceData; @@ -264,17 +262,7 @@ public class GDIWindowSurfaceData extends SurfaceData { this.graphicsConfig = (Win32GraphicsConfig) peer.getGraphicsConfiguration(); this.solidloops = graphicsConfig.getSolidLoops(sType); - if (peer instanceof WFileDialogPeer || - peer instanceof WPrintDialogPeer ) - { - // REMIND: Awful hack. The right fix for this problem - // would be for these type of Peers to not even use a - // GDIWindowSurfaceData object since they never do any - // rendering. Or they could actually implement the - // functionality needed in initOps. But this seems - // to work for now. See bug 4391928 for more info. - return; - } + Win32GraphicsDevice gd = (Win32GraphicsDevice)graphicsConfig.getDevice(); initOps(peer, depth, rMask, gMask, bMask, gd.getScreen()); From 0cadb2e0233e369ff4e9b9c36a3dd364f8c841a3 Mon Sep 17 00:00:00 2001 From: Dmitry Cherepanov Date: Tue, 23 Jun 2009 15:10:02 +0400 Subject: [PATCH 06/23] 6736247: Component.printAll Invalid local JNI handle Reviewed-by: anthony --- .../native/sun/windows/awt_Component.cpp | 12 +---- .../PrintAllXcheckJNI/PrintAllXcheckJNI.java | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 jdk/test/java/awt/Component/PrintAllXcheckJNI/PrintAllXcheckJNI.java diff --git a/jdk/src/windows/native/sun/windows/awt_Component.cpp b/jdk/src/windows/native/sun/windows/awt_Component.cpp index 3c20533de90..1da71d1fd4e 100644 --- a/jdk/src/windows/native/sun/windows/awt_Component.cpp +++ b/jdk/src/windows/native/sun/windows/awt_Component.cpp @@ -5975,17 +5975,7 @@ ret: env->DeleteGlobalRef(self); delete cpps; - - if (result != NULL) - { - jintArray resultGlobalRef = (jintArray)env->NewGlobalRef(result); - env->DeleteLocalRef(result); - return resultGlobalRef; - } - else - { - return NULL; - } + return result; // this reference is global } jboolean AwtComponent::_IsObscured(void *param) diff --git a/jdk/test/java/awt/Component/PrintAllXcheckJNI/PrintAllXcheckJNI.java b/jdk/test/java/awt/Component/PrintAllXcheckJNI/PrintAllXcheckJNI.java new file mode 100644 index 00000000000..d911a75d7c9 --- /dev/null +++ b/jdk/test/java/awt/Component/PrintAllXcheckJNI/PrintAllXcheckJNI.java @@ -0,0 +1,52 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + @test + @bug 6736247 + @summary Component.printAll Invalid local JNI handle + @author Dmitry Cherepanov: area=awt.component + @run main/othervm -Xcheck:jni PrintAllXcheckJNI +*/ + +import java.awt.*; +import java.awt.image.BufferedImage; + +public class PrintAllXcheckJNI +{ + public static void main(String []s) + { + Frame frame = new Frame(); + frame.setVisible(true); + + BufferedImage img = new BufferedImage(frame.getWidth(), + frame.getHeight(), + BufferedImage.TYPE_INT_RGB); + Graphics2D g = img.createGraphics(); + + frame.printAll(g); + + g.dispose(); + img.flush(); + } +} From 4fc4bb20aea08a7419ffb359c40fbd04149eff63 Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Tue, 23 Jun 2009 15:53:32 +0400 Subject: [PATCH 07/23] 6821291: assertion failure in awt_Frame.h Reviewed-by: dcherepanov, art --- .../windows/native/sun/windows/awt_Frame.cpp | 29 ++++++++++++------- .../windows/native/sun/windows/awt_Frame.h | 3 +- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/jdk/src/windows/native/sun/windows/awt_Frame.cpp b/jdk/src/windows/native/sun/windows/awt_Frame.cpp index 50f41d102ee..545b1b98175 100644 --- a/jdk/src/windows/native/sun/windows/awt_Frame.cpp +++ b/jdk/src/windows/native/sun/windows/awt_Frame.cpp @@ -381,19 +381,28 @@ LRESULT CALLBACK AwtFrame::ProxyWindowProc(HWND hwnd, UINT message, void AwtFrame::CreateProxyFocusOwner() { + if (AwtToolkit::IsMainThread()) { + AwtFrame::_CreateProxyFocusOwner((void *)this); + } else { + AwtToolkit::GetInstance().InvokeFunction(AwtFrame::_CreateProxyFocusOwner, (void *)this); + } +} + +void AwtFrame::_CreateProxyFocusOwner(void *param) +{ + DASSERT(AwtToolkit::IsMainThread()); DASSERT(m_proxyFocusOwner == NULL); - DASSERT(AwtToolkit::MainThread() == ::GetCurrentThreadId()); - m_proxyFocusOwner = ::CreateWindow(TEXT("STATIC"), - TEXT("ProxyFocusOwner"), - WS_CHILD, - 0, 0, 0, 0, GetHWnd(), NULL, - AwtToolkit::GetInstance(). - GetModuleHandle(), - NULL); - - m_proxyDefWindowProc = ComCtl32Util::GetInstance().SubclassHWND(m_proxyFocusOwner, ProxyWindowProc); + AwtFrame *f = (AwtFrame *)param; + f->m_proxyFocusOwner = ::CreateWindow(TEXT("STATIC"), + TEXT("ProxyFocusOwner"), + WS_CHILD, + 0, 0, 0, 0, f->GetHWnd(), NULL, + AwtToolkit::GetInstance(). + GetModuleHandle(), + NULL); + f->m_proxyDefWindowProc = ComCtl32Util::GetInstance().SubclassHWND(f->m_proxyFocusOwner, ProxyWindowProc); } void AwtFrame::DestroyProxyFocusOwner() diff --git a/jdk/src/windows/native/sun/windows/awt_Frame.h b/jdk/src/windows/native/sun/windows/awt_Frame.h index a5821329e6f..c5662deb2fa 100644 --- a/jdk/src/windows/native/sun/windows/awt_Frame.h +++ b/jdk/src/windows/native/sun/windows/awt_Frame.h @@ -117,7 +117,6 @@ public: INLINE BOOL IsUndecorated() { return m_isUndecorated; } INLINE HWND GetProxyFocusOwner() { - DASSERT(AwtToolkit::MainThread() == ::GetCurrentThreadId()); if (m_proxyFocusOwner == NULL) { CreateProxyFocusOwner(); } @@ -165,6 +164,8 @@ private: void CreateProxyFocusOwner(); void DestroyProxyFocusOwner(); + /* creates proxy focus owner, called on Toolkit thread */ + static void _CreateProxyFocusOwner(void *param); /* destroys proxy focus owner, called on Toolkit thread */ static void _DestroyProxyFocusOwner(void *param); From b751a27e27c6c216d444726451267d1c6ad0befc Mon Sep 17 00:00:00 2001 From: Anthony Petrov Date: Tue, 23 Jun 2009 16:10:19 +0400 Subject: [PATCH 08/23] 6851646: test/closed/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java can fail Added realSync() call. Made the test public. Reviewed-by: dcherepanov --- .../GridBagLayoutIpadXYTest.html | 43 +++++++++ .../GridBagLayoutIpadXYTest.java | 89 +++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 jdk/test/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.html create mode 100644 jdk/test/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java diff --git a/jdk/test/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.html b/jdk/test/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.html new file mode 100644 index 00000000000..639b87c1163 --- /dev/null +++ b/jdk/test/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.html @@ -0,0 +1,43 @@ + + + + + + + +

GridBagLayoutIpadXYTest
Bug ID: 5004032

+ +

This is an AUTOMATIC test, simply wait for completion

+ + + + + diff --git a/jdk/test/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java b/jdk/test/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java new file mode 100644 index 00000000000..86f9b2eaa35 --- /dev/null +++ b/jdk/test/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java @@ -0,0 +1,89 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + test + @bug 5004032 + @summary GridBagConstraints.ipad(x|y) defined in a new way + @author dav@sparc.spb.su area= + @run applet GridBagLayoutIpadXYTest.html +*/ + +import java.applet.Applet; +import java.awt.*; + +public class GridBagLayoutIpadXYTest extends Applet +{ + Frame frame = new Frame(); + TextField jtf = null; + final int customIpadx = 300; + final int customIpady = 40; + + public void init() + { + this.setLayout (new BorderLayout ()); + + String[] instructions = + { + "This is an AUTOMATIC test", + "simply wait until it is done" + }; + }//End init() + + public void start () + { + validate(); + frame.setLayout(new GridBagLayout()); + GridBagConstraints gc = new GridBagConstraints(); + Insets fieldInsets = new Insets(0,5,5,0); + + gc.anchor = gc.NORTH; + gc.fill = gc.HORIZONTAL; + gc.gridx = 1; + gc.gridy = 0; + gc.weightx = 1; + gc.ipadx = customIpadx; + gc.ipady = customIpady; + gc.insets = fieldInsets; + jtf = new TextField(); + frame.add(jtf, gc); + + frame.pack(); + frame.setVisible(true); + + ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync(); + + Dimension minSize = jtf.getMinimumSize(); + if ( minSize.width + customIpadx != jtf.getSize().width || + minSize.height + customIpady != jtf.getSize().height ){ + System.out.println("TextField originally has min size = " + jtf.getMinimumSize()); + System.out.println("TextField supplied with ipadx = 300, ipady =40"); + System.out.println("Frame size: " + frame.getSize()); + System.out.println(" Fields's size is "+jtf.getSize()); + + throw new RuntimeException("Test Failed. TextField has incorrect width. "); + } + System.out.println("Test Passed."); + + }// start() +} From c48e8ec7a631bf56f3292868a40f558229ebfab1 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Wed, 24 Jun 2009 13:59:54 +0400 Subject: [PATCH 09/23] 6852574: EnumPersistenceDelegate fails to persist instances with blocks Reviewed-by: peterz --- .../share/classes/java/beans/MetaData.java | 2 +- .../java/beans/XMLEncoder/Test6852574.java | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 jdk/test/java/beans/XMLEncoder/Test6852574.java diff --git a/jdk/src/share/classes/java/beans/MetaData.java b/jdk/src/share/classes/java/beans/MetaData.java index defd196457e..f4d307090a5 100644 --- a/jdk/src/share/classes/java/beans/MetaData.java +++ b/jdk/src/share/classes/java/beans/MetaData.java @@ -93,7 +93,7 @@ class EnumPersistenceDelegate extends PersistenceDelegate { protected Expression instantiate(Object oldInstance, Encoder out) { Enum e = (Enum) oldInstance; - return new Expression(e, Enum.class, "valueOf", new Object[]{e.getClass(), e.name()}); + return new Expression(e, Enum.class, "valueOf", new Object[]{e.getDeclaringClass(), e.name()}); } } diff --git a/jdk/test/java/beans/XMLEncoder/Test6852574.java b/jdk/test/java/beans/XMLEncoder/Test6852574.java new file mode 100644 index 00000000000..4b474ecb76c --- /dev/null +++ b/jdk/test/java/beans/XMLEncoder/Test6852574.java @@ -0,0 +1,58 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6852574 + * @summary Tests Enum subclass encoding + * @author Sergey Malenkov + */ + +public final class Test6852574 extends AbstractTest { + public static void main(String[] args) { + new Test6852574().test(true); + } + + protected Object getObject() { + return Data.FIRST; + } + + protected Object getAnotherObject() { + return Data.SECOND; + } + + public enum Data { + FIRST { + @Override + public String toString() { + return "1"; + } + }, + SECOND { + @Override + public String toString() { + return "2"; + } + } + } +} From eaf8bfc5f378dd0838646562ce4fb07407424201 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Wed, 24 Jun 2009 17:45:19 +0400 Subject: [PATCH 10/23] 6737700: api/javax_swing/table/DefaultTableCellRenderer/index.html#getset:DefaultTableCellRenderer Reviewed-by: alexp --- .../classes/javax/swing/table/DefaultTableCellRenderer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jdk/src/share/classes/javax/swing/table/DefaultTableCellRenderer.java b/jdk/src/share/classes/javax/swing/table/DefaultTableCellRenderer.java index c203178ce3a..07e7265c9bf 100644 --- a/jdk/src/share/classes/javax/swing/table/DefaultTableCellRenderer.java +++ b/jdk/src/share/classes/javax/swing/table/DefaultTableCellRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -118,12 +118,12 @@ public class DefaultTableCellRenderer extends JLabel if (System.getSecurityManager() != null) { if (border != null) return border; return SAFE_NO_FOCUS_BORDER; - } else { + } else if (border != null) { if (noFocusBorder == null || noFocusBorder == DEFAULT_NO_FOCUS_BORDER) { return border; } - return noFocusBorder; } + return noFocusBorder; } /** From f73952ec124850a93745f2996945ecb980a220a9 Mon Sep 17 00:00:00 2001 From: Yuka Kamiya Date: Thu, 25 Jun 2009 07:38:09 +0900 Subject: [PATCH 11/23] 6853792: test/java/text/Bidi/Bug6850113.java compilation error Reviewed-by: okutsu --- jdk/test/java/text/Bidi/Bug6850113.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/test/java/text/Bidi/Bug6850113.java b/jdk/test/java/text/Bidi/Bug6850113.java index 2023df89a58..d77f3c7798d 100644 --- a/jdk/test/java/text/Bidi/Bug6850113.java +++ b/jdk/test/java/text/Bidi/Bug6850113.java @@ -24,6 +24,7 @@ * @test * @bug 6850113 * @summary Verify the return value of digit() for some digits. + * @compile -XDignore.symbol.file=true Bug6850113.java */ import sun.text.normalizer.UCharacter; From 3876899a84546f504c2d635b456a8da9793b99ce Mon Sep 17 00:00:00 2001 From: Yuka Kamiya Date: Thu, 25 Jun 2009 17:37:28 +0900 Subject: [PATCH 12/23] 6609750: [Fmt-De] SimpleDateFormat.format() doesn't handle pattern "y" correctly Reviewed-by: okutsu --- .../classes/java/text/SimpleDateFormat.java | 4 +- .../text/Format/DateFormat/Bug6609750.java | 81 +++++++++++++++++++ 2 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 jdk/test/java/text/Format/DateFormat/Bug6609750.java diff --git a/jdk/src/share/classes/java/text/SimpleDateFormat.java b/jdk/src/share/classes/java/text/SimpleDateFormat.java index d7e99a943fe..1dfa42ea5f2 100644 --- a/jdk/src/share/classes/java/text/SimpleDateFormat.java +++ b/jdk/src/share/classes/java/text/SimpleDateFormat.java @@ -1030,9 +1030,9 @@ public class SimpleDateFormat extends DateFormat { case 1: // 'y' - YEAR if (calendar instanceof GregorianCalendar) { - if (count >= 4) + if (count != 2) zeroPaddingNumber(value, count, maxIntCount, buffer); - else // count < 4 + else // count == 2 zeroPaddingNumber(value, 2, 2, buffer); // clip 1996 to 96 } else { if (current == null) { diff --git a/jdk/test/java/text/Format/DateFormat/Bug6609750.java b/jdk/test/java/text/Format/DateFormat/Bug6609750.java new file mode 100644 index 00000000000..d1be2e843b1 --- /dev/null +++ b/jdk/test/java/text/Format/DateFormat/Bug6609750.java @@ -0,0 +1,81 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6609750 + * @summary Make sure that SimpleDateFormat.format() formats years correctly. + */ +import java.text.*; +import java.util.*; + +public class Bug6609750 { + + public static void main(String[] args) { + boolean error = false; + + Locale defaultLocale = Locale.getDefault(); + Locale.setDefault(Locale.US); + + Date[] dates = { + new Date(9-1900, Calendar.JUNE, 12), + new Date(99-1900, Calendar.JUNE, 12), + new Date(999-1900, Calendar.JUNE, 12), + new Date(2009-1900, Calendar.JUNE, 12), + new Date(30009-1900, Calendar.JUNE, 12), + }; + + String[] patterns = { + "y", "yy", "yyy", "yyyy", "yyyyy", "yyyyyy" + }; + String[][] expectedResults = { + {"9", "09", "009", "0009", "00009", "000009"}, + {"99", "99", "099", "0099", "00099", "000099"}, + {"999", "99", "999", "0999", "00999", "000999"}, + {"2009", "09", "2009", "2009", "02009", "002009"}, + {"30009", "09", "30009", "30009", "30009", "030009"}, + }; + + SimpleDateFormat sdf = new SimpleDateFormat(); + for (int dateNo = 0; dateNo < dates.length; dateNo++) { + Date date = dates[dateNo]; + for (int patternNo = 0; patternNo < patterns.length; patternNo++) { + sdf.applyPattern(patterns[patternNo]); + String got = sdf.format(date); + if (!expectedResults[dateNo][patternNo].equals(got)) { + error = true; + System.err.println("Failed: Unexpected format result: " + + "Expected: \"" + expectedResults[dateNo][patternNo] + + "\", Got: \"" + got + "\" for date " + date + + " with pattern \"" + patterns[patternNo] + "\""); + } + } + } + + Locale.setDefault(defaultLocale); + if (error) { + throw new RuntimeException("SimpleDateFormat.format() error."); + }; + } + +} From bbd33e6ddc179efbe5db3ffe4f18e88a7934ff07 Mon Sep 17 00:00:00 2001 From: Yuka Kamiya Date: Thu, 25 Jun 2009 21:55:39 +0900 Subject: [PATCH 13/23] 6792400: Avoid loading of Normalizer resources for simple uses Reviewed-by: okutsu --- .../sun/text/normalizer/NormalizerBase.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/classes/sun/text/normalizer/NormalizerBase.java b/jdk/src/share/classes/sun/text/normalizer/NormalizerBase.java index a82475c6009..b4df3e2a659 100644 --- a/jdk/src/share/classes/sun/text/normalizer/NormalizerBase.java +++ b/jdk/src/share/classes/sun/text/normalizer/NormalizerBase.java @@ -1598,15 +1598,34 @@ public final class NormalizerBase implements Cloneable { * @param options the optional features to be enabled. */ public static String normalize(String str, Normalizer.Form form, int options) { + int len = str.length(); + boolean asciiOnly = true; + if (len < 80) { + for (int i = 0; i < len; i++) { + if (str.charAt(i) > 127) { + asciiOnly = false; + break; + } + } + } else { + char[] a = str.toCharArray(); + for (int i = 0; i < len; i++) { + if (a[i] > 127) { + asciiOnly = false; + break; + } + } + } + switch (form) { case NFC : - return NFC.normalize(str, options); + return asciiOnly ? str : NFC.normalize(str, options); case NFD : - return NFD.normalize(str, options); + return asciiOnly ? str : NFD.normalize(str, options); case NFKC : - return NFKC.normalize(str, options); + return asciiOnly ? str : NFKC.normalize(str, options); case NFKD : - return NFKD.normalize(str, options); + return asciiOnly ? str : NFKD.normalize(str, options); } throw new IllegalArgumentException("Unexpected normalization form: " + From 3fcee8351e88455ba6bd796b59898239d1613a2d Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Thu, 25 Jun 2009 18:50:51 +0400 Subject: [PATCH 14/23] 6848364: javax/swing/border/Test4856008.java regression test fails due to BorderedComponent package not found Reviewed-by: alexp --- jdk/test/javax/swing/border/Test4856008.java | 22 +++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/jdk/test/javax/swing/border/Test4856008.java b/jdk/test/javax/swing/border/Test4856008.java index 1b045eb46ed..e2c1733c89d 100644 --- a/jdk/test/javax/swing/border/Test4856008.java +++ b/jdk/test/javax/swing/border/Test4856008.java @@ -35,6 +35,7 @@ import java.awt.Color; import java.awt.Font; import java.awt.Insets; +import javax.swing.ActionMap; import javax.swing.JComponent; import javax.swing.JFileChooser; import javax.swing.JLabel; @@ -51,6 +52,7 @@ import javax.swing.border.LineBorder; import javax.swing.border.MatteBorder; import javax.swing.border.SoftBevelBorder; import javax.swing.border.TitledBorder; +import javax.swing.plaf.ActionMapUIResource; import javax.swing.plaf.BorderUIResource; import javax.swing.plaf.synth.SynthLookAndFeel; import javax.swing.plaf.basic.BasicBorders; @@ -59,7 +61,6 @@ import javax.swing.plaf.metal.MetalBorders; import javax.swing.plaf.metal.MetalComboBoxEditor; import sun.swing.plaf.synth.SynthFileChooserUI; -import sun.tools.jconsole.BorderedComponent; public class Test4856008 { private static final JLabel LABEL = new JLabel(); @@ -133,11 +134,6 @@ public class Test4856008 { //+ SynthFileChooserUI.UIBorder: new SynthFileChooser().getUIBorder(), - - //+ BorderedComponent.FocusBorder: - getBorder(false), - //+ BorderedComponent.LabeledBorder: - getBorder(true), }; public static void main(String[] args) { @@ -182,15 +178,6 @@ public class Test4856008 { return LABEL; } - // This method is used to get the border from BorderedComponent - private static Border getBorder(boolean labeled) { - JComponent component = new BorderedComponent("4856008", null, true); - CompoundBorder border = (CompoundBorder) component.getBorder(); - return labeled - ? border.getInsideBorder() - : border.getOutsideBorder(); - } - // This class is used to get the instance of BasicBorders.RolloverMarginBorder private static class ToolBar extends BasicToolBarUI { private Border getRolloverMarginBorder() { @@ -223,6 +210,11 @@ public class Test4856008 { return CHOOSER.getBorder(); } + @Override + protected ActionMap createActionMap() { + return new ActionMapUIResource(); + } + @Override public String getFileName() { return this.name; From 433856b24dde70b09c526d1f4923189df1c2c747 Mon Sep 17 00:00:00 2001 From: Peter Zhelezniakov Date: Fri, 26 Jun 2009 08:09:19 +0400 Subject: [PATCH 15/23] 6827032: NIMBUS: Drag and drop throws a NPE in SwingSet2 ColorChooser Reviewed-by: malenkov --- .../classes/javax/swing/plaf/synth/SynthColorChooserUI.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java index 1a4e20fe57d..8a8dbf63220 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java @@ -69,6 +69,7 @@ class SynthColorChooserUI extends BasicColorChooserUI implements } protected void installDefaults() { + super.installDefaults(); updateStyle(chooser); } From c61b48b28b5d592b56ba2481243c4e1bd28dd125 Mon Sep 17 00:00:00 2001 From: Yuri Nesterenko Date: Fri, 26 Jun 2009 11:48:58 +0400 Subject: [PATCH 16/23] 6711676: Numpad keys trigger more than one KeyEvent Introduce a new sniffer based on server keymap. Reviewed-by: art --- jdk/make/sun/xawt/mapfile-vers | 1 + .../solaris/classes/sun/awt/X11/XKeysym.java | 4 +- .../solaris/classes/sun/awt/X11/XToolkit.java | 40 ++++++++----------- .../classes/sun/awt/X11/XlibWrapper.java | 1 + .../solaris/classes/sun/awt/X11/keysym2ucs.h | 4 +- jdk/src/solaris/native/sun/xawt/XlibWrapper.c | 32 +++++++++++++++ 6 files changed, 55 insertions(+), 27 deletions(-) diff --git a/jdk/make/sun/xawt/mapfile-vers b/jdk/make/sun/xawt/mapfile-vers index 87d274b5f2b..ce536f7a459 100644 --- a/jdk/make/sun/xawt/mapfile-vers +++ b/jdk/make/sun/xawt/mapfile-vers @@ -125,6 +125,7 @@ SUNWprivate_1.1 { Java_sun_awt_X11_XlibWrapper_XFree; Java_sun_awt_X11_XlibWrapper_ServerVendor; Java_sun_awt_X11_XlibWrapper_VendorRelease; + Java_sun_awt_X11_XlibWrapper_IsXsunKPBehavior; Java_sun_awt_X11_XlibWrapper_SetToolkitErrorHandler; Java_sun_awt_X11_XlibWrapper_XSetErrorHandler; Java_sun_awt_X11_XlibWrapper_CallErrorHandler; diff --git a/jdk/src/solaris/classes/sun/awt/X11/XKeysym.java b/jdk/src/solaris/classes/sun/awt/X11/XKeysym.java index 46137fbea96..ea39aeacc94 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XKeysym.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XKeysym.java @@ -145,7 +145,7 @@ public class XKeysym { { // Xsun without XKB uses keysymarray[2] keysym to determine if it is KP event. // Otherwise, it is [1]. - int ndx = XToolkit.isXsunServer() && + int ndx = XToolkit.isXsunKPBehavior() && ! XToolkit.isXKBenabled() ? 2 : 1; // Even if XKB is enabled, we have another problem: some symbol tables (e.g. cz) force // a regular comma instead of KP_comma for a decimal separator. Result is, @@ -193,7 +193,7 @@ public class XKeysym { private static long getKeypadKeysym( XKeyEvent ev ) { int ndx = 0; long keysym = XConstants.NoSymbol; - if( XToolkit.isXsunServer() && + if( XToolkit.isXsunKPBehavior() && ! XToolkit.isXKBenabled() ) { if( (ev.get_state() & XConstants.ShiftMask) != 0 ) { // shift modifier is on ndx = 3; diff --git a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java index 038f8534499..14839c7b671 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java @@ -2130,39 +2130,33 @@ public final class XToolkit extends UNIXToolkit implements Runnable { */ private static int backingStoreType; - static boolean awt_ServerInquired = false; - static boolean awt_IsXsunServer = false; + static final int XSUN_KP_BEHAVIOR = 1; + static final int XORG_KP_BEHAVIOR = 2; + + static int awt_IsXsunKPBehavior = 0; static boolean awt_UseXKB = false; static boolean awt_UseXKB_Calls = false; static int awt_XKBBaseEventCode = 0; static int awt_XKBEffectiveGroup = 0; // so far, I don't use it leaving all calculations // to XkbTranslateKeyCode static long awt_XKBDescPtr = 0; + /** - Try to understand if it is Xsun server. - By now (2005) Sun is vendor of Xsun and Xorg servers; we only return true if Xsun is running. - */ - static boolean isXsunServer() { + * Check for Xsun convention regarding numpad keys. + * Xsun and some other servers (i.e. derived from Xsun) + * under certain conditions process numpad keys unlike Xorg. + */ + static boolean isXsunKPBehavior() { awtLock(); try { - if( awt_ServerInquired ) { - return awt_IsXsunServer; + if( awt_IsXsunKPBehavior == 0 ) { + if( XlibWrapper.IsXsunKPBehavior(getDisplay()) ) { + awt_IsXsunKPBehavior = XSUN_KP_BEHAVIOR; + }else{ + awt_IsXsunKPBehavior = XORG_KP_BEHAVIOR; + } } - if( ! XlibWrapper.ServerVendor(getDisplay()).startsWith("Sun Microsystems") ) { - awt_ServerInquired = true; - awt_IsXsunServer = false; - return false; - } - // Now, it's Sun. It still may be Xorg though, eg on Solaris 10, x86. - // Today (2005), VendorRelease of Xorg is a Big Number unlike Xsun. - if( XlibWrapper.VendorRelease(getDisplay()) > 10000 ) { - awt_ServerInquired = true; - awt_IsXsunServer = false; - return false; - } - awt_ServerInquired = true; - awt_IsXsunServer = true; - return true; + return awt_IsXsunKPBehavior == XSUN_KP_BEHAVIOR ? true : false; } finally { awtUnlock(); } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XlibWrapper.java b/jdk/src/solaris/classes/sun/awt/X11/XlibWrapper.java index 19fd7df206a..3ef2f69ae85 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XlibWrapper.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XlibWrapper.java @@ -352,6 +352,7 @@ static native String XSetLocaleModifiers(String modifier_list); static native int XIconifyWindow(long display, long window, long screenNumber); static native String ServerVendor(long display); static native int VendorRelease(long display); + static native boolean IsXsunKPBehavior(long display); static native void XBell(long display, int percent); diff --git a/jdk/src/solaris/classes/sun/awt/X11/keysym2ucs.h b/jdk/src/solaris/classes/sun/awt/X11/keysym2ucs.h index 09ea14b1f95..e03e2a79c04 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/keysym2ucs.h +++ b/jdk/src/solaris/classes/sun/awt/X11/keysym2ucs.h @@ -183,7 +183,7 @@ tojava public static boolean isKPEvent( XKeyEvent ev ) tojava { tojava // Xsun without XKB uses keysymarray[2] keysym to determine if it is KP event. tojava // Otherwise, it is [1]. -tojava int ndx = XToolkit.isXsunServer() && +tojava int ndx = XToolkit.isXsunKPBehavior() && tojava ! XToolkit.isXKBenabled() ? 2 : 1; tojava // Even if XKB is enabled, we have another problem: some symbol tables (e.g. cz) force tojava // a regular comma instead of KP_comma for a decimal separator. Result is, @@ -231,7 +231,7 @@ tojava */ tojava private static long getKeypadKeysym( XKeyEvent ev ) { tojava int ndx = 0; tojava long keysym = XConstants.NoSymbol; -tojava if( XToolkit.isXsunServer() && +tojava if( XToolkit.isXsunKPBehavior() && tojava ! XToolkit.isXKBenabled() ) { tojava if( (ev.get_state() & XConstants.ShiftMask) != 0 ) { // shift modifier is on tojava ndx = 3; diff --git a/jdk/src/solaris/native/sun/xawt/XlibWrapper.c b/jdk/src/solaris/native/sun/xawt/XlibWrapper.c index ce8cadbf391..93fc0971c46 100644 --- a/jdk/src/solaris/native/sun/xawt/XlibWrapper.c +++ b/jdk/src/solaris/native/sun/xawt/XlibWrapper.c @@ -1181,6 +1181,38 @@ JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_VendorRelease AWT_CHECK_HAVE_LOCK(); return VendorRelease((Display*)jlong_to_ptr(display)); } +/* + * Class: sun_awt_X11_XlibWrapper + * Method: IsXsunKPBehavior + * Signature: (J)Z; + */ +JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_IsXsunKPBehavior +(JNIEnv *env, jclass clazz, jlong display) +{ + // Xsun without XKB uses keysymarray[2] keysym to determine if it is KP event. + // Otherwise, it is [1] or sometimes [0]. + // This sniffer first tries to determine what is a keycode for XK_KP_7 + // using XKeysymToKeycode; + // second, in which place in the keysymarray is XK_KP_7 + // using XKeycodeToKeysym. + int kc7; + AWT_CHECK_HAVE_LOCK(); + kc7 = XKeysymToKeycode((Display*)jlong_to_ptr(display), XK_KP_7); + if( !kc7 ) { + // keycode is not defined. Why, it's a reduced keyboard perhaps: + // report arbitrarily false. + return JNI_FALSE; + } else { + long ks2 = XKeycodeToKeysym((Display*)jlong_to_ptr(display), kc7, 2); + if( ks2 == XK_KP_7 ) { + //XXX If some Xorg server would put XK_KP_7 in keysymarray[2] as well, + //XXX for yet unknown to me reason, the sniffer would lie. + return JNI_TRUE; + }else{ + return JNI_FALSE; + } + } +} JavaVM* jvm = NULL; static int ToolkitErrorHandler(Display * dpy, XErrorEvent * event) { From 0ed9b1c52f71ccf02568bc6f9a8cd23be9347733 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Fri, 26 Jun 2009 16:30:02 +0400 Subject: [PATCH 17/23] 6557223: Resize cursor stays after fast outline-resize of JInternalFrame with JScrollPane Reviewed-by: peterz --- .../classes/javax/swing/plaf/basic/BasicInternalFrameUI.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java index 46eefa26c14..383930533a2 100644 --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java @@ -1,5 +1,5 @@ /* - * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -683,6 +683,7 @@ public class BasicInternalFrameUI extends InternalFrameUI } getDesktopManager().endResizingFrame(frame); resizing = false; + updateFrameCursor(); } _x = 0; _y = 0; From d41845e0abd3f8b916e391c392538d6268cde6bd Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Fri, 26 Jun 2009 16:58:46 +0400 Subject: [PATCH 18/23] 6679840: provide a way to choose v-synced BufferStrategy Reviewed-by: peterz --- .../com/sun/java/swing/SwingUtilities3.java | 43 ++++++++++++- .../swing/BufferStrategyPaintManager.java | 60 +++++++------------ 2 files changed, 65 insertions(+), 38 deletions(-) diff --git a/jdk/src/share/classes/com/sun/java/swing/SwingUtilities3.java b/jdk/src/share/classes/com/sun/java/swing/SwingUtilities3.java index 324d2172a43..50ce0b760b9 100644 --- a/jdk/src/share/classes/com/sun/java/swing/SwingUtilities3.java +++ b/jdk/src/share/classes/com/sun/java/swing/SwingUtilities3.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,13 +27,17 @@ package com.sun.java.swing; import sun.awt.EventQueueDelegate; import sun.awt.AppContext; +import java.util.Collections; import java.util.Map; +import java.util.WeakHashMap; import java.util.concurrent.Callable; import java.awt.AWTEvent; import java.awt.EventQueue; import java.awt.Component; +import java.awt.Container; import javax.swing.JComponent; import javax.swing.RepaintManager; +import javax.swing.SwingUtilities; /** * A collection of utility methods for Swing. @@ -69,6 +73,43 @@ public class SwingUtilities3 { repaintManager); } + private static final Map vsyncedMap = + Collections.synchronizedMap(new WeakHashMap()); + + /** + * Sets vsyncRequested state for the {@code rootContainer}. If + * {@code isRequested} is {@code true} then vsynced + * {@code BufferStrategy} is enabled for this {@code rootContainer}. + * + * Note: requesting vsynced painting does not guarantee one. The outcome + * depends on current RepaintManager's RepaintManager.PaintManager + * and on the capabilities of the graphics hardware/software and what not. + * + * @param rootContainer topmost container. Should be either {@code Window} + * or {@code Applet} + * @param isRequested the value to set vsyncRequested state to + */ + public static void setVsyncRequested(Container rootContainer, + boolean isRequested) { + assert SwingUtilities.getRoot(rootContainer) == rootContainer; + if (isRequested) { + vsyncedMap.put(rootContainer, Boolean.TRUE); + } else { + vsyncedMap.remove(rootContainer); + } + } + + /** + * Checks if vsync painting is requested for {@code rootContainer} + * + * @param rootContainer topmost container. Should be either Window or Applet + * @return {@code true} if vsync painting is requested for {@code rootContainer} + */ + public static boolean isVsyncRequested(Container rootContainer) { + assert SwingUtilities.getRoot(rootContainer) == rootContainer; + return Boolean.TRUE == vsyncedMap.get(rootContainer); + } + /** * Returns delegate {@code RepaintManager} for {@code component} hierarchy. */ diff --git a/jdk/src/share/classes/javax/swing/BufferStrategyPaintManager.java b/jdk/src/share/classes/javax/swing/BufferStrategyPaintManager.java index 3c084afd17f..6fb1732090a 100644 --- a/jdk/src/share/classes/javax/swing/BufferStrategyPaintManager.java +++ b/jdk/src/share/classes/javax/swing/BufferStrategyPaintManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,9 +33,13 @@ import java.lang.ref.WeakReference; import java.security.AccessController; import java.util.*; import java.util.logging.*; + +import com.sun.java.swing.SwingUtilities3; + import sun.awt.SubRegionShowable; import sun.java2d.SunGraphics2D; import sun.security.action.GetPropertyAction; +import sun.java2d.pipe.hw.ExtendedBufferCapabilities; /** * A PaintManager implementation that uses a BufferStrategy for @@ -73,12 +77,6 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager { private static Method COMPONENT_CREATE_BUFFER_STRATEGY_METHOD; private static Method COMPONENT_GET_BUFFER_STRATEGY_METHOD; - /** - * Indicates whether or not we should try and get a flip buffer strategy - * first, default is false. - */ - private static boolean TRY_FLIP; - private static final Logger LOGGER = Logger.getLogger( "javax.swing.BufferStrategyPaintManager"); @@ -151,12 +149,6 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager { */ private boolean disposeBufferOnEnd; - - static { - TRY_FLIP = "true".equals(AccessController.doPrivileged( - new GetPropertyAction("swing.useFlipBufferStrategy", "false"))); - } - private static Method getGetBufferStrategyMethod() { if (COMPONENT_GET_BUFFER_STRATEGY_METHOD == null) { getMethods(); @@ -257,7 +249,7 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager { try { BufferInfo info = getBufferInfo(c); BufferStrategy bufferStrategy; - if (info != null && !info.usingFlip && info.isInSync() && + if (info != null && info.isInSync() && (bufferStrategy = info.getBufferStrategy(false)) != null) { SubRegionShowable bsSubRegion = (SubRegionShowable)bufferStrategy; @@ -685,8 +677,6 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager { // same reason. private WeakReference weakBS; private WeakReference root; - // Whether or not we're using flip bs or blit. - private boolean usingFlip; // Indicates whether or not the backbuffer and display are in sync. // This is set to true when a full repaint on the rootpane is done. private boolean inSync; @@ -763,13 +753,6 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager { return bs; } - /** - * Returns true if using a flip buffer strategy. - */ - public boolean usingFlip() { - return usingFlip; - } - /** * Returns true if the buffer strategy of the component differs * from current buffer strategy. @@ -814,23 +797,19 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager { * blit. */ private BufferStrategy createBufferStrategy() { - BufferCapabilities caps; Container root = getRoot(); if (root == null) { return null; } BufferStrategy bs = null; - if (TRY_FLIP) { - bs = createBufferStrategy(root,BufferCapabilities.FlipContents. - COPIED); - usingFlip = true; + if (SwingUtilities3.isVsyncRequested(root)) { + bs = createBufferStrategy(root, true); if (LOGGER.isLoggable(Level.FINER)) { - LOGGER.finer("createBufferStrategy: using flip strategy"); + LOGGER.finer("createBufferStrategy: using vsynced strategy"); } } if (bs == null) { - bs = createBufferStrategy(root, null); - usingFlip = false; + bs = createBufferStrategy(root, false); } if (!(bs instanceof SubRegionShowable)) { // We do this for two reasons: @@ -843,15 +822,22 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager { return bs; } - // Creates and returns a buffer strategy of the requested type. If + // Creates and returns a buffer strategy. If // there is a problem creating the buffer strategy this will // eat the exception and return null. private BufferStrategy createBufferStrategy(Container root, - BufferCapabilities.FlipContents type) { - BufferCapabilities caps = new BufferCapabilities( - new ImageCapabilities(true), - new ImageCapabilities(true), - type); + boolean isVsynced) { + BufferCapabilities caps; + if (isVsynced) { + caps = new ExtendedBufferCapabilities( + new ImageCapabilities(true), new ImageCapabilities(true), + BufferCapabilities.FlipContents.COPIED, + ExtendedBufferCapabilities.VSyncType.VSYNC_ON); + } else { + caps = new BufferCapabilities( + new ImageCapabilities(true), new ImageCapabilities(true), + null); + } BufferStrategy bs = null; if (root instanceof Applet) { try { From 99370fd8712951eb84aae618ae0a74bba75a0da0 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Fri, 26 Jun 2009 17:15:19 +0400 Subject: [PATCH 19/23] 6742850: Antialiasing for GTK L&F should be turned on by default if there is no embedded bitmap Reviewed-by: peterz --- .../classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java index 23e4ee2eee5..aeefca782c2 100644 --- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -139,7 +139,7 @@ public class GTKLookAndFeel extends SynthLookAndFeel { }); isSunDesktop = val.booleanValue(); } - if (isSunDesktop) { + if (isSunDesktop && !sun.java2d.SunGraphicsEnvironment.isOpenSolaris) { isSunCJK = true; } } From adb1c7571e2b355b4b5d44a5f747fdb762b5c858 Mon Sep 17 00:00:00 2001 From: Man Lung Wong Date: Fri, 26 Jun 2009 19:50:44 +0400 Subject: [PATCH 20/23] 6848458: java/awt/GridLayout/LayoutExtraGaps/LayoutExtraGaps.java fails Consider gap between the component edge and container borders instead of just getX() and getY() Reviewed-by: dav --- .../LayoutExtraGaps/LayoutExtraGaps.java | 105 +++++++++++++++--- 1 file changed, 89 insertions(+), 16 deletions(-) diff --git a/jdk/test/java/awt/GridLayout/LayoutExtraGaps/LayoutExtraGaps.java b/jdk/test/java/awt/GridLayout/LayoutExtraGaps/LayoutExtraGaps.java index c7c3d25e9d6..e8ff9602202 100644 --- a/jdk/test/java/awt/GridLayout/LayoutExtraGaps/LayoutExtraGaps.java +++ b/jdk/test/java/awt/GridLayout/LayoutExtraGaps/LayoutExtraGaps.java @@ -24,7 +24,8 @@ /* @test @bug 4370316 - @summary GridLayout does not fill its Container + @summary GridLayout does not centre its component properly + (summary was GridLayout does not fill its Container) @library ../../regtesthelpers @build Util @author Andrei Dmitriev : area=awt.layout @@ -90,27 +91,99 @@ public class LayoutExtraGaps extends Frame { setVisible(true); Util.waitForIdle(Util.createRobot()); - Rectangle r1 = yellowPanel.getComponent(0).getBounds(); - Rectangle r2 = bluePanel.getComponent(0).getBounds(); - Rectangle r3 = blackPanel.getComponent(0).getBounds(); - Rectangle r4 = redPanel.getComponent(0).getBounds(); - System.out.println("firstHorizLabel bounds ="+r1); - System.out.println("firstVertLabel bounds ="+r2); - System.out.println("firstHorizLabel_RTL bounds ="+r3); - System.out.println("firstVertLabel_RTL bounds ="+r4); - if ((r1.getX() == 0 && r1.getY() == 0) || - (r2.getX() == 0 && r2.getY() == 0) || - (r3.getX() == 0 && r3.getY() == 0) || - // RTL only affects horizontal positioning and components lays out from top right corner - (r4.getX() == blackPanel.getWidth() && r4.getY() == 0)) + if (isComponentCentredLTR(yellowPanel) && isComponentCentredLTR(bluePanel) + && isComponentCentredLTR(blackPanel) && isComponentCentredRTL(redPanel)) { - throw new RuntimeException("Test failed. GridLayout doesn't center component."); - } else { System.out.println("Test passed."); + } else { + throw new RuntimeException("Test failed. GridLayout doesn't center component."); } } + /** + * Checks if the components under Panel p are properly centred (i.e. + * opposite borders between the Panel and component are equal). Panel p + * must not be affect by RTL orientation (RTL only affects horizontal + * positioning and components lay out from top right corner). + * + * @param p the panel where the components exist and is not affected + * by right to left orientation + * @return true if components of panel p are properly centre, false + * otherwise + */ + public static boolean isComponentCentredLTR(Panel p) { + double borderLeft; + double borderRight; + double borderTop; + double borderBottom; + + //The first component(rectangle) in panel p. + Rectangle firstRec = p.getComponent(0).getBounds(); + + //The last component(rectangle) in panel p. + Rectangle lastRec = p.getComponent(compCount - 1).getBounds(); + + System.out.println("bounds of the first rectangle in "+ p.getName() + " = " + firstRec); + System.out.println("bounds of the last rectangle in "+ p.getName() + " = " + lastRec); + + borderLeft = firstRec.getX(); + borderRight = p.getWidth() - lastRec.getWidth() - lastRec.getX(); + borderTop = firstRec.getY(); + borderBottom = p.getHeight() - lastRec.getHeight() - lastRec.getY(); + + return areBordersEqual(borderLeft, borderRight) && + areBordersEqual(borderTop, borderBottom); + } + + /** + * Checks if the components under Panel p are properly centred (i.e. + * opposite borders between the Panel and component are equal). Panel p + * must be affect by RTL orientation (RTL only affects horizontal positioning + * and components lay out from top right corner). + * + * @param p the panel where the components exist and is affected by + * right to left orientation + * @return true if components of panel p are properly centre, false + * otherwise + */ + public static boolean isComponentCentredRTL(Panel p) { + double borderLeft; + double borderRight; + double borderTop; + double borderBottom; + + //The first component(rectangle) in panel p. + Rectangle firstRec = p.getComponent(0).getBounds(); + + //The last component(rectangle) in panel p. + Rectangle lastRec = p.getComponent(compCount - 1).getBounds(); + + System.out.println("bounds of the first rectangle in "+ p.getName() + " = " + firstRec); + System.out.println("bounds of the last rectangle in "+ p.getName() + " = " + lastRec); + + borderLeft = lastRec.getX(); + borderRight = p.getWidth() - firstRec.getWidth() - firstRec.getX(); + borderTop = lastRec.getY(); + borderBottom = p.getHeight() - firstRec.getHeight() - firstRec.getY(); + + return areBordersEqual(borderLeft, borderRight) && + areBordersEqual(borderTop, borderBottom); + } + + /** + * Given two borders border1 and border2 check if they are equal. + * + * @param border1 one of the borders being compared + * @param border2 the other border being compared + * @return true if border1 and border2 are equal to each other (i.e. + * their width/height difference is at most 1, assuming the + * smallest pixel is of size 1), false otherwise + */ + public static boolean areBordersEqual(double border1, double border2) { + return Math.abs(border1 - border2) <= 1; + } + public static void main(String[] args) { new LayoutExtraGaps(); } From f17d1e509eddad446bdf8e1f70cd55feede5279e Mon Sep 17 00:00:00 2001 From: Peter Zhelezniakov Date: Fri, 26 Jun 2009 21:43:21 +0400 Subject: [PATCH 21/23] 6849805: Nimbus L&F: NimbusLookAndFeel.getDerivedColor() not always returns color2 for 1.0 midPoint Different rounding mode used for float->int conversion Reviewed-by: malenkov --- .../plaf/nimbus/AbstractRegionPainter.java | 3 +- .../swing/plaf/nimbus/NimbusLookAndFeel.java | 10 +-- .../javax/swing/plaf/nimbus/Test6849805.java | 73 +++++++++++++++++++ 3 files changed, 78 insertions(+), 8 deletions(-) create mode 100644 jdk/test/javax/swing/plaf/nimbus/Test6849805.java diff --git a/jdk/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java b/jdk/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java index 55fb19599c7..bf29e15221d 100644 --- a/jdk/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java +++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java @@ -31,7 +31,6 @@ import javax.swing.*; import javax.swing.plaf.UIResource; import javax.swing.Painter; import java.awt.print.PrinterGraphics; -import static javax.swing.plaf.nimbus.NimbusLookAndFeel.deriveARGB; /** * Convenient base class for defining Painter instances for rendering a @@ -347,7 +346,7 @@ public abstract class AbstractRegionPainter implements Painter { */ protected final Color decodeColor(Color color1, Color color2, float midPoint) { - return new Color(deriveARGB(color1, color2, midPoint)); + return new Color(NimbusLookAndFeel.deriveARGB(color1, color2, midPoint)); } /** diff --git a/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java b/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java index eae031b6ba3..8c5d121b7e1 100644 --- a/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java +++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java @@ -436,15 +436,13 @@ public class NimbusLookAndFeel extends SynthLookAndFeel { */ static int deriveARGB(Color color1, Color color2, float midPoint) { int r = color1.getRed() + - (int) ((color2.getRed() - color1.getRed()) * midPoint + 0.5f); + Math.round((color2.getRed() - color1.getRed()) * midPoint); int g = color1.getGreen() + - (int) ((color2.getGreen() - color1.getGreen()) * midPoint + - 0.5f); + Math.round((color2.getGreen() - color1.getGreen()) * midPoint); int b = color1.getBlue() + - (int) ((color2.getBlue() - color1.getBlue()) * midPoint + 0.5f); + Math.round((color2.getBlue() - color1.getBlue()) * midPoint); int a = color1.getAlpha() + - (int) ((color2.getAlpha() - color1.getAlpha()) * midPoint + - 0.5f); + Math.round((color2.getAlpha() - color1.getAlpha()) * midPoint); return ((a & 0xFF) << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | diff --git a/jdk/test/javax/swing/plaf/nimbus/Test6849805.java b/jdk/test/javax/swing/plaf/nimbus/Test6849805.java new file mode 100644 index 00000000000..10f6fb85aef --- /dev/null +++ b/jdk/test/javax/swing/plaf/nimbus/Test6849805.java @@ -0,0 +1,73 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* @test + @bug 6849805 + @summary Tests NimbusLookAndFeel.deriveColor() + @author Peter Zhelezniakov + @run main Test6849805 +*/ + +import java.awt.Color; + + +public class Test6849805 { + + static boolean pass = true; + + static class Minimbus extends javax.swing.plaf.nimbus.NimbusLookAndFeel { + + public void test(Color c1, Color c2, float f) { + Color r = getDerivedColor(c1, c2, f); + Color test = (f > 0 ? c2 : c1); + System.out.printf("Got %s, need %s ", r, test); + + if (r.getRGB() == test.getRGB() && + r.getAlpha() == test.getAlpha()) { + + System.out.println("Ok"); + } else { + System.out.println("FAIL"); + pass = false; + } + } + } + + public static void main(String[] args) { + Minimbus laf = new Minimbus(); + laf.test(Color.WHITE, Color.BLACK, 0f); + laf.test(Color.WHITE, Color.BLACK, 1f); + laf.test(Color.BLACK, Color.WHITE, 0f); + laf.test(Color.BLACK, Color.WHITE, 1f); + laf.test(Color.RED, Color.GREEN, 0f); + laf.test(Color.RED, Color.GREEN, 1f); + laf.test(new Color(127, 127, 127), new Color(51, 151, 212), 0f); + laf.test(new Color(127, 127, 127), new Color(51, 151, 212), 1f); + laf.test(new Color(221, 63, 189), new Color(112, 200, 89), 0f); + laf.test(new Color(221, 63, 189), new Color(112, 200, 89), 1f); + + if (! pass) { + throw new RuntimeException("Some testcases failed, see above"); + } + } +} From f2d770bf7340e17ece32e8042da47ebf4e533432 Mon Sep 17 00:00:00 2001 From: Yuka Kamiya Date: Tue, 30 Jun 2009 09:38:16 +0900 Subject: [PATCH 22/23] 6855715: Font2Dtest demo needs to be updated to support Unicode 5.1.0 Reviewed-by: okutsu --- .../share/demo/jfc/Font2DTest/RangeMenu.java | 108 +++++++++++++++++- 1 file changed, 102 insertions(+), 6 deletions(-) diff --git a/jdk/src/share/demo/jfc/Font2DTest/RangeMenu.java b/jdk/src/share/demo/jfc/Font2DTest/RangeMenu.java index 3dabe1e88f8..52c5783f7c1 100644 --- a/jdk/src/share/demo/jfc/Font2DTest/RangeMenu.java +++ b/jdk/src/share/demo/jfc/Font2DTest/RangeMenu.java @@ -53,7 +53,7 @@ import javax.swing.*; public final class RangeMenu extends JComboBox implements ActionListener { /// Painfully extracted from java.lang.Character.UnicodeBlock. Arrrgh! - /// Unicode 3.0 data. + /// Unicode 5.1.0 data. private final int[][] UNICODE_RANGES = { { 0x000000, 0x00007f }, /// BASIC_LATIN @@ -63,14 +63,16 @@ public final class RangeMenu extends JComboBox implements ActionListener { { 0x000250, 0x0002af }, /// IPA_EXTENSIONS { 0x0002b0, 0x0002ff }, /// SPACING_MODIFIER_LETTERS { 0x000300, 0x00036f }, /// COMBINING_DIACRITICAL_MARKS - { 0x000370, 0x0003ff }, /// GREEK + { 0x000370, 0x0003ff }, /// GREEK_AND_COPTIC { 0x000400, 0x0004ff }, /// CYRILLIC { 0x000500, 0x00052f }, /// CYRILLIC_SUPPLEMENTARY { 0x000530, 0x00058f }, /// ARMENIAN { 0x000590, 0x0005ff }, /// HEBREW { 0x000600, 0x0006ff }, /// ARABIC { 0x000700, 0x00074f }, /// SYRIAC + { 0x000750, 0x00077f }, /// ARABIC_SUPPLEMENT { 0x000780, 0x0007bf }, /// THAANA + { 0x0007c0, 0x0007ff }, /// NKO { 0x000900, 0x00097f }, /// DEVANAGARI { 0x000980, 0x0009ff }, /// BENGALI { 0x000a00, 0x000a7f }, /// GURMUKHI @@ -88,6 +90,7 @@ public final class RangeMenu extends JComboBox implements ActionListener { { 0x0010a0, 0x0010ff }, /// GEORGIAN { 0x001100, 0x0011ff }, /// HANGUL_JAMO { 0x001200, 0x00137f }, /// ETHIOPIC + { 0x001380, 0x00139f }, /// ETHIOPIC_SUPPLEMENT { 0x0013a0, 0x0013ff }, /// CHEROKEE { 0x001400, 0x00167f }, /// UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS { 0x001680, 0x00169f }, /// OGHAM @@ -100,8 +103,16 @@ public final class RangeMenu extends JComboBox implements ActionListener { { 0x001800, 0x0018af }, /// MONGOLIAN { 0x001900, 0x00194f }, /// LIMBU { 0x001950, 0x00197f }, /// TAI_LE + { 0x001980, 0x0019df }, /// NEW_TAI_LE { 0x0019e0, 0x0019ff }, /// KHMER_SYMBOLS + { 0x001a00, 0x001a1f }, /// BUGINESE + { 0x001b00, 0x001b7f }, /// BALINESE + { 0x001b80, 0x001bbf }, /// SUNDANESE + { 0x001c00, 0x001c4f }, /// LEPCHA + { 0x001c50, 0x001c7f }, /// OL_CHIKI { 0x001d00, 0x001d7f }, /// PHONETIC_EXTENSIONS + { 0x001d80, 0x001dbf }, /// PHONEITC EXTENSIONS SUPPLEMENT + { 0x001dc0, 0x001dff }, /// COMBINING_DIACRITICAL_MAKRS_SUPPLEMENT { 0x001e00, 0x001eff }, /// LATIN_EXTENDED_ADDITIONAL { 0x001f00, 0x001fff }, /// GREEK_EXTENDED { 0x002000, 0x00206f }, /// GENERAL_PUNCTUATION @@ -128,6 +139,14 @@ public final class RangeMenu extends JComboBox implements ActionListener { { 0x002980, 0x0029ff }, /// MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B { 0x002a00, 0x002aff }, /// SUPPLEMENTAL_MATHEMATICAL_OPERATORS { 0x002b00, 0x002bff }, /// MISCELLANEOUS_SYMBOLS_AND_ARROWS + { 0x002c00, 0x002c5f }, /// GLAGOLITIC + { 0x002c60, 0x002c7f }, /// LATIN_EXTENDED-C + { 0x002c80, 0x002cff }, /// COPTIC + { 0x002d00, 0x002d2f }, /// GEORGIAN_SUPPLEMENT + { 0x002d30, 0x002d7f }, /// TIFINAGH + { 0x002d80, 0x002ddf }, /// ETHIOPIC_EXTENDED + { 0x002de0, 0x002dff }, /// CYRILLIC_EXTENDED-A + { 0x002e00, 0x002e7f }, /// SUPPLEMENTAL_PUNCTUATION { 0x002e80, 0x002eff }, /// CJK_RADICALS_SUPPLEMENT { 0x002f00, 0x002fdf }, /// KANGXI_RADICALS { 0x002ff0, 0x002fff }, /// IDEOGRAPHIC_DESCRIPTION_CHARACTERS @@ -138,6 +157,7 @@ public final class RangeMenu extends JComboBox implements ActionListener { { 0x003130, 0x00318f }, /// HANGUL_COMPATIBILITY_JAMO { 0x003190, 0x00319f }, /// KANBUN { 0x0031a0, 0x0031bf }, /// BOPOMOFO_EXTENDED + { 0x0031c0, 0x0031ef }, /// CJK_STROKES { 0x0031f0, 0x0031ff }, /// KATAKANA_PHONETIC_EXTENSIONS { 0x003200, 0x0032ff }, /// ENCLOSED_CJK_LETTERS_AND_MONTHS { 0x003300, 0x0033ff }, /// CJK_COMPATIBILITY @@ -146,13 +166,26 @@ public final class RangeMenu extends JComboBox implements ActionListener { { 0x004e00, 0x009fff }, /// CJK_UNIFIED_IDEOGRAPHS { 0x00a000, 0x00a48f }, /// YI_SYLLABLES { 0x00a490, 0x00a4cf }, /// YI_RADICALS + { 0x00a500, 0x00a63f }, /// YAI + { 0x00a640, 0x00a69f }, /// CYRILLIC_EXTENDED-B + { 0x00a700, 0x00a71f }, /// MODIFIER_TONE_LETTERS + { 0x00a720, 0x00a7ff }, /// LATIN_EXTENDED-D + { 0x00a800, 0x00a82f }, /// SYLOTI_NAGRI + { 0x00a840, 0x00a87f }, /// PHAGS-PA + { 0x00a880, 0x00a8df }, /// SAURASHTRA + { 0x00a900, 0x00a92f }, /// KAYAH_LI + { 0x00a930, 0x00a95f }, /// REJANG + { 0x00aa00, 0x00aa5f }, /// CHAM { 0x00ac00, 0x00d7af }, /// HANGUL_SYLLABLES - { 0x00d800, 0x00dfff }, /// SURROGATES_AREA + { 0x00d800, 0x00db7f }, /// HIGH_SURROGATES_AREA + { 0x00db80, 0x00dbff }, /// HIGH_PRIVATE_USE_SURROGATES_AREA + { 0x00dc00, 0x00dfff }, /// LOW_SURROGATES_AREA { 0x00e000, 0x00f8ff }, /// PRIVATE_USE_AREA { 0x00f900, 0x00faff }, /// CJK_COMPATIBILITY_IDEOGRAPHS { 0x00fb00, 0x00fb4f }, /// ALPHABETIC_PRESENTATION_FORMS { 0x00fb50, 0x00fdff }, /// ARABIC_PRESENTATION_FORMS_A { 0x00fe00, 0x00fe0f }, /// VARIATION_SELECTORS + { 0x00fe10, 0x00fe1f }, /// VERTICAL_FORMS { 0x00fe20, 0x00fe2f }, /// COMBINING_HALF_MARKS { 0x00fe30, 0x00fe4f }, /// CJK_COMPATIBILITY_FORMS { 0x00fe50, 0x00fe6f }, /// SMALL_FORM_VARIANTS @@ -162,17 +195,32 @@ public final class RangeMenu extends JComboBox implements ActionListener { { 0x010000, 0x01007f }, /// LINEAR_B_SYLLABARY { 0x010080, 0x0100ff }, /// LINEAR_B_IDEOGRAMS { 0x010100, 0x01013f }, /// AEGEAN_NUMBERS + { 0x010140, 0x01018f }, /// ANCIENT_GREEK_NUMBERS + { 0x010190, 0x0101cf }, /// ANCIENT_SYMBOLS + { 0x0101d0, 0x0101ff }, /// PHAISTOS_DISC + { 0x010280, 0x01029f }, /// LYCIAN + { 0x0102a0, 0x0102df }, /// CARIAN { 0x010300, 0x01032f }, /// OLD_ITALIC { 0x010330, 0x01034f }, /// GOTHIC { 0x010380, 0x01039f }, /// UGARITIC + { 0x0103a0, 0x0103df }, /// OLD_PERSIAN { 0x010400, 0x01044f }, /// DESERET { 0x010450, 0x01047f }, /// SHAVIAN { 0x010480, 0x0104af }, /// OSMANYA { 0x010800, 0x01083f }, /// CYPRIOT_SYLLABARY + { 0x010900, 0x01091f }, /// PHOENICIAN + { 0x010920, 0x01093f }, /// LYDIAN + { 0x010a00, 0x010a5f }, /// KHAROSHTHI + { 0x012000, 0x0123ff }, /// CUNEIFORM + { 0x012400, 0x01247f }, /// CUNEIFORM_NUMBERS_AND_PUNCTUATION { 0x01d000, 0x01d0ff }, /// BYZANTINE_MUSICAL_SYMBOLS { 0x01d100, 0x01d1ff }, /// MUSICAL_SYMBOLS + { 0x01d200, 0x01d24f }, /// ANCIENT_GREEK_MUSICAL_NOTATION { 0x01d300, 0x01d35f }, /// TAI_XUAN_JING_SYMBOLS + { 0x01d360, 0x01d37f }, /// COUNTING_ROD_NUMERALS { 0x01d400, 0x01d7ff }, /// MATHEMATICAL_ALPHANUMERIC_SYMBOLS + { 0x01f000, 0x01f02f }, /// MAHJONG_TILES + { 0x01f030, 0x01f09f }, /// DOMINO_TILES { 0x020000, 0x02a6df }, /// CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B { 0x02f800, 0x02fa1f }, /// CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT { 0x0e0000, 0x0e007f }, /// TAGS @@ -190,14 +238,16 @@ public final class RangeMenu extends JComboBox implements ActionListener { "IPA Extensions", "Spacing Modifier Letters", "Combining Diacritical Marks", - "Greek", + "Greek and Coptic", "Cyrillic", "Cyrillic Supplement", "Armenian", "Hebrew", "Arabic", "Syriac", + "Arabic Supplement", "Thaana", + "NKo", "Devanagari", "Bengali", "Gurmukhi", @@ -215,6 +265,7 @@ public final class RangeMenu extends JComboBox implements ActionListener { "Georgian", "Hangul Jamo", "Ethiopic", + "Ethiopic Supplement", "Cherokee", "Unified Canadian Aboriginal Syllabics", "Ogham", @@ -227,14 +278,22 @@ public final class RangeMenu extends JComboBox implements ActionListener { "Mongolian", "Limbu", "Tai Le", + "New Tai Lue", "Khmer Symbols", + "Buginese", + "Balinese", + "Sundanese", + "Lepcha", + "Ol Chiki", "Phonetic Extensions", + "Phonetic Extensions Supplement", + "Combining Diacritical Marks Supplement", "Latin Extended Additional", "Greek Extended", "General Punctuation", "Superscripts and Subscripts", "Currency Symbols", - "Combining Marks for Symbols", + "Combining Diacritical Marks for Symbols", "Letterlike Symbols", "Number Forms", "Arrows", @@ -255,6 +314,14 @@ public final class RangeMenu extends JComboBox implements ActionListener { "Miscellaneous Mathematical Symbols-B", "Supplemental Mathematical Operators", "Miscellaneous Symbols and Arrows", + "Glagolitic", + "Latin Extended-C", + "Coptic", + "Georgian Supplement", + "Tifinagh", + "Ethiopic Extended", + "Cyrillic Extended-A", + "Supplemental Punctuation", "CJK Radicals Supplement", "Kangxi Radicals", "Ideographic Description Characters", @@ -265,6 +332,7 @@ public final class RangeMenu extends JComboBox implements ActionListener { "Hangul Compatibility Jamo", "Kanbun", "Bopomofo Extended", + "CJK Strokes", "Katakana Phonetic Extensions", "Enclosed CJK Letters and Months", "CJK Compatibility", @@ -273,13 +341,26 @@ public final class RangeMenu extends JComboBox implements ActionListener { "CJK Unified Ideographs", "Yi Syllables", "Yi Radicals", + "Vai", + "Cyrillic Extended-B", + "Modifier Tone Letters", + "Latin Extended-D", + "Syloti Nagri", + "Phags-pa", + "Saurashtra", + "Kayah Li", + "Rejang", + "Cham", "Hangul Syllables", - "Surrogates Area", // High Surrogates, High Private Use Surrogates, Low Surrogates + "High Surrogates", + "High Private Use Surrogates", + "Low Surrogates", "Private Use Area", "CJK Compatibility Ideographs", "Alphabetic Presentation Forms", "Arabic Presentation Forms-A", "Variation Selectors", + "Vertical Forms", "Combining Half Marks", "CJK Compatibility Forms", "Small Form Variants", @@ -289,17 +370,32 @@ public final class RangeMenu extends JComboBox implements ActionListener { "Linear B Syllabary", "Linear B Ideograms", "Aegean Numbers", + "Ancient Greek Numbers", + "Ancient Symbols", + "Phaistos Disc", + "Lycian", + "Carian", "Old Italic", "Gothic", "Ugaritic", + "Old Persian", "Deseret", "Shavian", "Osmanya", "Cypriot Syllabary", + "Phoenician", + "Lydian", + "Kharoshthi", + "Cuneiform", + "Cuneiform Numbers and Punctuation", "Byzantine Musical Symbols", "Musical Symbols", + "Ancient Greek Musical Notation", "Tai Xuan Jing Symbols", + "Counting Rod Numerals", "Mathematical Alphanumeric Symbols", + "Mahjong Tiles", + "Domino Tiles", "CJK Unified Ideographs Extension B", "CJK Compatibility Ideographs Supplement", "Tags", From fdd028066160f0c516e5e8ce2e8777c4f8dcf8a9 Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Tue, 30 Jun 2009 12:55:21 +0400 Subject: [PATCH 23/23] 6855713: jdk7: debug build failure in awt_Frame.cpp Reviewed-by: dcherepanov, yan --- jdk/src/windows/native/sun/windows/awt_Frame.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jdk/src/windows/native/sun/windows/awt_Frame.cpp b/jdk/src/windows/native/sun/windows/awt_Frame.cpp index 545b1b98175..6e2ec9c0ff7 100644 --- a/jdk/src/windows/native/sun/windows/awt_Frame.cpp +++ b/jdk/src/windows/native/sun/windows/awt_Frame.cpp @@ -391,9 +391,10 @@ void AwtFrame::CreateProxyFocusOwner() void AwtFrame::_CreateProxyFocusOwner(void *param) { DASSERT(AwtToolkit::IsMainThread()); - DASSERT(m_proxyFocusOwner == NULL); AwtFrame *f = (AwtFrame *)param; + DASSERT(f->m_proxyFocusOwner == NULL); + f->m_proxyFocusOwner = ::CreateWindow(TEXT("STATIC"), TEXT("ProxyFocusOwner"), WS_CHILD,