--- a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Wed Jun 05 12:30:02 2013 -0700
@@ -77,8 +77,20 @@
if (!GraphicsEnvironment.isHeadless()) {
initIDs();
}
+ inAWT = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+ @Override
+ public Boolean run() {
+ return !Boolean.parseBoolean(System.getProperty("javafx.embed.singleThread", "false"));
+ }
+ });
}
+ /*
+ * If true we operate in normal mode and nested runloop is executed in JavaRunLoopMode
+ * If false we operate in singleThreaded FX/AWT interop mode and nested loop uses NSDefaultRunLoopMode
+ */
+ private static final boolean inAWT;
+
public LWCToolkit() {
SunToolkit.setDataTransfererClassName("sun.lwawt.macosx.CDataTransferer");
@@ -701,7 +713,10 @@
*
* if false - all events come after exit form the nested loop
*/
- static native void doAWTRunLoop(long mediator, boolean processEvents);
+ static void doAWTRunLoop(long mediator, boolean processEvents) {
+ doAWTRunLoopImpl(mediator, processEvents, inAWT);
+ }
+ static private native void doAWTRunLoopImpl(long mediator, boolean processEvents, boolean inAWT);
static native void stopAWTRunLoop(long mediator);
private native boolean nativeSyncQueue(long timeout);
--- a/jdk/src/macosx/native/sun/awt/AWTWindow.m Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/src/macosx/native/sun/awt/AWTWindow.m Wed Jun 05 12:30:02 2013 -0700
@@ -539,7 +539,7 @@
AWTWindow *opposite = [AWTWindow lastKeyWindow];
if (!IS(self.styleBits, IS_DIALOG)) {
[CMenuBar activate:self.javaMenuBar modallyDisabled:NO];
- } else if (IS(self.styleBits, IS_MODAL)) {
+ } else if ((opposite != NULL) && IS(self.styleBits, IS_MODAL)) {
[CMenuBar activate:opposite->javaMenuBar modallyDisabled:YES];
}
[AWTWindow setLastKeyWindow:nil];
--- a/jdk/src/macosx/native/sun/awt/CDropTargetContextPeer.m Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/src/macosx/native/sun/awt/CDropTargetContextPeer.m Wed Jun 05 12:30:02 2013 -0700
@@ -61,7 +61,6 @@
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CDropTargetContextPeer_startTransfer
(JNIEnv *env, jobject jthis, jlong jdroptarget, jlong jformat)
{
- AWT_ASSERT_NOT_APPKIT_THREAD;
jlong result = (jlong) 0L;
--- a/jdk/src/macosx/native/sun/awt/LWCToolkit.m Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/src/macosx/native/sun/awt/LWCToolkit.m Wed Jun 05 12:30:02 2013 -0700
@@ -295,11 +295,11 @@
/*
* Class: sun_lwawt_macosx_LWCToolkit
- * Method: doAWTRunLoop
+ * Method: doAWTRunLoopImpl
* Signature: (JZZ)V
*/
-JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_doAWTRunLoop
-(JNIEnv *env, jclass clz, jlong mediator, jboolean processEvents)
+JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_doAWTRunLoopImpl
+(JNIEnv *env, jclass clz, jlong mediator, jboolean processEvents, jboolean inAWT)
{
AWT_ASSERT_APPKIT_THREAD;
JNF_COCOA_ENTER(env);
@@ -311,7 +311,7 @@
// Don't use acceptInputForMode because that doesn't setup autorelease pools properly
BOOL isRunning = true;
while (![mediatorObject shouldEndRunLoop] && isRunning) {
- isRunning = [[NSRunLoop currentRunLoop] runMode:[JNFRunLoop javaRunLoopMode]
+ isRunning = [[NSRunLoop currentRunLoop] runMode:(inAWT ? [JNFRunLoop javaRunLoopMode] : NSDefaultRunLoopMode)
beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.010]];
if (processEvents) {
//We do not spin a runloop here as date is nil, so does not matter which mode to use
@@ -340,7 +340,6 @@
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_stopAWTRunLoop
(JNIEnv *env, jclass clz, jlong mediator)
{
-AWT_ASSERT_NOT_APPKIT_THREAD;
JNF_COCOA_ENTER(env);
AWTRunLoopObject* mediatorObject = (AWTRunLoopObject*)jlong_to_ptr(mediator);
--- a/jdk/src/macosx/native/sun/osxapp/QueuingApplicationDelegate.m Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/src/macosx/native/sun/osxapp/QueuingApplicationDelegate.m Wed Jun 05 12:30:02 2013 -0700
@@ -110,8 +110,14 @@
- (void)_handleOpenURLEvent:(NSAppleEventDescriptor *)openURLEvent withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
+ // Make an explicit copy of the passed events as they may be invalidated by the time they're processed
+ NSAppleEventDescriptor *openURLEventCopy = [openURLEvent copy];
+ NSAppleEventDescriptor *replyEventCopy = [replyEvent copy];
+
[self.queue addObject:[^(){
- [self.realDelegate _handleOpenURLEvent:openURLEvent withReplyEvent:replyEvent];
+ [self.realDelegate _handleOpenURLEvent:openURLEventCopy withReplyEvent:replyEventCopy];
+ [openURLEventCopy release];
+ [replyEventCopy release];
} copy]];
}
--- a/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java Wed Jun 05 12:30:02 2013 -0700
@@ -42,7 +42,7 @@
* Component to focus. This behavior can be disabled using the
* <code>setImplicitDownCycleTraversal</code> method.
* <p>
- * By default, methods of this class with return a Component only if it is
+ * By default, methods of this class will return a Component only if it is
* visible, displayable, enabled, and focusable. Subclasses can modify this
* behavior by overriding the <code>accept</code> method.
* <p>
--- a/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java Wed Jun 05 12:30:02 2013 -0700
@@ -559,6 +559,7 @@
} else {
restoreFocus(fe, newFocusedWindow);
}
+ setMostRecentFocusOwner(newFocusedWindow, null); // see: 8013773
}
break;
}
--- a/jdk/src/share/classes/java/awt/EventQueue.java Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/src/share/classes/java/awt/EventQueue.java Wed Jun 05 12:30:02 2013 -0700
@@ -37,16 +37,10 @@
import java.util.EmptyStackException;
+import sun.awt.*;
import sun.awt.dnd.SunDropTargetEvent;
import sun.util.logging.PlatformLogger;
-import sun.awt.AppContext;
-import sun.awt.AWTAutoShutdown;
-import sun.awt.PeerEvent;
-import sun.awt.SunToolkit;
-import sun.awt.EventQueueItem;
-import sun.awt.AWTAccessor;
-
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.atomic.AtomicInteger;
@@ -181,6 +175,8 @@
private final String name = "AWT-EventQueue-" + threadInitNumber.getAndIncrement();
+ private FwDispatcher fwDispatcher;
+
private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.EventQueue");
static {
@@ -209,6 +205,10 @@
{
EventQueue.invokeAndWait(source, r);
}
+ public void setFwDispatcher(EventQueue eventQueue,
+ FwDispatcher dispatcher) {
+ eventQueue.setFwDispatcher(dispatcher);
+ }
});
}
@@ -684,7 +684,16 @@
final Object src = event.getSource();
final PrivilegedAction<Void> action = new PrivilegedAction<Void>() {
public Void run() {
- dispatchEventImpl(event, src);
+ if (fwDispatcher == null) {
+ dispatchEventImpl(event, src);
+ } else {
+ fwDispatcher.scheduleDispatch(new Runnable() {
+ @Override
+ public void run() {
+ dispatchEventImpl(event, src);
+ }
+ });
+ }
return null;
}
};
@@ -844,7 +853,9 @@
while (topQueue.nextQueue != null) {
topQueue = topQueue.nextQueue;
}
-
+ if (topQueue.fwDispatcher != null) {
+ throw new RuntimeException("push() to queue with fwDispatcher");
+ }
if ((topQueue.dispatchThread != null) &&
(topQueue.dispatchThread.getEventQueue() == this))
{
@@ -975,6 +986,9 @@
// Forward the request to the top of EventQueue stack
return nextQueue.createSecondaryLoop(cond, filter, interval);
}
+ if (fwDispatcher != null) {
+ return fwDispatcher.createSecondaryLoop();
+ }
if (dispatchThread == null) {
initDispatchThread();
}
@@ -1018,6 +1032,9 @@
eq = next;
next = eq.nextQueue;
}
+ if (eq.fwDispatcher != null) {
+ return eq.fwDispatcher.isDispatchThread();
+ }
return (Thread.currentThread() == eq.dispatchThread);
} finally {
pushPopLock.unlock();
@@ -1303,6 +1320,15 @@
pushPopLock.unlock();
}
}
+
+ // The method is used by AWTAccessor for javafx/AWT single threaded mode.
+ private void setFwDispatcher(FwDispatcher dispatcher) {
+ if (nextQueue != null) {
+ nextQueue.setFwDispatcher(dispatcher);
+ } else {
+ fwDispatcher = dispatcher;
+ }
+ }
}
/**
--- a/jdk/src/share/classes/java/awt/Window.java Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/src/share/classes/java/awt/Window.java Wed Jun 05 12:30:02 2013 -0700
@@ -1200,6 +1200,7 @@
}
}
}
+ boolean fireWindowClosedEvent = isDisplayable();
DisposeAction action = new DisposeAction();
if (EventQueue.isDispatchThread()) {
action.run();
@@ -1220,7 +1221,9 @@
// Execute outside the Runnable because postWindowEvent is
// synchronized on (this). We don't need to synchronize the call
// on the EventQueue anyways.
- postWindowEvent(WindowEvent.WINDOW_CLOSED);
+ if (fireWindowClosedEvent) {
+ postWindowEvent(WindowEvent.WINDOW_CLOSED);
+ }
}
/*
--- a/jdk/src/share/classes/java/beans/XMLEncoder.java Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/src/share/classes/java/beans/XMLEncoder.java Wed Jun 05 12:30:02 2013 -0700
@@ -487,6 +487,12 @@
}
indentation--;
+ Statement statement = getMissedStatement();
+ while (statement != null) {
+ outputStatement(statement, this, false);
+ statement = getMissedStatement();
+ }
+
try {
out.flush();
}
@@ -503,6 +509,17 @@
targetToStatementList.clear();
}
+ Statement getMissedStatement() {
+ for (List<Statement> statements : this.targetToStatementList.values()) {
+ for (int i = 0; i < statements.size(); i++) {
+ if (Statement.class == statements.get(i).getClass()) {
+ return statements.remove(i);
+ }
+ }
+ }
+ return null;
+ }
+
/**
* This method calls <code>flush</code>, writes the closing
@@ -597,7 +614,7 @@
"methodName") + " should not be null");
}
- if (target instanceof Field && methodName.equals("get")) {
+ if (isArgument && target instanceof Field && methodName.equals("get")) {
Field f = (Field)target;
writeln("<object class=" + quote(f.getDeclaringClass().getName()) +
" field=" + quote(f.getName()) + "/>");
--- a/jdk/src/share/classes/javax/swing/DefaultComboBoxModel.java Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/src/share/classes/javax/swing/DefaultComboBoxModel.java Wed Jun 05 12:30:02 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, Oracle and/or its affiliates. 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
@@ -55,8 +55,7 @@
* @param items an array of Object objects
*/
public DefaultComboBoxModel(final E items[]) {
- objects = new Vector<E>();
- objects.ensureCapacity( items.length );
+ objects = new Vector<E>(items.length);
int i,c;
for ( i=0,c=items.length;i<c;i++ )
--- a/jdk/src/share/classes/javax/swing/KeyboardManager.java Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/src/share/classes/javax/swing/KeyboardManager.java Wed Jun 05 12:30:02 2013 -0700
@@ -285,10 +285,11 @@
while (iter.hasMoreElements()) {
JMenuBar mb = (JMenuBar)iter.nextElement();
if ( mb.isShowing() && mb.isEnabled() ) { // don't want to give these out
- if( !(ks.equals(ksE)) ) {
+ boolean extended = (ksE != null) && !ksE.equals(ks);
+ if (extended) {
fireBinding(mb, ksE, e, pressed);
}
- if(ks.equals(ksE) || !e.isConsumed()) {
+ if (!extended || !e.isConsumed()) {
fireBinding(mb, ks, e, pressed);
}
if (e.isConsumed()) {
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java Wed Jun 05 12:30:02 2013 -0700
@@ -692,9 +692,9 @@
*/
protected void installComponents() {
arrowButton = createArrowButton();
- comboBox.add( arrowButton );
if (arrowButton != null) {
+ comboBox.add(arrowButton);
configureArrowButton();
}
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTableUI.java Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTableUI.java Wed Jun 05 12:30:02 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. 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
@@ -419,7 +419,7 @@
}
}
else {
- if (!(table.getParent().getParent() instanceof
+ if (!(SwingUtilities.getUnwrappedParent(table).getParent() instanceof
JScrollPane)) {
return;
}
@@ -1431,7 +1431,7 @@
}
// install the scrollpane border
- Container parent = table.getParent(); // should be viewport
+ Container parent = SwingUtilities.getUnwrappedParent(table); // should be viewport
if (parent != null) {
parent = parent.getParent(); // should be the scrollpane
if (parent != null && parent instanceof JScrollPane) {
--- a/jdk/src/share/classes/sun/awt/AWTAccessor.java Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java Wed Jun 05 12:30:02 2013 -0700
@@ -484,6 +484,11 @@
*/
void invokeAndWait(Object source, Runnable r)
throws InterruptedException, InvocationTargetException;
+
+ /**
+ * Sets the delegate for the EventQueue used by FX/AWT single threaded mode
+ */
+ public void setFwDispatcher(EventQueue eventQueue, FwDispatcher dispatcher);
}
/*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/awt/FwDispatcher.java Wed Jun 05 12:30:02 2013 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.awt;
+
+import java.awt.*;
+
+/**
+ * An interface for the EventQueue delegate.
+ * This class is added to support JavaFX/AWT interop single threaded mode
+ * The delegate should be set in EventQueue by {@link EventQueue#setFwDispatcher(FwDispatcher)}
+ * If the delegate is not null, than it handles supported methods instead of the
+ * event queue. If it is null than the behaviour of an event queue does not change.
+ *
+ * @see EventQueue
+ *
+ * @author Petr Pchelko
+ *
+ * @since 1.8
+ */
+public interface FwDispatcher {
+ /**
+ * Delegates the {@link EventQueue#isDispatchThread()} method
+ */
+ boolean isDispatchThread();
+
+ /**
+ * Forwards a runnable to the delegate, which executes it on an appropriate thread.
+ * @param r - a runnable calling {@link EventQueue#dispatchEventImpl(java.awt.AWTEvent, Object)}
+ */
+ void scheduleDispatch(Runnable r);
+
+ /**
+ * Delegates the {@link java.awt.EventQueue#createSecondaryLoop()} method
+ */
+ SecondaryLoop createSecondaryLoop();
+}
--- a/jdk/src/solaris/classes/sun/awt/X11/XClipboard.java Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XClipboard.java Wed Jun 05 12:30:02 2013 -0700
@@ -179,6 +179,7 @@
}
synchronized (XClipboard.classLock) {
if (targetsAtom2Clipboard != null && !targetsAtom2Clipboard.isEmpty()) {
+ // The viewer is still registered, schedule next poll.
XToolkit.schedule(this, XClipboard.getPollInterval());
}
}
@@ -191,7 +192,8 @@
final XSelectionEvent xse = ev.get_xselection();
XClipboard clipboard = null;
synchronized (XClipboard.classLock) {
- if (targetsAtom2Clipboard != null && !targetsAtom2Clipboard.isEmpty()) {
+ if (targetsAtom2Clipboard != null && targetsAtom2Clipboard.isEmpty()) {
+ // The viewer was unregistered, remove the dispatcher.
XToolkit.removeEventDispatcher(XWindow.getXAWTRootWindow().getWindow(), this);
return;
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java Wed Jun 05 12:30:02 2013 -0700
@@ -1143,6 +1143,19 @@
addNotify();
}
+ @Override
+ public void invalidate() {
+ synchronized (getTreeLock()) {
+ final Container parent = getParent();
+ AWTAccessor.getComponentAccessor().setParent(this, null);
+ try {
+ super.invalidate();
+ } finally {
+ AWTAccessor.getComponentAccessor().setParent(this, parent);
+ }
+ }
+ }
+
public void focusGained(FocusEvent e) {
Graphics g = getGraphics();
Rectangle r = getViewportBorderBounds();
--- a/jdk/src/solaris/native/sun/xawt/XlibWrapper.c Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/src/solaris/native/sun/xawt/XlibWrapper.c Wed Jun 05 12:30:02 2013 -0700
@@ -1946,13 +1946,16 @@
JNIEXPORT jboolean JNICALL
Java_sun_awt_X11_XlibWrapper_XNextSecondaryLoopEvent(JNIEnv *env, jclass clazz,
jlong display, jlong ptr) {
+ uint32_t timeout = 1;
+
AWT_CHECK_HAVE_LOCK();
exitSecondaryLoop = False;
while (!exitSecondaryLoop) {
if (XCheckIfEvent((Display*) jlong_to_ptr(display), (XEvent*) jlong_to_ptr(ptr), secondary_loop_event, NULL)) {
return JNI_TRUE;
}
- AWT_WAIT(AWT_SECONDARY_LOOP_TIMEOUT);
+ timeout = (timeout < AWT_SECONDARY_LOOP_TIMEOUT) ? (timeout << 1) : AWT_SECONDARY_LOOP_TIMEOUT;
+ AWT_WAIT(timeout);
}
return JNI_FALSE;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/ResetMostRecentFocusOwnerTest/ResetMostRecentFocusOwnerTest.java Wed Jun 05 12:30:02 2013 -0700
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ @test
+ @bug 8013773
+ @summary Tests that disabled component is not retained as most recent focus owner.
+ @author Anton.Tarasov: area=awt.focus
+ @library ../../regtesthelpers
+ @build Util
+ @run main ResetMostRecentFocusOwnerTest
+*/
+
+import java.applet.Applet;
+import java.awt.AWTEvent;
+import java.awt.FlowLayout;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.event.AWTEventListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.WindowEvent;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import test.java.awt.regtesthelpers.Util;
+
+public class ResetMostRecentFocusOwnerTest extends Applet {
+
+ public static void main(String[] args) {
+ ResetMostRecentFocusOwnerTest app = new ResetMostRecentFocusOwnerTest();
+ app.init();
+ app.start();
+ }
+
+ @Override
+ public void start() {
+
+ Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+ public void eventDispatched(AWTEvent e) {
+ System.err.println(e);
+ }
+ }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK);
+
+ boolean gained = false;
+ final Robot robot = Util.createRobot();
+
+ JFrame frame1 = new JFrame("Main Frame");
+ final JButton b1 = new JButton("button1");
+ frame1.add(b1);
+ frame1.pack();
+ frame1.setLocation(0, 300);
+
+ Util.showWindowWait(frame1);
+
+ final JFrame frame2 = new JFrame("Test Frame");
+ final JButton b2 = new JButton("button2");
+ frame2.add(b2);
+ frame2.pack();
+ frame2.setLocation(300, 300);
+
+ b2.setEnabled(false);
+ b2.requestFocus();
+
+ Util.showWindowWait(frame2);
+
+ robot.delay(500);
+
+ //
+ // It's expeced that the focus is restored to <button1>.
+ // If not, click <button1> to set focus on it.
+ //
+ if (!b1.hasFocus()) {
+ gained = Util.trackFocusGained(b1, new Runnable() {
+ public void run() {
+ Util.clickOnComp(b1, robot);
+ }
+ }, 5000, false);
+
+ if (!gained) {
+ throw new RuntimeException("Unexpected state: focus is not on <button1>");
+ }
+ }
+
+ robot.delay(500);
+
+ //
+ // Click <button2>, check that focus is set on the parent frame.
+ //
+ gained = false;
+ gained = Util.trackFocusGained(frame2, new Runnable() {
+ public void run() {
+ Util.clickOnComp(b2, robot);
+ }
+ }, 5000, false);
+
+ if (!gained) {
+ throw new RuntimeException("Test failed: focus wasn't set to <frame2>");
+ }
+
+ System.out.println("Test passed.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/TextArea/Mixing/TextAreaMixing.java Wed Jun 05 12:30:02 2013 -0700
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 8013189
+ * @run main TextAreaMixing
+ * @summary TextArea should support HW/LW mixing
+ * @author anthony.petrov@oracle.com
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+public class TextAreaMixing {
+
+ private static volatile boolean menuClicked = false;
+ private static JMenuItem menuItem;
+
+ public static void main(String[] args) throws Exception {
+ // The bug is only reproducible on X11, but there's no reason
+ // for this test to not pass on any platofrm
+
+ final JFrame frame = new JFrame("JFrame");
+ frame.setLayout(new GridLayout(0, 1));
+ frame.setSize(200, 200);
+
+ JMenuBar menuBar = new JMenuBar();
+ JMenu menu = new JMenu("Test Menu");
+
+ for (int i = 0; i < 6; i++) {
+ JMenuItem mi = new JMenuItem(Integer.toString(i));
+ mi.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ menuClicked = true;
+ }
+ });
+ menu.add(mi);
+
+ // Choose a random (OK, the fourth) menu item to click on
+ if (i == 3) {
+ menuItem = mi;
+ }
+ }
+ menuBar.add(menu);
+ frame.setJMenuBar(menuBar);
+
+ frame.getContentPane().add(new TextArea());
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setVisible(true);
+
+ Thread.sleep(2000);
+
+ Robot robot = new Robot();
+
+ // Open the menu
+ Point loc = menu.getLocationOnScreen();
+ robot.mouseMove(loc.x + menu.getWidth() / 2, loc.y + menu.getHeight() / 2);
+ robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+
+ Thread.sleep(500);
+
+ // Click an item
+ loc = menuItem.getLocationOnScreen();
+ robot.mouseMove(loc.x + menuItem.getWidth() / 2, loc.y + menuItem.getHeight() / 2);
+ robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+
+ Thread.sleep(500);
+
+ frame.dispose();
+
+ if (!menuClicked) {
+ throw new RuntimeException("A menu item has never been clicked.");
+ }
+ }
+}
--- a/jdk/test/java/awt/Window/Grab/GrabTest.java Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/test/java/awt/Window/Grab/GrabTest.java Wed Jun 05 12:30:02 2013 -0700
@@ -175,7 +175,7 @@
// 6. Check that press on the outside area causes ungrab
Point loc = f.getLocationOnScreen();
- robot.mouseMove(loc.x + 100, loc.y + f.getSize().height + 1);
+ robot.mouseMove(loc.x + 100, loc.y + f.getSize().height + 10);
Util.waitForIdle(robot);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.delay(50);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/WindowClosedEvents/WindowClosedEventOnDispose.java Wed Jun 05 12:30:02 2013 -0700
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ @test
+ @bug 8015500
+ @summary DisposeAction multiplies the WINDOW_CLOSED event.
+ @author jlm@joseluismartin.info
+ @run main WindowClosedEventOnDispose
+ */
+
+
+import java.awt.Toolkit;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+
+/**
+ * WindowClosedEventOnDispose.java
+ * Summary: tests that Window don't multiplies the WINDOW_CLOSED event
+ * on dispose.
+ * Test fails if fire more events that expected;
+ */
+public class WindowClosedEventOnDispose {
+
+ private static int N_LOOPS = 5;
+ private static int N_DIALOGS = 2;
+
+ public static void main(String args[]) throws Exception {
+ tesWithFrame();
+ testWithoutFrame();
+ testHidenChildDispose();
+ testHidenWindowDispose();
+ }
+
+ /**
+ * Test WINDOW_CLOSED event received by a dialog
+ * that have a owner window.
+ * @throws Exception
+ */
+ public static void tesWithFrame() throws Exception {
+ doTest(true);
+ }
+
+ /**
+ * Test WINDOW_CLOSED event received by a dialog
+ * that don't have a owner window.
+ * @throws Exception
+ */
+ public static void testWithoutFrame() throws Exception {
+ System.out.println("Run without owner Frame");
+ doTest(false);
+ }
+
+ /**
+ * Test if a dialog that has never been shown fire
+ * the WINDOW_CLOSED event on parent dispose().
+ * @throws Exception
+ */
+ public static void testHidenChildDispose() throws Exception {
+ JFrame f = new JFrame();
+ JDialog dlg = new JDialog(f);
+ Listener l = new Listener();
+ dlg.addWindowListener(l);
+ f.dispose();
+ waitEvents();
+
+ assertEquals(0, l.getCount());
+ }
+
+ /**
+ * Test if a dialog fire the WINDOW_CLOSED event
+ * on parent dispose().
+ * @throws Exception
+ */
+ public static void testVisibleChildParentDispose() throws Exception {
+ JFrame f = new JFrame();
+ JDialog dlg = new JDialog(f);
+ Listener l = new Listener();
+ dlg.addWindowListener(l);
+ dlg.setVisible(true);
+ f.dispose();
+ waitEvents();
+
+ assertEquals(1, l.getCount());
+ }
+
+ /**
+ * Test if a Window that has never been shown fire the
+ * WINDOW_CLOSED event on dispose()
+ */
+ public static void testHidenWindowDispose() throws Exception {
+ JFrame f = new JFrame();
+ Listener l = new Listener();
+ f.addWindowListener(l);
+ f.dispose();
+ waitEvents();
+
+ assertEquals(0, l.getCount());
+ }
+
+ /**
+ * Test if a JDialog receive the correct number
+ * of WINDOW_CLOSED_EVENT
+ * @param useFrame true if use a owner frame
+ * @throws Exception
+ */
+ private static void doTest(final boolean useFrame) throws Exception {
+ final Listener l = new Listener();
+ final JFrame f = new JFrame();
+
+ for (int i = 0; i < N_LOOPS; i++) {
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ public void run() {
+ JDialog[] dialogs = new JDialog[N_DIALOGS];
+ for (int i = 0; i < N_DIALOGS; i++) {
+ if (useFrame) {
+ dialogs[i]= new JDialog(f);
+ }
+ else {
+ dialogs[i] = new JDialog();
+ }
+
+ dialogs[i].addWindowListener(l);
+ dialogs[i].setVisible(true);
+ }
+
+ // Dispose all
+ for (JDialog d : dialogs)
+ d.dispose();
+
+ f.dispose();
+ }
+ });
+ }
+
+ waitEvents();
+
+ assertEquals(N_DIALOGS * N_LOOPS, l.getCount());
+ }
+
+ private static void waitEvents() throws InterruptedException {
+ // Wait until events are dispatched
+ while (Toolkit.getDefaultToolkit().getSystemEventQueue().peekEvent() != null)
+ Thread.sleep(100);
+ }
+
+ /**
+ * @param expected the expected value
+ * @param real the real value
+ */
+ private static void assertEquals(int expected, int real) throws Exception {
+ if (expected != real) {
+ throw new Exception("Expected events: " + expected + " Received Events: " + real);
+ }
+ }
+
+}
+
+/**
+ * Listener to count events
+ */
+class Listener extends WindowAdapter {
+
+ private volatile int count = 0;
+
+ public void windowClosed(WindowEvent e) {
+ count++;
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setCount(int count) {
+ this.count = count;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/XMLEncoder/Test6989223.java Wed Jun 05 12:30:02 2013 -0700
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6989223
+ * @summary Tests Rectangle2D.Double encoding
+ * @author Sergey Malenkov
+ */
+
+import java.awt.geom.Rectangle2D;
+
+public class Test6989223 extends AbstractTest {
+ public static void main(String[] args) {
+ new Test6989223().test(true);
+ }
+
+ protected Object getObject() {
+ return new Bean(1, 2, 3, 4);
+ }
+
+ @Override
+ protected Object getAnotherObject() {
+ return new Bean(1, 2, 3, 5);
+ }
+
+ public static class Bean extends Rectangle2D.Double {
+ public Bean() {
+ }
+
+ public Bean(double x, double y, double w, double h) {
+ super(x, y, w, h);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ return super.equals(object); // to avoid recursion during validation
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/XMLEncoder/Test7080156.java Wed Jun 05 12:30:02 2013 -0700
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7080156 7094245
+ * @summary Tests beans with public arrays
+ * @author Sergey Malenkov
+ */
+
+public class Test7080156 extends AbstractTest {
+ public static void main(String[] args) {
+ new Test7080156().test(true);
+ }
+
+ protected Object getObject() {
+ Bean bean = new Bean();
+ bean.setArray("something");
+ return bean;
+ }
+
+ @Override
+ protected Object getAnotherObject() {
+ Bean bean = new Bean();
+ bean.setArray("some", "thing");
+ return bean;
+ }
+
+ public static class Bean {
+ public String[] array = {"default"};
+
+ public void setArray(String... array) {
+ this.array = array;
+ }
+
+ public String[] getArray() {
+ return this.array;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/XMLEncoder/Test8013557.java Wed Jun 05 12:30:02 2013 -0700
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8013557
+ * @summary Tests beans with public fields
+ * @author Sergey Malenkov
+ */
+
+public class Test8013557 extends AbstractTest {
+ public static void main(String[] args) {
+ new Test8013557().test(true);
+ }
+
+ protected Object getObject() {
+ return new Bean(new Value("something"));
+ }
+
+ @Override
+ protected Object getAnotherObject() {
+ return new Bean(new Value());
+ }
+
+ public static class Bean {
+ public Value value;
+
+ public Bean() {
+ this.value = new Value();
+ }
+
+ public Bean(Value value) {
+ this.value = value;
+ }
+
+ public void setValue(Value value) {
+ this.value = value;
+ }
+
+ public Value getValue() {
+ return this.value;
+ }
+ }
+
+ public static class Value {
+ private String string;
+
+ public Value() {
+ this.string = "default";
+ }
+
+ public Value(String value) {
+ this.string = value;
+ }
+
+ public void setString(String string) {
+ this.string = string;
+ }
+
+ public String getString() {
+ return this.string;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JComboBox/6337518/bug6337518.java Wed Jun 05 12:30:02 2013 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ @bug 6337518
+ @summary Null Arrow Button Throws Exception in BasicComboBoxUI
+ @author Anton Litvinov
+*/
+
+import javax.swing.*;
+import javax.swing.plaf.basic.*;
+
+public class bug6337518 extends BasicComboBoxUI {
+ @Override
+ protected JButton createArrowButton() {
+ return null;
+ }
+
+ public static void main(String[] args) throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ JComboBox comboBox = new JComboBox();
+ comboBox.setUI(new bug6337518());
+ }
+ });
+ }
+}
--- a/jdk/test/javax/swing/JTabbedPane/4624207/bug4624207.java Wed Jun 05 09:52:41 2013 -0700
+++ b/jdk/test/javax/swing/JTabbedPane/4624207/bug4624207.java Wed Jun 05 12:30:02 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. 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
@@ -37,6 +37,8 @@
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
+
+import sun.awt.OSInfo;
import sun.awt.SunToolkit;
public class bug4624207 implements ChangeListener, FocusListener {
@@ -99,7 +101,7 @@
toolkit.realSync();
- if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
+ if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_B);
} else {
Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_B);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTable/7068740/bug7068740.java Wed Jun 05 12:30:02 2013 -0700
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ @bug 7068740
+ @summary JTable wrapped in JLayer can't use PGUP/PGDOWN keys
+ @author Vladislav Karnaukhov
+ @run main bug7068740
+*/
+
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import javax.swing.plaf.LayerUI;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+import javax.swing.table.DefaultTableModel;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+import java.lang.reflect.InvocationTargetException;
+
+public class bug7068740 extends JFrame {
+
+ private static Robot robot = null;
+ private static JTable table = null;
+ private static SunToolkit toolkit = null;
+
+ bug7068740() {
+ super();
+ setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+
+ DefaultTableModel model = new DefaultTableModel() {
+ @Override
+ public int getRowCount() {
+ return 20;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 2;
+ }
+
+ @Override
+ public Object getValueAt(int row, int column) {
+ return "(" + row + "," + column + ")";
+ }
+ };
+
+ table = new JTable(model);
+ LayerUI<JComponent> layerUI = new LayerUI<>();
+ JLayer<JComponent> layer = new JLayer<>(table, layerUI);
+ JScrollPane scrollPane = new JScrollPane(layer);
+ add(scrollPane);
+ pack();
+ setLocationRelativeTo(null);
+ }
+
+ private static void setUp() {
+ try {
+ if (robot == null) {
+ robot = new Robot();
+ robot.setAutoDelay(20);
+ }
+
+ if (toolkit == null) {
+ toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ }
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ bug7068740 test = new bug7068740();
+ test.setVisible(true);
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ throw new RuntimeException("Test failed");
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ throw new RuntimeException("Test failed");
+ } catch (AWTException e) {
+ e.printStackTrace();
+ throw new RuntimeException("Test failed");
+ }
+ }
+
+ private static void doTest() {
+ toolkit.realSync();
+ table.setRowSelectionInterval(0, 0);
+
+ robot.keyPress(KeyEvent.VK_PAGE_DOWN);
+ toolkit.realSync();
+ if (table.getSelectedRow() != 19) {
+ throw new RuntimeException("Test failed");
+ }
+
+ robot.keyPress(KeyEvent.VK_PAGE_UP);
+ toolkit.realSync();
+ if (table.getSelectedRow() != 0) {
+ throw new RuntimeException("Test failed");
+ }
+ }
+
+ public static void main(String[] args) {
+ try {
+ UIManager.setLookAndFeel(new MetalLookAndFeel());
+ setUp();
+ doTest();
+ } catch (UnsupportedLookAndFeelException e) {
+ e.printStackTrace();
+ throw new RuntimeException("Test failed");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/KeyboardManager/8013370/Test8013370.java Wed Jun 05 12:30:02 2013 -0700
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.InputMap;
+import javax.swing.JFrame;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.KeyStroke;
+import sun.awt.SunToolkit;
+
+import static java.awt.event.InputEvent.CTRL_DOWN_MASK;
+import static javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW;
+import static javax.swing.JOptionPane.showMessageDialog;
+import static javax.swing.SwingUtilities.invokeAndWait;
+
+/*
+ * @test
+ * @bug 8013370
+ * @summary Ensure that key stroke is not null
+ * @author Sergey Malenkov
+ */
+
+public class Test8013370 implements Runnable {
+ public static void main(String[] args) throws Exception {
+ Test8013370 task = new Test8013370();
+ invokeAndWait(task);
+
+ Robot robot = new Robot();
+ robot.waitForIdle();
+ robot.keyPress(KeyEvent.VK_CONTROL);
+ robot.keyRelease(KeyEvent.VK_CONTROL);
+ robot.waitForIdle();
+
+ invokeAndWait(task);
+ task.validate();
+ }
+
+ private JFrame frame;
+ private boolean error;
+
+ @Override
+ public void run() {
+ if (this.frame == null) {
+ JMenuBar menu = new JMenuBar() {
+ @Override
+ protected boolean processKeyBinding(KeyStroke stroke, KeyEvent event, int condition, boolean pressed) {
+ if (stroke == null) {
+ Test8013370.this.error = true;
+ return false;
+ }
+ return super.processKeyBinding(stroke, event, condition, pressed);
+ }
+ };
+ menu.add(new JMenuItem("Menu"));
+
+ InputMap map = menu.getInputMap(WHEN_IN_FOCUSED_WINDOW);
+ // We add exactly 10 actions because the ArrayTable is converted
+ // from a array to a hashtable when more than 8 values are added.
+ for (int i = 0; i < 9; i++) {
+ String name = " Action #" + i;
+ map.put(KeyStroke.getKeyStroke(KeyEvent.VK_A + i, CTRL_DOWN_MASK), name);
+
+ menu.getActionMap().put(name, new AbstractAction(name) {
+ @Override
+ public void actionPerformed(ActionEvent event) {
+ showMessageDialog(null, getValue(NAME));
+ }
+ });
+ }
+ this.frame = new JFrame("8013370");
+ this.frame.setJMenuBar(menu);
+ this.frame.setVisible(true);
+ }
+ else {
+ this.frame.dispose();
+ }
+ }
+
+ private void validate() {
+ if (this.error) {
+ throw new Error("KeyStroke is null");
+ }
+ }
+}