From e04c087c6dd2f345489213ac51482274000cc396 Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Fri, 15 Nov 2013 14:05:49 +0400 Subject: [PATCH] 8025126: [macosx] Invalid calls to setValueAt() within JTable in Java 7 on Mac OS X Reviewed-by: serb --- .../classes/sun/lwawt/LWWindowPeer.java | 3 +- .../ExtendedKeyCode/ExtendedKeyCodeTest.java | 31 +++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java b/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java index 7b3cff536ad..d61dc7a9d0e 100644 --- a/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java +++ b/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java @@ -949,7 +949,8 @@ public class LWWindowPeer KeyEvent keyEvent = new KeyEvent(focusOwner, id, when, modifiers, keyCode, keyChar, keyLocation); AWTAccessor.getKeyEventAccessor().setExtendedKeyCode(keyEvent, - ExtendedKeyCodes.getExtendedKeyCodeForChar(keyChar)); + (keyChar == KeyEvent.CHAR_UNDEFINED) ? keyCode + : ExtendedKeyCodes.getExtendedKeyCodeForChar(keyChar)); postEvent(keyEvent); } diff --git a/jdk/test/java/awt/event/KeyEvent/ExtendedKeyCode/ExtendedKeyCodeTest.java b/jdk/test/java/awt/event/KeyEvent/ExtendedKeyCode/ExtendedKeyCodeTest.java index 5d1342d171f..6b21ea0054c 100644 --- a/jdk/test/java/awt/event/KeyEvent/ExtendedKeyCode/ExtendedKeyCodeTest.java +++ b/jdk/test/java/awt/event/KeyEvent/ExtendedKeyCode/ExtendedKeyCodeTest.java @@ -31,7 +31,7 @@ import sun.awt.SunToolkit; /* * @test - * @bug 8007156 + * @bug 8007156 8025126 * @summary Extended key code is not set for a key event * @author Alexandr Scherbatiy * @run main ExtendedKeyCodeTest @@ -44,6 +44,7 @@ public class ExtendedKeyCodeTest { public static void main(String[] args) throws Exception { SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); Robot robot = new Robot(); + robot.setAutoDelay(50); Frame frame = new Frame(); frame.setSize(300, 300); @@ -54,14 +55,14 @@ public class ExtendedKeyCodeTest { public void keyPressed(KeyEvent e) { eventsCount++; setExtendedKeyCode = setExtendedKeyCode && (e.getExtendedKeyCode() - == ExtendedKeyCodes.getExtendedKeyCodeForChar(e.getKeyChar())); + == ExtendedKeyCodes.getExtendedKeyCodeForChar(e.getKeyChar())); } @Override public void keyReleased(KeyEvent e) { eventsCount++; setExtendedKeyCode = setExtendedKeyCode && (e.getExtendedKeyCode() - == ExtendedKeyCodes.getExtendedKeyCodeForChar(e.getKeyChar())); + == ExtendedKeyCodes.getExtendedKeyCodeForChar(e.getKeyChar())); } }); @@ -77,5 +78,29 @@ public class ExtendedKeyCodeTest { if (eventsCount != 2 || !setExtendedKeyCode) { throw new RuntimeException("Wrong extended key code"); } + + frame = new Frame(); + frame.setSize(300, 300); + setExtendedKeyCode = false; + + frame.addKeyListener(new KeyAdapter() { + + @Override + public void keyPressed(KeyEvent e) { + setExtendedKeyCode = e.getExtendedKeyCode() == KeyEvent.VK_LEFT; + } + }); + + frame.setVisible(true); + toolkit.realSync(); + + robot.keyPress(KeyEvent.VK_LEFT); + robot.keyRelease(KeyEvent.VK_LEFT); + toolkit.realSync(); + frame.dispose(); + + if (!setExtendedKeyCode) { + throw new RuntimeException("Wrong extended key code!"); + } } }