--- a/jdk/make/gensrc/Gensrc-java.desktop.gmk Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/make/gensrc/Gensrc-java.desktop.gmk Mon Mar 21 09:36:54 2016 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, 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
@@ -62,7 +62,9 @@
ifeq ($(OPENJDK_TARGET_OS), windows)
PROP_SRC_DIRS += $(JDK_TOPDIR)/src/java.desktop/windows/classes/sun/awt/windows
-else
+endif
+
+ifeq ($(filter $(OPENJDK_TARGET_OS), windows macosx), )
PROP_SRC_DIRS += $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/resources
endif
--- a/jdk/make/lib/Awt2dLibraries.gmk Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/make/lib/Awt2dLibraries.gmk Mon Mar 21 09:36:54 2016 -0700
@@ -311,6 +311,10 @@
$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \
#
+ ifneq ($(filter $(OPENJDK_TARGET_OS),linux solaris), )
+ LIBAWT_XAWT_DIRS += $(JDK_TOPDIR)/src/java.desktop/unix/native/common/awt/systemscale
+ endif
+
LIBAWT_XAWT_EXCLUDES := medialib
LIBAWT_XAWT_CFLAGS := $(addprefix -I, $(shell $(FIND) $(LIBAWT_XAWT_DIRS) -type d)) \
@@ -883,6 +887,10 @@
LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/java.desktop/macosx/native/libsplashscreen
endif
+ ifneq ($(filter $(OPENJDK_TARGET_OS),linux solaris), )
+ LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/java.desktop/unix/native/common/awt/systemscale
+ endif
+
LIBSPLASHSCREEN_CFLAGS += -DSPLASHSCREEN -DPNG_NO_MMX_CODE -DPNG_ARM_NEON_OPT=0 \
$(addprefix -I, $(LIBSPLASHSCREEN_DIRS)) \
$(LIBJAVA_HEADER_FLAGS) \
--- a/jdk/make/mapfiles/libsplashscreen/mapfile-vers Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/make/mapfiles/libsplashscreen/mapfile-vers Mon Mar 21 09:36:54 2016 -0700
@@ -42,6 +42,8 @@
SplashInit;
SplashClose;
SplashSetFileJarName;
+ SplashSetScaleFactor;
+ SplashGetScaledImageName;
local:
*;
};
--- a/jdk/src/java.desktop/macosx/classes/sun/java2d/OSXOffScreenSurfaceData.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/macosx/classes/sun/java2d/OSXOffScreenSurfaceData.java Mon Mar 21 09:36:54 2016 -0700
@@ -478,13 +478,9 @@
// <rdar://problem/4488745> For the Sun2D renderer we should rely on the implementation of the super class.
// BufImageSurfaceData.java doesn't have an implementation of copyArea() and relies on the super class.
- int offsetX = 0;
- int offsetY = 0;
- if (sg2d.transformState == SunGraphics2D.TRANSFORM_ANY_TRANSLATE ||
- sg2d.transformState == SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
- offsetX = (int) sg2d.transform.getTranslateX();
- offsetY = (int) sg2d.transform.getTranslateY();
- } else if (sg2d.transformState != SunGraphics2D.TRANSFORM_ISIDENT) { return false; }
+ if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
+ return false;
+ }
// reset the clip (this is how it works on windows)
// we actually can handle a case with any clips but windows ignores the light clip
@@ -498,18 +494,23 @@
return true;
}
- // the rectangle returned from clipCopyArea() is in the coordinate space of the surface (image)
- // we need to substract the offsetX and offsetY to move it to the coordinate space of the graphics2d.
- // sg2d.drawImage expects the destination rect to be in the coord space of the graphics2d. <rdar://3746194>
- // (vm)
- x = clippedCopyAreaRect.x - offsetX;
- y = clippedCopyAreaRect.y - offsetY;
+ // the rectangle returned from clipCopyArea() is in the coordinate space
+ // of the surface (image)
+ x = clippedCopyAreaRect.x;
+ y = clippedCopyAreaRect.y;
w = clippedCopyAreaRect.width;
h = clippedCopyAreaRect.height;
- // copy (dst coordinates are in the coord space of the graphics2d, and src coordinates are
- // in the coordinate space of the image)
- sg2d.drawImage(this.bim, x + dx, y + dy, x + dx + w, y + dy + h, x + offsetX, y + offsetY, x + w + offsetX, y + h + offsetY, null);
+ // copy (dst coordinates are in the coord space of the graphics2d, and
+ // src coordinates are in the coordinate space of the image)
+ // sg2d.drawImage expects the destination rect to be in the coord space
+ // of the graphics2d. <rdar://3746194> (vm)
+ // we need to substract the transX and transY to move it
+ // to the coordinate space of the graphics2d.
+ int dstX = x + dx - sg2d.transX;
+ int dstY = y + dy - sg2d.transY;
+ sg2d.drawImage(this.bim, dstX, dstY, dstX + w, dstY + h,
+ x, y, x + w, y + h, null);
// restore the clip
sg2d.setClip(clip);
--- a/jdk/src/java.desktop/macosx/classes/sun/java2d/OSXSurfaceData.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/macosx/classes/sun/java2d/OSXSurfaceData.java Mon Mar 21 09:36:54 2016 -0700
@@ -1094,19 +1094,13 @@
}
/**
- * Clips the copy area to the heavywieght bounds and returns the cliped rectangle. The tricky part here is the
- * passed arguments x, y are in the coordinate space of the sg2d/lightweight comp. In order to do the clipping we
- * translate them to the coordinate space of the surface, and the returned clipped rectangle is in the coordinate
- * space of the surface.
+ * Clips the copy area to the heavyweight bounds and returns the clipped rectangle.
+ * The returned clipped rectangle is in the coordinate space of the surface.
*/
protected Rectangle clipCopyArea(SunGraphics2D sg2d, int x, int y, int w, int h, int dx, int dy) {
// we need to clip against the heavyweight bounds
copyAreaBounds.setBounds(sg2d.devClip.getLoX(), sg2d.devClip.getLoY(), sg2d.devClip.getWidth(), sg2d.devClip.getHeight());
- // put src rect into surface coordinate space
- x += sg2d.transX;
- y += sg2d.transY;
-
// clip src rect
srcCopyAreaRect.setBounds(x, y, w, h);
intersection(srcCopyAreaRect, copyAreaBounds, srcCopyAreaRect);
--- a/jdk/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLSurfaceData.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLSurfaceData.java Mon Mar 21 09:36:54 2016 -0700
@@ -175,31 +175,6 @@
return scale;
}
- @Override
- public boolean copyArea(SunGraphics2D sg2d, int x, int y, int w, int h,
- int dx, int dy) {
- final int state = sg2d.transformState;
- if (state > SunGraphics2D.TRANSFORM_TRANSLATESCALE
- || sg2d.compositeState >= SunGraphics2D.COMP_XOR) {
- return false;
- }
- if (state <= SunGraphics2D.TRANSFORM_ANY_TRANSLATE) {
- x += sg2d.transX;
- y += sg2d.transY;
- } else if (state == SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
- final double[] coords = {x, y, x + w, y + h, x + dx, y + dy};
- sg2d.transform.transform(coords, 0, coords, 0, 3);
- x = (int) Math.ceil(coords[0] - 0.5);
- y = (int) Math.ceil(coords[1] - 0.5);
- w = ((int) Math.ceil(coords[2] - 0.5)) - x;
- h = ((int) Math.ceil(coords[3] - 0.5)) - y;
- dx = ((int) Math.ceil(coords[4] - 0.5)) - x;
- dy = ((int) Math.ceil(coords[5] - 0.5)) - y;
- }
- oglRenderPipe.copyArea(sg2d, x, y, w, h, dx, dy);
- return true;
- }
-
protected native void clearWindow();
public static class CGLWindowSurfaceData extends CGLSurfaceData {
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m Mon Mar 21 09:36:54 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -29,12 +29,12 @@
#import <JavaNativeFoundation/JavaNativeFoundation.h>
#import <ApplicationServices/ApplicationServices.h>
+#import "CRobotKeyCode.h"
#import "LWCToolkit.h"
#import "sun_lwawt_macosx_CRobot.h"
#import "java_awt_event_InputEvent.h"
#import "sizecalc.h"
-
// Starting number for event numbers generated by Robot.
// Apple docs don't mention at all what are the requirements
// for these numbers. It seems that they must be higher
@@ -354,241 +354,10 @@
}
}
-// NOTE: Don't modify this table directly. It is machine generated. See below.
-static const unsigned char javaToMacKeyCode[] = {
- 127, // 0 0 VK_UNDEFINED No_Equivalent
- 127, // 1 0x1 Not_Used
- 127, // 2 0x2 Not_Used
- 127, // 3 0x3 VK_CANCEL No_Equivalent
- 127, // 4 0x4 Not_Used
- 127, // 5 0x5 Not_Used
- 127, // 6 0x6 Not_Used
- 127, // 7 0x7 Not_Used
- 51, // 8 0x8 VK_BACK_SPACE
- 48, // 9 0x9 VK_TAB
- 36, // 10 0xa VK_ENTER
- 127, // 11 0xb Not_Used
- 71, // 12 0xc VK_CLEAR
- 127, // 13 0xd Not_Used
- 127, // 14 0xe Not_Used
- 127, // 15 0xf Not_Used
- 56, // 16 0x10 VK_SHIFT
- 59, // 17 0x11 VK_CONTROL
- 58, // 18 0x12 VK_ALT
- 113, // 19 0x13 VK_PAUSE
- 57, // 20 0x14 VK_CAPS_LOCK
- 127, // 21 0x15 VK_KANA No_Equivalent
- 127, // 22 0x16 Not_Used
- 127, // 23 0x17 Not_Used
- 127, // 24 0x18 VK_FINAL No_Equivalent
- 127, // 25 0x19 VK_KANJI No_Equivalent
- 127, // 26 0x1a Not_Used
- 53, // 27 0x1b VK_ESCAPE
- 127, // 28 0x1c VK_CONVERT No_Equivalent
- 127, // 29 0x1d VK_NONCONVERT No_Equivalent
- 127, // 30 0x1e VK_ACCEPT No_Equivalent
- 127, // 31 0x1f VK_MODECHANGE No_Equivalent
- 49, // 32 0x20 VK_SPACE
- 116, // 33 0x21 VK_PAGE_UP
- 121, // 34 0x22 VK_PAGE_DOWN
- 119, // 35 0x23 VK_END
- 115, // 36 0x24 VK_HOME
- 123, // 37 0x25 VK_LEFT
- 126, // 38 0x26 VK_UP
- 124, // 39 0x27 VK_RIGHT
- 125, // 40 0x28 VK_DOWN
- 127, // 41 0x29 Not_Used
- 127, // 42 0x2a Not_Used
- 127, // 43 0x2b Not_Used
- 43, // 44 0x2c VK_COMMA
- 27, // 45 0x2d VK_MINUS
- 47, // 46 0x2e VK_PERIOD
- 44, // 47 0x2f VK_SLASH
- 29, // 48 0x30 VK_0
- 18, // 49 0x31 VK_1
- 19, // 50 0x32 VK_2
- 20, // 51 0x33 VK_3
- 21, // 52 0x34 VK_4
- 23, // 53 0x35 VK_5
- 22, // 54 0x36 VK_6
- 26, // 55 0x37 VK_7
- 28, // 56 0x38 VK_8
- 25, // 57 0x39 VK_9
- 127, // 58 0x3a Not_Used
- 41, // 59 0x3b VK_SEMICOLON
- 127, // 60 0x3c Not_Used
- 24, // 61 0x3d VK_EQUALS
- 127, // 62 0x3e Not_Used
- 127, // 63 0x3f Not_Used
- 127, // 64 0x40 Not_Used
- 0, // 65 0x41 VK_A
- 11, // 66 0x42 VK_B
- 8, // 67 0x43 VK_C
- 2, // 68 0x44 VK_D
- 14, // 69 0x45 VK_E
- 3, // 70 0x46 VK_F
- 5, // 71 0x47 VK_G
- 4, // 72 0x48 VK_H
- 34, // 73 0x49 VK_I
- 38, // 74 0x4a VK_J
- 40, // 75 0x4b VK_K
- 37, // 76 0x4c VK_L
- 46, // 77 0x4d VK_M
- 45, // 78 0x4e VK_N
- 31, // 79 0x4f VK_O
- 35, // 80 0x50 VK_P
- 12, // 81 0x51 VK_Q
- 15, // 82 0x52 VK_R
- 1, // 83 0x53 VK_S
- 17, // 84 0x54 VK_T
- 32, // 85 0x55 VK_U
- 9, // 86 0x56 VK_V
- 13, // 87 0x57 VK_W
- 7, // 88 0x58 VK_X
- 16, // 89 0x59 VK_Y
- 6, // 90 0x5a VK_Z
- 33, // 91 0x5b VK_OPEN_BRACKET
- 42, // 92 0x5c VK_BACK_SLASH
- 30, // 93 0x5d VK_CLOSE_BRACKET
- 127, // 94 0x5e Not_Used
- 127, // 95 0x5f Not_Used
- 82, // 96 0x60 VK_NUMPAD0
- 83, // 97 0x61 VK_NUMPAD1
- 84, // 98 0x62 VK_NUMPAD2
- 85, // 99 0x63 VK_NUMPAD3
- 86, // 100 0x64 VK_NUMPAD4
- 87, // 101 0x65 VK_NUMPAD5
- 88, // 102 0x66 VK_NUMPAD6
- 89, // 103 0x67 VK_NUMPAD7
- 91, // 104 0x68 VK_NUMPAD8
- 92, // 105 0x69 VK_NUMPAD9
- 67, // 106 0x6a VK_MULTIPLY
- 69, // 107 0x6b VK_ADD
- 127, // 108 0x6c VK_SEPARATER No_Equivalent
- 78, // 109 0x6d VK_SUBTRACT
- 65, // 110 0x6e VK_DECIMAL
- 75, // 111 0x6f VK_DIVIDE
- 122, // 112 0x70 VK_F1
- 120, // 113 0x71 VK_F2
- 99, // 114 0x72 VK_F3
- 118, // 115 0x73 VK_F4
- 96, // 116 0x74 VK_F5
- 97, // 117 0x75 VK_F6
- 98, // 118 0x76 VK_F7
- 100, // 119 0x77 VK_F8
- 101, // 120 0x78 VK_F9
- 109, // 121 0x79 VK_F10
- 103, // 122 0x7a VK_F11
- 111, // 123 0x7b VK_F12
- 127, // 124 0x7c Not_Used
- 127, // 125 0x7d Not_Used
- 127, // 126 0x7e Not_Used
- 117, // 127 0x7f VK_DELETE
- 127, // 128 0x80 VK_DEAD_GRAVE No_Equivalent
- 127, // 129 0x81 VK_DEAD_ACUTE No_Equivalent
- 127, // 130 0x82 VK_DEAD_CIRCUMFLEX No_Equivalent
- 127, // 131 0x83 VK_DEAD_TILDE No_Equivalent
- 127, // 132 0x84 VK_DEAD_MACRON No_Equivalent
- 127, // 133 0x85 VK_DEAD_BREVE No_Equivalent
- 127, // 134 0x86 VK_DEAD_ABOVEDOT No_Equivalent
- 127, // 135 0x87 VK_DEAD_DIAERESIS No_Equivalent
- 127, // 136 0x88 VK_DEAD_ABOVERING No_Equivalent
- 127, // 137 0x89 VK_DEAD_DOUBLEACUTE No_Equivalent
- 127, // 138 0x8a VK_DEAD_CARON No_Equivalent
- 127, // 139 0x8b VK_DEAD_CEDILLA No_Equivalent
- 127, // 140 0x8c VK_DEAD_OGONEK No_Equivalent
- 127, // 141 0x8d VK_DEAD_IOTA No_Equivalent
- 127, // 142 0x8e VK_DEAD_VOICED_SOUND No_Equivalent
- 127, // 143 0x8f VK_DEAD_SEMIVOICED_SOUND No_Equivalent
- 127, // 144 0x90 VK_NUM_LOCK No_Equivalent
- 107, // 145 0x91 VK_SCROLL_LOCK
- 127, // 146 0x92 Not_Used
- 127, // 147 0x93 Not_Used
- 127, // 148 0x94 Not_Used
- 127, // 149 0x95 Not_Used
- 127, // 150 0x96 VK_AMPERSAND No_Equivalent
- 127, // 151 0x97 VK_ASTERISK No_Equivalent
- 127, // 152 0x98 VK_QUOTEDBL No_Equivalent
- 127, // 153 0x99 VK_LESS No_Equivalent
- 105, // 154 0x9a VK_PRINTSCREEN
- 127, // 155 0x9b VK_INSERT No_Equivalent
- 114, // 156 0x9c VK_HELP
- 55, // 157 0x9d VK_META
- 127, // 158 0x9e Not_Used
- 127, // 159 0x9f Not_Used
- 127, // 160 0xa0 VK_GREATER No_Equivalent
- 127, // 161 0xa1 VK_BRACELEFT No_Equivalent
- 127, // 162 0xa2 VK_BRACERIGHT No_Equivalent
- 127, // 163 0xa3 Not_Used
- 127, // 164 0xa4 Not_Used
- 127, // 165 0xa5 Not_Used
- 127, // 166 0xa6 Not_Used
- 127, // 167 0xa7 Not_Used
- 127, // 168 0xa8 Not_Used
- 127, // 169 0xa9 Not_Used
- 127, // 170 0xaa Not_Used
- 127, // 171 0xab Not_Used
- 127, // 172 0xac Not_Used
- 127, // 173 0xad Not_Used
- 127, // 174 0xae Not_Used
- 127, // 175 0xaf Not_Used
- 127, // 176 0xb0 Not_Used
- 127, // 177 0xb1 Not_Used
- 127, // 178 0xb2 Not_Used
- 127, // 179 0xb3 Not_Used
- 127, // 180 0xb4 Not_Used
- 127, // 181 0xb5 Not_Used
- 127, // 182 0xb6 Not_Used
- 127, // 183 0xb7 Not_Used
- 127, // 184 0xb8 Not_Used
- 127, // 185 0xb9 Not_Used
- 127, // 186 0xba Not_Used
- 127, // 187 0xbb Not_Used
- 127, // 188 0xbc Not_Used
- 127, // 189 0xbd Not_Used
- 127, // 190 0xbe Not_Used
- 127, // 191 0xbf Not_Used
- 50, // 192 0xc0 VK_BACK_QUOTE
- 127, // 193 0xc1 Not_Used
- 127, // 194 0xc2 Not_Used
- 127, // 195 0xc3 Not_Used
- 127, // 196 0xc4 Not_Used
- 127, // 197 0xc5 Not_Used
- 127, // 198 0xc6 Not_Used
- 127, // 199 0xc7 Not_Used
- 127, // 200 0xc8 Not_Used
- 127, // 201 0xc9 Not_Used
- 127, // 202 0xca Not_Used
- 127, // 203 0xcb Not_Used
- 127, // 204 0xcc Not_Used
- 127, // 205 0xcd Not_Used
- 127, // 206 0xce Not_Used
- 127, // 207 0xcf Not_Used
- 127, // 208 0xd0 Not_Used
- 127, // 209 0xd1 Not_Used
- 127, // 210 0xd2 Not_Used
- 127, // 211 0xd3 Not_Used
- 127, // 212 0xd4 Not_Used
- 127, // 213 0xd5 Not_Used
- 127, // 214 0xd6 Not_Used
- 127, // 215 0xd7 Not_Used
- 127, // 216 0xd8 Not_Used
- 127, // 217 0xd9 Not_Used
- 127, // 218 0xda Not_Used
- 127, // 219 0xdb Not_Used
- 127, // 220 0xdc Not_Used
- 127, // 221 0xdd Not_Used
- 39 // 222 0xde VK_QUOTE
-};
-
-// NOTE: All values above 222 don't have an equivalent on MacOSX.
static inline CGKeyCode GetCGKeyCode(jint javaKeyCode)
{
- if (javaKeyCode > 222) {
- return 127;
- } else {
- return javaToMacKeyCode[javaKeyCode];
- }
+ CRobotKeyCodeMapping *keyCodeMapping = [CRobotKeyCodeMapping sharedInstance];
+ return [keyCodeMapping getOSXKeyCodeForJavaKey:javaKeyCode];
}
static int GetClickCount(BOOL isDown) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobotKeyCode.h Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+#import <Foundation/Foundation.h>
+
+#ifndef KeyCodeConverter_CRobotKeyCode_h
+#define KeyCodeConverter_CRobotKeyCode_h
+
+const static int OSX_kVK_ANSI_A = 0x00;
+const static int OSX_kVK_ANSI_S = 0x01;
+const static int OSX_kVK_ANSI_D = 0x02;
+const static int OSX_kVK_ANSI_F = 0x03;
+const static int OSX_kVK_ANSI_H = 0x04;
+const static int OSX_kVK_ANSI_G = 0x05;
+const static int OSX_kVK_ANSI_Z = 0x06;
+const static int OSX_kVK_ANSI_X = 0x07;
+const static int OSX_kVK_ANSI_C = 0x08;
+const static int OSX_kVK_ANSI_V = 0x09;
+const static int OSX_kVK_ISO_Section = 0x0A;
+const static int OSX_kVK_ANSI_B = 0x0B;
+const static int OSX_kVK_ANSI_Q = 0x0C;
+const static int OSX_kVK_ANSI_W = 0x0D;
+const static int OSX_kVK_ANSI_E = 0x0E;
+const static int OSX_kVK_ANSI_R = 0x0F;
+const static int OSX_kVK_ANSI_Y = 0x10;
+const static int OSX_kVK_ANSI_T = 0x11;
+const static int OSX_kVK_ANSI_1 = 0x12;
+const static int OSX_kVK_ANSI_2 = 0x13;
+const static int OSX_kVK_ANSI_3 = 0x14;
+const static int OSX_kVK_ANSI_4 = 0x15;
+const static int OSX_kVK_ANSI_6 = 0x16;
+const static int OSX_kVK_ANSI_5 = 0x17;
+const static int OSX_kVK_ANSI_Equal = 0x18;
+const static int OSX_kVK_ANSI_9 = 0x19;
+const static int OSX_kVK_ANSI_7 = 0x1A;
+const static int OSX_kVK_ANSI_Minus = 0x1B;
+const static int OSX_kVK_ANSI_8 = 0x1C;
+const static int OSX_kVK_ANSI_0 = 0x1D;
+const static int OSX_kVK_ANSI_RightBracket = 0x1E;
+const static int OSX_kVK_ANSI_O = 0x1F;
+const static int OSX_kVK_ANSI_U = 0x20;
+const static int OSX_kVK_ANSI_LeftBracket = 0x21;
+const static int OSX_kVK_ANSI_I = 0x22;
+const static int OSX_kVK_ANSI_P = 0x23;
+const static int OSX_kVK_ANSI_L = 0x25;
+const static int OSX_kVK_ANSI_J = 0x26;
+const static int OSX_kVK_ANSI_Quote = 0x27;
+const static int OSX_kVK_ANSI_K = 0x28;
+const static int OSX_kVK_ANSI_Semicolon = 0x29;
+const static int OSX_kVK_ANSI_Backslash = 0x2A;
+const static int OSX_kVK_ANSI_Comma = 0x2B;
+const static int OSX_kVK_ANSI_Slash = 0x2C;
+const static int OSX_kVK_ANSI_N = 0x2D;
+const static int OSX_kVK_ANSI_M = 0x2E;
+const static int OSX_kVK_ANSI_Period = 0x2F;
+const static int OSX_kVK_ANSI_Grave = 0x32;
+const static int OSX_kVK_ANSI_KeypadDecimal = 0x41;
+const static int OSX_kVK_ANSI_KeypadMultiply = 0x43;
+const static int OSX_kVK_ANSI_KeypadPlus = 0x45;
+const static int OSX_kVK_ANSI_KeypadClear = 0x47;
+const static int OSX_kVK_ANSI_KeypadDivide = 0x4B;
+const static int OSX_kVK_ANSI_KeypadEnter = 0x4C;
+const static int OSX_kVK_ANSI_KeypadMinus = 0x4E;
+const static int OSX_kVK_ANSI_KeypadEquals = 0x51;
+const static int OSX_kVK_ANSI_Keypad0 = 0x52;
+const static int OSX_kVK_ANSI_Keypad1 = 0x53;
+const static int OSX_kVK_ANSI_Keypad2 = 0x54;
+const static int OSX_kVK_ANSI_Keypad3 = 0x55;
+const static int OSX_kVK_ANSI_Keypad4 = 0x56;
+const static int OSX_kVK_ANSI_Keypad5 = 0x57;
+const static int OSX_kVK_ANSI_Keypad6 = 0x58;
+const static int OSX_kVK_ANSI_Keypad7 = 0x59;
+const static int OSX_kVK_ANSI_Keypad8 = 0x5B;
+const static int OSX_kVK_ANSI_Keypad9 = 0x5C;
+const static int OSX_kVK_Return = 0x24;
+const static int OSX_kVK_Tab = 0x30;
+const static int OSX_kVK_Space = 0x31;
+const static int OSX_Delete = 0x33;
+const static int OSX_Escape = 0x35;
+const static int OSX_Command = 0x37;
+const static int OSX_Shift = 0x38;
+const static int OSX_CapsLock = 0x39;
+const static int OSX_Option = 0x3A;
+const static int OSX_Control = 0x3B;
+const static int OSX_RightShift = 0x3C;
+const static int OSX_RightOption = 0x3D;
+const static int OSX_RightControl = 0x3E;
+const static int OSX_Function = 0x3F;
+const static int OSX_F17 = 0x40;
+const static int OSX_VolumeUp = 0x48;
+const static int OSX_VolumeDown = 0x49;
+const static int OSX_Mute = 0x4A;
+const static int OSX_F18 = 0x4F;
+const static int OSX_F19 = 0x50;
+const static int OSX_F20 = 0x5A;
+const static int OSX_F5 = 0x60;
+const static int OSX_F6 = 0x61;
+const static int OSX_F7 = 0x62;
+const static int OSX_F3 = 0x63;
+const static int OSX_F8 = 0x64;
+const static int OSX_F9 = 0x65;
+const static int OSX_F11 = 0x67;
+const static int OSX_F13 = 0x69;
+const static int OSX_F16 = 0x6A;
+const static int OSX_F14 = 0x6B;
+const static int OSX_F10 = 0x6D;
+const static int OSX_F12 = 0x6F;
+const static int OSX_F15 = 0x71;
+const static int OSX_Help = 0x72;
+const static int OSX_Home = 0x73;
+const static int OSX_PageUp = 0x74;
+const static int OSX_ForwardDelete = 0x75;
+const static int OSX_F4 = 0x76;
+const static int OSX_End = 0x77;
+const static int OSX_F2 = 0x78;
+const static int OSX_PageDown = 0x79;
+const static int OSX_F1 = 0x7A;
+const static int OSX_LeftArrow = 0x7B;
+const static int OSX_RightArrow = 0x7C;
+const static int OSX_DownArrow = 0x7D;
+const static int OSX_UpArrow = 0x7E;
+const static int OSX_Undefined = 0x7F;
+
+@interface CRobotKeyCodeMapping : NSObject {
+
+}
+
+@property (readwrite, retain) NSDictionary *javaToMacKeyMap;
+
++ (CRobotKeyCodeMapping *)sharedInstance ;
+- (int)getOSXKeyCodeForJavaKey:(int) javaKey;
+
+@end
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobotKeyCode.m Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+#import "CRobotKeyCode.h"
+#import "java_awt_event_KeyEvent.h"
+
+@implementation CRobotKeyCodeMapping
+
+@synthesize javaToMacKeyMap;
+
++(CRobotKeyCodeMapping *) sharedInstance {
+ static CRobotKeyCodeMapping *instance = nil;
+ static dispatch_once_t executeOnce;
+
+ dispatch_once(&executeOnce, ^{
+ instance = [[CRobotKeyCodeMapping alloc] init];
+ });
+
+ return instance;
+}
+
+-(id) init {
+ self = [super init];
+
+ if (nil != self) {
+ javaToMacKeyMap = [NSDictionary dictionaryWithObjectsAndKeys :
+ [NSNumber numberWithInt : OSX_Delete], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_BACK_SPACE],
+ [NSNumber numberWithInt : OSX_kVK_Tab], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_TAB],
+ [NSNumber numberWithInt : OSX_kVK_Return], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_ENTER],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_KeypadClear], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_CLEAR],
+ [NSNumber numberWithInt : OSX_Shift], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_SHIFT],
+ [NSNumber numberWithInt : OSX_Control], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_CONTROL],
+ [NSNumber numberWithInt : OSX_Option], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_ALT],
+ [NSNumber numberWithInt : OSX_CapsLock], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_CAPS_LOCK],
+ [NSNumber numberWithInt : OSX_Escape], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_ESCAPE],
+ [NSNumber numberWithInt : OSX_kVK_Space], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_SPACE],
+ [NSNumber numberWithInt : OSX_PageUp], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_PAGE_UP],
+ [NSNumber numberWithInt : OSX_PageDown], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_PAGE_DOWN],
+ [NSNumber numberWithInt : OSX_End], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_END],
+ [NSNumber numberWithInt : OSX_Home], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_HOME],
+ [NSNumber numberWithInt : OSX_LeftArrow], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_LEFT],
+ [NSNumber numberWithInt : OSX_UpArrow], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_UP],
+ [NSNumber numberWithInt : OSX_RightArrow], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_RIGHT],
+ [NSNumber numberWithInt : OSX_DownArrow], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_DOWN],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Comma], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_COMMA],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Minus], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_MINUS],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Period], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_PERIOD],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Slash], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_SLASH],
+
+ [NSNumber numberWithInt : OSX_kVK_ANSI_0], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_0],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_1], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_1],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_2], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_2],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_3], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_3],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_4], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_4],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_5], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_5],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_6], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_6],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_7], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_7],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_8], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_8],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_9], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_9],
+
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Semicolon], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_SEMICOLON],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Equal], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_EQUALS],
+
+ [NSNumber numberWithInt : OSX_kVK_ANSI_A], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_A],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_B], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_B],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_C], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_C],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_D], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_D],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_E], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_E],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_F], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_G], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_G],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_H], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_H],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_I], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_I],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_J], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_J],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_K], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_K],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_L], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_L],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_M], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_M],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_N], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_N],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_O], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_O],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_P], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_P],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Q], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_Q],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_R], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_R],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_S], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_S],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_T], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_T],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_U], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_U],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_V], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_V],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_W], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_W],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_X], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_X],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Y], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_Y],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Z], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_Z],
+
+ [NSNumber numberWithInt : OSX_kVK_ANSI_LeftBracket], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_OPEN_BRACKET],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Backslash], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_BACK_SLASH],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_RightBracket], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_CLOSE_BRACKET],
+
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Keypad0], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD0],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Keypad1], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD1],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Keypad2], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD2],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Keypad3], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD3],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Keypad4], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD4],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Keypad5], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD5],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Keypad6], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD6],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Keypad7], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD7],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Keypad8], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD8],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Keypad9], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD9],
+
+ [NSNumber numberWithInt : OSX_kVK_ANSI_KeypadMultiply], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_MULTIPLY],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_KeypadPlus], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_ADD],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_KeypadMinus], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_SUBTRACT],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_KeypadDecimal], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_DECIMAL],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_KeypadDivide], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_DIVIDE],
+
+ [NSNumber numberWithInt : OSX_F1], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F1],
+ [NSNumber numberWithInt : OSX_F2], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F2],
+ [NSNumber numberWithInt : OSX_F3], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F3],
+ [NSNumber numberWithInt : OSX_F4], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F4],
+ [NSNumber numberWithInt : OSX_F5], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F5],
+ [NSNumber numberWithInt : OSX_F6], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F6],
+ [NSNumber numberWithInt : OSX_F7], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F7],
+ [NSNumber numberWithInt : OSX_F8], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F8],
+ [NSNumber numberWithInt : OSX_F9], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F9],
+ [NSNumber numberWithInt : OSX_F10], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F10],
+ [NSNumber numberWithInt : OSX_F11], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F11],
+ [NSNumber numberWithInt : OSX_F12], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F12],
+
+ [NSNumber numberWithInt : OSX_ForwardDelete], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_DELETE],
+ [NSNumber numberWithInt : OSX_Help], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_HELP],
+ [NSNumber numberWithInt : OSX_Command], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_META],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Grave], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_BACK_QUOTE],
+ [NSNumber numberWithInt : OSX_kVK_ANSI_Quote], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_QUOTE],
+
+ [NSNumber numberWithInt : OSX_F13], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F13],
+ [NSNumber numberWithInt : OSX_F14], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F14],
+ [NSNumber numberWithInt : OSX_F15], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F15],
+ [NSNumber numberWithInt : OSX_F16], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F16],
+ [NSNumber numberWithInt : OSX_F17], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F17],
+ [NSNumber numberWithInt : OSX_F18], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F18],
+ [NSNumber numberWithInt : OSX_F19], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F19],
+ [NSNumber numberWithInt : OSX_F20], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F20],
+
+ nil];
+ }
+
+ return self;
+}
+
+-(int) getOSXKeyCodeForJavaKey : (int) javaKey {
+ id val = [javaToMacKeyMap objectForKey : [NSNumber numberWithInt : javaKey]];
+
+ if (nil != val) {
+ return [val intValue];
+ } else {
+ return OSX_Undefined;
+ }
+}
+
+@end
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Mon Mar 21 09:36:54 2016 -0700
@@ -698,7 +698,7 @@
// DeskTop.
"Desktop.background", new DesktopProperty(
- "win.desktop.backgroundColor",
+ "win.mdi.backgroundColor",
table.get("desktop")),
"Desktop.ancestorInputMap",
new UIDefaults.LazyInputMap(new Object[] {
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileFormat.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileFormat.java Mon Mar 21 09:36:54 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, 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
@@ -45,11 +45,12 @@
static final int AU_LINEAR_24 = 4; /* 24-bit linear PCM */
static final int AU_LINEAR_32 = 5; /* 32-bit linear PCM */
static final int AU_FLOAT = 6; /* 32-bit IEEE floating point */
- static final int AU_DOUBLE = 7; /* 64-bit IEEE floating point */
- static final int AU_ADPCM_G721 = 23; /* 4-bit CCITT g.721 ADPCM */
- static final int AU_ADPCM_G722 = 24; /* CCITT g.722 ADPCM */
- static final int AU_ADPCM_G723_3 = 25; /* CCITT g.723 3-bit ADPCM */
- static final int AU_ADPCM_G723_5 = 26; /* CCITT g.723 5-bit ADPCM */
+// we don't support these ...
+// static final int AU_DOUBLE = 7; /* 64-bit IEEE floating point */
+// static final int AU_ADPCM_G721 = 23; /* 4-bit CCITT g.721 ADPCM */
+// static final int AU_ADPCM_G722 = 24; /* CCITT g.722 ADPCM */
+// static final int AU_ADPCM_G723_3 = 25; /* CCITT g.723 3-bit ADPCM */
+// static final int AU_ADPCM_G723_5 = 26; /* CCITT g.723 5-bit ADPCM */
static final int AU_ALAW_8 = 27; /* 8-bit ISDN A-law */
static final int AU_HEADERSIZE = 24;
@@ -64,24 +65,28 @@
auType = -1;
- if( AudioFormat.Encoding.ALAW.equals(encoding) ) {
- if( format.getSampleSizeInBits()==8 ) {
+ if (AudioFormat.Encoding.ALAW.equals(encoding)) {
+ if (format.getSampleSizeInBits() == 8) {
auType = AU_ALAW_8;
}
- } else if( AudioFormat.Encoding.ULAW.equals(encoding) ) {
- if( format.getSampleSizeInBits()==8 ) {
+ } else if (AudioFormat.Encoding.ULAW.equals(encoding)) {
+ if (format.getSampleSizeInBits() == 8) {
auType = AU_ULAW_8;
}
- } else if( AudioFormat.Encoding.PCM_SIGNED.equals(encoding) ) {
- if( format.getSampleSizeInBits()==8 ) {
+ } else if (AudioFormat.Encoding.PCM_SIGNED.equals(encoding)) {
+ if (format.getSampleSizeInBits() == 8) {
auType = AU_LINEAR_8;
- } else if( format.getSampleSizeInBits()==16 ) {
+ } else if (format.getSampleSizeInBits() == 16) {
auType = AU_LINEAR_16;
- } else if( format.getSampleSizeInBits()==24 ) {
+ } else if (format.getSampleSizeInBits() == 24) {
auType = AU_LINEAR_24;
- } else if( format.getSampleSizeInBits()==32 ) {
+ } else if (format.getSampleSizeInBits() == 32) {
auType = AU_LINEAR_32;
}
+ } else if (AudioFormat.Encoding.PCM_FLOAT.equals(encoding)) {
+ if (format.getSampleSizeInBits() == 32) {
+ auType = AU_FLOAT;
+ }
}
}
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileReader.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileReader.java Mon Mar 21 09:36:54 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, 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
@@ -30,6 +30,7 @@
import java.io.InputStream;
import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioFileFormat.Type;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
@@ -56,7 +57,7 @@
final int headerSize = dis.readInt();
final int dataSize = dis.readInt();
- final int encoding_local = dis.readInt();
+ final int auType = dis.readInt();
final int sampleRate = dis.readInt();
final int channels = dis.readInt();
if (channels <= 0) {
@@ -65,40 +66,38 @@
final int sampleSizeInBits;
final AudioFormat.Encoding encoding;
- switch (encoding_local) {
- case AuFileFormat.AU_ULAW_8:
- encoding = AudioFormat.Encoding.ULAW;
- sampleSizeInBits = 8;
- break;
- case AuFileFormat.AU_ALAW_8:
- encoding = AudioFormat.Encoding.ALAW;
- sampleSizeInBits = 8;
- break;
- case AuFileFormat.AU_LINEAR_8:
- // $$jb: 04.29.99: 8bit linear is *signed*, not *unsigned*
- encoding = AudioFormat.Encoding.PCM_SIGNED;
- sampleSizeInBits = 8;
- break;
- case AuFileFormat.AU_LINEAR_16:
- encoding = AudioFormat.Encoding.PCM_SIGNED;
- sampleSizeInBits = 16;
- break;
- case AuFileFormat.AU_LINEAR_24:
- encoding = AudioFormat.Encoding.PCM_SIGNED;
-
- sampleSizeInBits = 24;
- break;
- case AuFileFormat.AU_LINEAR_32:
- encoding = AudioFormat.Encoding.PCM_SIGNED;
-
- sampleSizeInBits = 32;
- break;
- // $jb: 03.19.99: we don't support these ...
- /* case AuFileFormat.AU_FLOAT:
- encoding = new AudioFormat.FLOAT;
- sampleSizeInBits = 32;
- break;
- case AuFileFormat.AU_DOUBLE:
+ switch (auType) {
+ case AuFileFormat.AU_ULAW_8:
+ encoding = AudioFormat.Encoding.ULAW;
+ sampleSizeInBits = 8;
+ break;
+ case AuFileFormat.AU_ALAW_8:
+ encoding = AudioFormat.Encoding.ALAW;
+ sampleSizeInBits = 8;
+ break;
+ case AuFileFormat.AU_LINEAR_8:
+ // $$jb: 04.29.99: 8bit linear is *signed*, not *unsigned*
+ encoding = AudioFormat.Encoding.PCM_SIGNED;
+ sampleSizeInBits = 8;
+ break;
+ case AuFileFormat.AU_LINEAR_16:
+ encoding = AudioFormat.Encoding.PCM_SIGNED;
+ sampleSizeInBits = 16;
+ break;
+ case AuFileFormat.AU_LINEAR_24:
+ encoding = AudioFormat.Encoding.PCM_SIGNED;
+ sampleSizeInBits = 24;
+ break;
+ case AuFileFormat.AU_LINEAR_32:
+ encoding = AudioFormat.Encoding.PCM_SIGNED;
+ sampleSizeInBits = 32;
+ break;
+ case AuFileFormat.AU_FLOAT:
+ encoding = AudioFormat.Encoding.PCM_FLOAT;
+ sampleSizeInBits = 32;
+ break;
+ // we don't support these ...
+ /* case AuFileFormat.AU_DOUBLE:
encoding = new AudioFormat.DOUBLE;
sampleSizeInBits = 8;
break;
@@ -117,9 +116,9 @@
SamplePerUnit = 8;
break;
*/
- default:
- // unsupported filetype, throw exception
- throw new UnsupportedAudioFileException("not a valid AU file");
+ default:
+ // unsupported filetype, throw exception
+ throw new UnsupportedAudioFileException("not a valid AU file");
}
final int frameSize = calculatePCMFrameSize(sampleSizeInBits, channels);
@@ -136,7 +135,6 @@
final AudioFormat format = new AudioFormat(encoding, sampleRate,
sampleSizeInBits, channels,
frameSize, sampleRate, true);
- return new AuFileFormat(AudioFileFormat.Type.AU, dataSize + headerSize,
- format, length);
+ return new AuFileFormat(Type.AU, dataSize + headerSize, format, length);
}
}
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileWriter.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileWriter.java Mon Mar 21 09:36:54 2016 -0700
@@ -39,6 +39,7 @@
import java.util.Objects;
import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioFileFormat.Type;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
@@ -59,32 +60,32 @@
* Constructs a new AuFileWriter object.
*/
public AuFileWriter() {
- super(new AudioFileFormat.Type[]{AudioFileFormat.Type.AU});
+ super(new Type[]{Type.AU});
}
@Override
- public AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream) {
+ public Type[] getAudioFileTypes(AudioInputStream stream) {
- AudioFileFormat.Type[] filetypes = new AudioFileFormat.Type[types.length];
+ Type[] filetypes = new Type[types.length];
System.arraycopy(types, 0, filetypes, 0, types.length);
// make sure we can write this stream
AudioFormat format = stream.getFormat();
AudioFormat.Encoding encoding = format.getEncoding();
- if( (AudioFormat.Encoding.ALAW.equals(encoding)) ||
- (AudioFormat.Encoding.ULAW.equals(encoding)) ||
- (AudioFormat.Encoding.PCM_SIGNED.equals(encoding)) ||
- (AudioFormat.Encoding.PCM_UNSIGNED.equals(encoding)) ) {
-
+ if (AudioFormat.Encoding.ALAW.equals(encoding)
+ || AudioFormat.Encoding.ULAW.equals(encoding)
+ || AudioFormat.Encoding.PCM_SIGNED.equals(encoding)
+ || AudioFormat.Encoding.PCM_UNSIGNED.equals(encoding)
+ || AudioFormat.Encoding.PCM_FLOAT.equals(encoding)) {
return filetypes;
}
- return new AudioFileFormat.Type[0];
+ return new Type[0];
}
@Override
- public int write(AudioInputStream stream, AudioFileFormat.Type fileType, OutputStream out) throws IOException {
+ public int write(AudioInputStream stream, Type fileType, OutputStream out) throws IOException {
Objects.requireNonNull(stream);
Objects.requireNonNull(fileType);
Objects.requireNonNull(out);
@@ -101,7 +102,7 @@
}
@Override
- public int write(AudioInputStream stream, AudioFileFormat.Type fileType, File out) throws IOException {
+ public int write(AudioInputStream stream, Type fileType, File out) throws IOException {
Objects.requireNonNull(stream);
Objects.requireNonNull(fileType);
Objects.requireNonNull(out);
@@ -141,61 +142,35 @@
* Returns the AudioFileFormat describing the file that will be written from this AudioInputStream.
* Throws IllegalArgumentException if not supported.
*/
- private AudioFileFormat getAudioFileFormat(AudioFileFormat.Type type, AudioInputStream stream) {
+ private AudioFileFormat getAudioFileFormat(Type type, AudioInputStream stream) {
if (!isFileTypeSupported(type, stream)) {
throw new IllegalArgumentException("File type " + type + " not supported.");
}
- AudioFormat format = null;
- AuFileFormat fileFormat = null;
- AudioFormat.Encoding encoding = AudioFormat.Encoding.PCM_SIGNED;
-
AudioFormat streamFormat = stream.getFormat();
- AudioFormat.Encoding streamEncoding = streamFormat.getEncoding();
-
-
- int sampleSizeInBits;
- int fileSize;
+ AudioFormat.Encoding encoding = streamFormat.getEncoding();
- if( (AudioFormat.Encoding.ALAW.equals(streamEncoding)) ||
- (AudioFormat.Encoding.ULAW.equals(streamEncoding)) ) {
-
- encoding = streamEncoding;
- sampleSizeInBits = streamFormat.getSampleSizeInBits();
-
- } else if ( streamFormat.getSampleSizeInBits()==8 ) {
-
+ if (AudioFormat.Encoding.PCM_UNSIGNED.equals(encoding)) {
encoding = AudioFormat.Encoding.PCM_SIGNED;
- sampleSizeInBits=8;
-
- } else {
-
- encoding = AudioFormat.Encoding.PCM_SIGNED;
- sampleSizeInBits=streamFormat.getSampleSizeInBits();
}
+ // We always write big endian au files, this is by far the standard
+ AudioFormat format = new AudioFormat(encoding,
+ streamFormat.getSampleRate(),
+ streamFormat.getSampleSizeInBits(),
+ streamFormat.getChannels(),
+ streamFormat.getFrameSize(),
+ streamFormat.getFrameRate(), true);
- format = new AudioFormat( encoding,
- streamFormat.getSampleRate(),
- sampleSizeInBits,
- streamFormat.getChannels(),
- streamFormat.getFrameSize(),
- streamFormat.getFrameRate(),
- true); // AU is always big endian
-
-
- if( stream.getFrameLength()!=AudioSystem.NOT_SPECIFIED ) {
+ int fileSize;
+ if (stream.getFrameLength() != AudioSystem.NOT_SPECIFIED) {
fileSize = (int)stream.getFrameLength()*streamFormat.getFrameSize() + AuFileFormat.AU_HEADERSIZE;
} else {
fileSize = AudioSystem.NOT_SPECIFIED;
}
- fileFormat = new AuFileFormat( AudioFileFormat.Type.AU,
- fileSize,
- format,
- (int)stream.getFrameLength() );
-
- return fileFormat;
+ return new AuFileFormat(Type.AU, fileSize, format,
+ (int) stream.getFrameLength());
}
private InputStream getFileStream(AuFileFormat auFileFormat, AudioInputStream audioStream) throws IOException {
@@ -212,7 +187,7 @@
if (dataSizeInBytes>0x7FFFFFFFl) {
dataSizeInBytes=UNKNOWN_SIZE;
}
- int encoding_local = auFileFormat.getAuType();
+ int auType = auFileFormat.getAuType();
int sampleRate = (int)format.getSampleRate();
int channels = format.getChannels();
@@ -222,43 +197,17 @@
DataOutputStream dos = null;
SequenceInputStream auStream = null;
- AudioFormat audioStreamFormat = null;
- AudioFormat.Encoding encoding = null;
- InputStream codedAudioStream = audioStream;
-
- // if we need to do any format conversion, do it here.
-
- codedAudioStream = audioStream;
-
- audioStreamFormat = audioStream.getFormat();
- encoding = audioStreamFormat.getEncoding();
-
+ // if we need to do any format conversion, we do it here.
//$$ fb 2001-07-13: Bug 4391108
- if( (AudioFormat.Encoding.PCM_UNSIGNED.equals(encoding)) ||
- (AudioFormat.Encoding.PCM_SIGNED.equals(encoding)
- && !audioStreamFormat.isBigEndian()) ) {
- // We always write big endian au files, this is by far the standard
- codedAudioStream = AudioSystem.getAudioInputStream( new AudioFormat (
- AudioFormat.Encoding.PCM_SIGNED,
- audioStreamFormat.getSampleRate(),
- audioStreamFormat.getSampleSizeInBits(),
- audioStreamFormat.getChannels(),
- audioStreamFormat.getFrameSize(),
- audioStreamFormat.getFrameRate(),
- true),
- audioStream );
-
-
- }
+ audioStream = AudioSystem.getAudioInputStream(format, audioStream);
baos = new ByteArrayOutputStream();
dos = new DataOutputStream(baos);
-
dos.writeInt(AuFileFormat.AU_SUN_MAGIC);
dos.writeInt(headerSize);
dos.writeInt((int)dataSizeInBytes);
- dos.writeInt(encoding_local);
+ dos.writeInt(auType);
dos.writeInt(sampleRate);
dos.writeInt(channels);
@@ -269,7 +218,7 @@
header = baos.toByteArray();
headerStream = new ByteArrayInputStream( header );
auStream = new SequenceInputStream(headerStream,
- new NoCloseInputStream(codedAudioStream));
+ new NoCloseInputStream(audioStream));
return auStream;
}
--- a/jdk/src/java.desktop/share/classes/java/awt/SplashScreen.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/java/awt/SplashScreen.java Mon Mar 21 09:36:54 2016 -0700
@@ -251,7 +251,7 @@
assert scale > 0;
if (scale > 0 && scale != 1) {
bounds.setSize((int) (bounds.getWidth() / scale),
- (int) (bounds.getWidth() / scale));
+ (int) (bounds.getHeight() / scale));
}
return bounds;
}
--- a/jdk/src/java.desktop/share/classes/javax/imageio/ImageTypeSpecifier.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/ImageTypeSpecifier.java Mon Mar 21 09:36:54 2016 -0700
@@ -997,7 +997,7 @@
* negative or greater than the largest band index.
*/
public int getBitsPerBand(int band) {
- if (band < 0 | band >= getNumBands()) {
+ if (band < 0 || band >= getNumBands()) {
throw new IllegalArgumentException("band out of range!");
}
return sampleModel.getSampleSize(band);
--- a/jdk/src/java.desktop/share/classes/javax/swing/DefaultDesktopManager.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/DefaultDesktopManager.java Mon Mar 21 09:36:54 2016 -0700
@@ -129,8 +129,12 @@
} catch (PropertyVetoException e2) {
}
} else {
+ Container c = f.getParent();
+ if (c == null) {
+ return;
+ }
f.setNormalBounds(f.getBounds());
- Rectangle desktopBounds = f.getParent().getBounds();
+ Rectangle desktopBounds = c.getBounds();
setBoundsForFrame(f, 0, 0,
desktopBounds.width, desktopBounds.height);
}
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java Mon Mar 21 09:36:54 2016 -0700
@@ -1719,6 +1719,9 @@
if ((frame.getParent() != null) && !componentListenerAdded) {
f.getParent().addComponentListener(componentListener);
componentListenerAdded = true;
+ if (f.isMaximum()) {
+ maximizeFrame(f);
+ }
}
} else if (JInternalFrame.TITLE_PROPERTY == prop ||
prop == "closable" || prop == "iconable" ||
--- a/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java Mon Mar 21 09:36:54 2016 -0700
@@ -2101,13 +2101,39 @@
if (w <= 0 || h <= 0) {
return;
}
+
+ if (transformState == SunGraphics2D.TRANSFORM_ISIDENT) {
+ // do nothing
+ } else if (transformState <= SunGraphics2D.TRANSFORM_ANY_TRANSLATE) {
+ x += transX;
+ y += transY;
+ } else if (transformState == SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
+ final double[] coords = {x, y, x + w, y + h, x + dx, y + dy};
+ transform.transform(coords, 0, coords, 0, 3);
+ x = (int) Math.ceil(coords[0] - 0.5);
+ y = (int) Math.ceil(coords[1] - 0.5);
+ w = ((int) Math.ceil(coords[2] - 0.5)) - x;
+ h = ((int) Math.ceil(coords[3] - 0.5)) - y;
+ dx = ((int) Math.ceil(coords[4] - 0.5)) - x;
+ dy = ((int) Math.ceil(coords[5] - 0.5)) - y;
+ // In case of negative scale transform, reflect the rect coords.
+ if (w < 0) {
+ w = -w;
+ x -= w;
+ }
+ if (h < 0) {
+ h = -h;
+ y -= h;
+ }
+ } else {
+ throw new InternalError("transformed copyArea not implemented yet");
+ }
+
SurfaceData theData = surfaceData;
if (theData.copyArea(this, x, y, w, h, dx, dy)) {
return;
}
- if (transformState > TRANSFORM_TRANSLATESCALE) {
- throw new InternalError("transformed copyArea not implemented yet");
- }
+
// REMIND: This method does not deal with missing data from the
// source object (i.e. it does not send exposure events...)
@@ -2126,26 +2152,6 @@
lastCAcomp = comp;
}
- double[] coords = {x, y, x + w, y + h, x + dx, y + dy};
- transform.transform(coords, 0, coords, 0, 3);
-
- x = (int)Math.ceil(coords[0] - 0.5);
- y = (int)Math.ceil(coords[1] - 0.5);
- w = ((int)Math.ceil(coords[2] - 0.5)) - x;
- h = ((int)Math.ceil(coords[3] - 0.5)) - y;
- dx = ((int)Math.ceil(coords[4] - 0.5)) - x;
- dy = ((int)Math.ceil(coords[5] - 0.5)) - y;
-
- // In case of negative scale transform, reflect the rect coords.
- if (w < 0) {
- w *= -1;
- x -= w;
- }
- if (h < 0) {
- h *= -1;
- y -= h;
- }
-
Blit ob = lastCAblit;
if (dy == 0 && dx > 0 && dx < w) {
while (w > 0) {
@@ -2167,7 +2173,7 @@
}
return;
}
- ob.Blit(theData, theData, comp, clip, x, y, x+dx, y+dy, w, h);
+ ob.Blit(theData, theData, comp, clip, x, y, x+dx, y+dy, w, h);
}
/*
--- a/jdk/src/java.desktop/share/classes/sun/java2d/SurfaceData.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/SurfaceData.java Mon Mar 21 09:36:54 2016 -0700
@@ -1039,6 +1039,11 @@
* Performs a copyarea within this surface. Returns
* false if there is no algorithm to perform the copyarea
* given the current settings of the SunGraphics2D.
+ *
+ * @param x the x coordinate of the area in device space
+ * @param y the y coordinate of the area in device space
+ * @param w the width of the area in device space
+ * @param h the height of the area in device space
*/
public boolean copyArea(SunGraphics2D sg2d,
int x, int y, int w, int h, int dx, int dy)
--- a/jdk/src/java.desktop/share/classes/sun/java2d/opengl/OGLSurfaceData.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/opengl/OGLSurfaceData.java Mon Mar 21 09:36:54 2016 -0700
@@ -542,20 +542,14 @@
return super.getMaskFill(sg2d);
}
- public boolean copyArea(SunGraphics2D sg2d,
- int x, int y, int w, int h, int dx, int dy)
- {
- if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
- sg2d.compositeState < SunGraphics2D.COMP_XOR)
- {
- x += sg2d.transX;
- y += sg2d.transY;
-
- oglRenderPipe.copyArea(sg2d, x, y, w, h, dx, dy);
-
- return true;
+ @Override
+ public boolean copyArea(SunGraphics2D sg2d, int x, int y, int w, int h,
+ int dx, int dy) {
+ if (sg2d.compositeState >= SunGraphics2D.COMP_XOR) {
+ return false;
}
- return false;
+ oglRenderPipe.copyArea(sg2d, x, y, w, h, dx, dy);
+ return true;
}
public void flush() {
--- a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/DrawImage.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/DrawImage.java Mon Mar 21 09:36:54 2016 -0700
@@ -340,8 +340,8 @@
* <li> Image will be used only once and acceleration caching wouldn't help
* </ul>
*/
- BufferedImage makeBufferedImage(Image img, Color bgColor, int type,
- int sx1, int sy1, int sx2, int sy2)
+ private BufferedImage makeBufferedImage(Image img, Color bgColor, int type,
+ int sx1, int sy1, int sx2, int sy2)
{
final int width = sx2 - sx1;
final int height = sy2 - sy1;
@@ -430,10 +430,16 @@
if (isBgOperation(srcData, bgColor)) {
// We cannot perform bg operations during transform so make
- // an opaque temp image with the appropriate background
- // and work from there.
- img = makeBufferedImage(img, bgColor, BufferedImage.TYPE_INT_RGB,
- sx1, sy1, sx2, sy2);
+ // a temp image with the appropriate background based on
+ // background alpha value and work from there. If background
+ // alpha is opaque use INT_RGB else use INT_ARGB so that we
+ // will not lose translucency of background.
+
+ int bgAlpha = bgColor.getAlpha();
+ int type = ((bgAlpha == 255)
+ ? BufferedImage.TYPE_INT_RGB
+ : BufferedImage.TYPE_INT_ARGB);
+ img = makeBufferedImage(img, bgColor, type, sx1, sy1, sx2, sy2);
// Temp image has appropriate subimage at 0,0 now.
sx2 -= sx1;
sy2 -= sy1;
--- a/jdk/src/java.desktop/share/classes/sun/print/PrintJob2D.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/print/PrintJob2D.java Mon Mar 21 09:36:54 2016 -0700
@@ -995,6 +995,7 @@
public void run() {
try {
+ attributes.remove(PageRanges.class);
printerJob.print(attributes);
} catch (PrinterException e) {
//REMIND: need to store this away and not rethrow it.
--- a/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java Mon Mar 21 09:36:54 2016 -0700
@@ -1212,6 +1212,7 @@
pageRangesAttr = (PageRanges)attributes.get(PageRanges.class);
if (!isSupportedValue(pageRangesAttr, attributes)) {
pageRangesAttr = null;
+ setPageRange(-1, -1);
} else {
if ((SunPageSelection)attributes.get(SunPageSelection.class)
== SunPageSelection.RANGE) {
--- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc Mon Mar 21 09:36:54 2016 -0700
@@ -293,7 +293,7 @@
return NULL;
}
length = env->GetArrayLength(tableBytes);
- buffer = new jbyte[length];
+ buffer = (jbyte *)calloc(length, sizeof(jbyte));
env->GetByteArrayRegion(tableBytes, 0, length, buffer);
return hb_blob_create((const char *)buffer, length,
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java Mon Mar 21 09:36:54 2016 -0700
@@ -1008,13 +1008,10 @@
// if ( Check if it's a resize, a move, or a stacking order change )
// {
Rectangle bounds = getBounds();
- final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
if (!bounds.getSize().equals(oldBounds.getSize())) {
- acc.setSize(target, bounds.width, bounds.height);
postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_RESIZED));
}
if (!bounds.getLocation().equals(oldBounds.getLocation())) {
- acc.setLocation(target, bounds.x, bounds.y);
postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_MOVED));
}
// }
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java Mon Mar 21 09:36:54 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, 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
@@ -87,7 +87,7 @@
// used for modal blocking to keep existing z-order
protected XWindowPeer prevTransientFor, nextTransientFor;
// value of WM_TRANSIENT_FOR hint set on this window
- private XWindowPeer curRealTransientFor;
+ private XBaseWindow curRealTransientFor;
private boolean grab = false; // Whether to do a grab during showing
@@ -803,23 +803,31 @@
*/
@Override
public void handleConfigureNotifyEvent(XEvent xev) {
+ assert (SunToolkit.isAWTLockHeldByCurrentThread());
XConfigureEvent xe = xev.get_xconfigure();
- /*
- * Correct window location which could be wrong in some cases.
- * See getNewLocation() for the details.
- */
- Point newLocation = getNewLocation(xe, 0, 0);
- xe.set_x(scaleUp(newLocation.x));
- xe.set_y(scaleUp(newLocation.y));
- checkIfOnNewScreen(new Rectangle(newLocation.x,
- newLocation.y,
- scaleDown(xe.get_width()),
- scaleDown(xe.get_height())));
+ if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
+ insLog.fine(xe.toString());
+ }
+ checkIfOnNewScreen(toGlobal(new Rectangle(scaleDown(xe.get_x()),
+ scaleDown(xe.get_y()),
+ scaleDown(xe.get_width()),
+ scaleDown(xe.get_height()))));
+
+ Rectangle oldBounds = getBounds();
- // Don't call super until we've handled a screen change. Otherwise
- // there could be a race condition in which a ComponentListener could
- // see the old screen.
- super.handleConfigureNotifyEvent(xev);
+ x = scaleDown(xe.get_x());
+ y = scaleDown(xe.get_y());
+ width = scaleDown(xe.get_width());
+ height = scaleDown(xe.get_height());
+
+ if (!getBounds().getSize().equals(oldBounds.getSize())) {
+ AWTAccessor.getComponentAccessor().setSize(target, width, height);
+ postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_RESIZED));
+ }
+ if (!getBounds().getLocation().equals(oldBounds.getLocation())) {
+ AWTAccessor.getComponentAccessor().setLocation(target, x, y);
+ postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED));
+ }
repositionSecurityWarning();
}
@@ -1057,13 +1065,23 @@
log.fine("Promoting always-on-top state {0}", Boolean.valueOf(alwaysOnTop));
}
XWM.getWM().setLayer(this,
- alwaysOnTop ?
- XLayerProtocol.LAYER_ALWAYS_ON_TOP :
- XLayerProtocol.LAYER_NORMAL);
+ alwaysOnTop ?
+ XLayerProtocol.LAYER_ALWAYS_ON_TOP :
+ XLayerProtocol.LAYER_NORMAL);
}
public void updateAlwaysOnTopState() {
this.alwaysOnTop = ((Window) this.target).isAlwaysOnTop();
+ if (ownerPeer != null) {
+ XToolkit.awtLock();
+ try {
+ restoreTransientFor(this);
+ applyWindowType();
+ }
+ finally {
+ XToolkit.awtUnlock();
+ }
+ }
updateAlwaysOnTop();
}
@@ -1107,7 +1125,27 @@
if (!vis && warningWindow != null) {
warningWindow.setSecurityWarningVisible(false, false);
}
+ boolean refreshChildsTransientFor = isVisible() != vis;
super.setVisible(vis);
+ if (refreshChildsTransientFor) {
+ for (Window child : ((Window) target).getOwnedWindows()) {
+ XToolkit.awtLock();
+ try {
+ if(!child.isLightweight() && child.isVisible()) {
+ ComponentPeer childPeer = AWTAccessor.
+ getComponentAccessor().getPeer(child);
+ if(childPeer instanceof XWindowPeer) {
+ XWindowPeer windowPeer = (XWindowPeer) childPeer;
+ restoreTransientFor(windowPeer);
+ windowPeer.applyWindowType();
+ }
+ }
+ }
+ finally {
+ XToolkit.awtUnlock();
+ }
+ }
+ }
if (!vis && !isWithdrawn()) {
// ICCCM, 4.1.4. Changing Window State:
// "Iconic -> Withdrawn - The client should unmap the window and follow it
@@ -1636,9 +1674,6 @@
window.prevTransientFor = transientForWindow;
transientForWindow.nextTransientFor = window;
}
- if (window.curRealTransientFor == transientForWindow) {
- return;
- }
if (!allStates && (window.getWMState() != transientForWindow.getWMState())) {
return;
}
@@ -1650,11 +1685,14 @@
bpw = XlibUtil.getParentWindow(bpw);
}
long tpw = transientForWindow.getWindow();
- while (!XlibUtil.isToplevelWindow(tpw) && !XlibUtil.isXAWTToplevelWindow(tpw)) {
+ XBaseWindow parent = transientForWindow;
+ while (tpw != 0 && ((!XlibUtil.isToplevelWindow(tpw) &&
+ !XlibUtil.isXAWTToplevelWindow(tpw)) || !parent.isVisible())) {
tpw = XlibUtil.getParentWindow(tpw);
+ parent = XToolkit.windowToXWindow(tpw);
}
XlibWrapper.XSetTransientFor(XToolkit.getDisplay(), bpw, tpw);
- window.curRealTransientFor = transientForWindow;
+ window.curRealTransientFor = parent;
}
/*
@@ -1948,7 +1986,7 @@
switch (getWindowType())
{
case NORMAL:
- typeAtom = (ownerPeer == null) ?
+ typeAtom = curRealTransientFor == null ?
protocol.XA_NET_WM_WINDOW_TYPE_NORMAL :
protocol.XA_NET_WM_WINDOW_TYPE_DIALOG;
break;
--- a/jdk/src/java.desktop/unix/classes/sun/java2d/x11/X11SurfaceData.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/java2d/x11/X11SurfaceData.java Mon Mar 21 09:36:54 2016 -0700
@@ -487,12 +487,9 @@
makePipes();
}
CompositeType comptype = sg2d.imageComp;
- if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
- (CompositeType.SrcOverNoEa.equals(comptype) ||
+ if ((CompositeType.SrcOverNoEa.equals(comptype) ||
CompositeType.SrcNoEa.equals(comptype)))
{
- x += sg2d.transX;
- y += sg2d.transY;
SunToolkit.awtLock();
try {
boolean needExposures = canSourceSendExposures(x, y, w, h);
--- a/jdk/src/java.desktop/unix/classes/sun/java2d/xr/XRSurfaceData.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/java2d/xr/XRSurfaceData.java Mon Mar 21 09:36:54 2016 -0700
@@ -365,12 +365,9 @@
makePipes();
}
CompositeType comptype = sg2d.imageComp;
- if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
- (CompositeType.SrcOverNoEa.equals(comptype) ||
- CompositeType.SrcNoEa.equals(comptype)))
+ if (CompositeType.SrcOverNoEa.equals(comptype) ||
+ CompositeType.SrcNoEa.equals(comptype))
{
- x += sg2d.transX;
- y += sg2d.transY;
try {
SunToolkit.awtLock();
boolean needExposures = canSourceSendExposures(x, y, w, h);
--- a/jdk/src/java.desktop/unix/classes/sun/print/IPPPrintService.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/print/IPPPrintService.java Mon Mar 21 09:36:54 2016 -0700
@@ -929,6 +929,7 @@
DocFlavor[] flavor = new DocFlavor[2];
flavor[0] = DocFlavor.SERVICE_FORMATTED.PAGEABLE;
flavor[1] = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
+ supportedDocFlavors = flavor;
return flavor;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.c Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2016, 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.
+*/
+
+#include "systemScale.h"
+#include <stdlib.h>
+
+int getNativeScaleFactor() {
+
+ static int scale = -2.0;
+
+ if (scale == -2) {
+ scale = getScale("J2D_UISCALE");
+ }
+
+ if (scale >= 1) {
+ return (int) scale;
+ }
+ return getScale("GDK_SCALE");
+}
+
+int getScale(const char *name) {
+ char *uiScale = getenv(name);
+ if (uiScale != NULL) {
+ double scale = strtod(uiScale, NULL);
+ if (scale < 1) {
+ return -1;
+ }
+ return (int) scale;
+ }
+ return -1;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.h Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2016, 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.
+*/
+#ifndef _AWT_SYSTEMSCALE_H
+#define _AWT_SYSTEMSCALE_H
+
+#include <signal.h>
+#include <stdlib.h>
+
+int getNativeScaleFactor();
+int getScale(const char *uiScale);
+
+#endif
+
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c Mon Mar 21 09:36:54 2016 -0700
@@ -43,7 +43,7 @@
#include <jvm.h>
#include <jvm_md.h>
#include <jlong.h>
-
+#include "systemScale.h"
#include <stdlib.h>
#include "awt_GraphicsEnv.h"
@@ -2083,17 +2083,6 @@
* End DisplayMode/FullScreen support
*/
-int getScale(const char *name) {
- char *uiScale = getenv(name);
- if (uiScale != NULL) {
- double scale = strtod(uiScale, NULL);
- if (errno == ERANGE || scale < 1) {
- return -1;
- }
- return (int) scale;
- }
- return -1;
-}
/*
* Class: sun_awt_X11GraphicsDevice
@@ -2104,16 +2093,5 @@
Java_sun_awt_X11GraphicsDevice_getNativeScaleFactor
(JNIEnv *env, jobject this, jint screen) {
- // for debug purposes
- static int scale = -2.0;
-
- if (scale == -2) {
- scale = getScale("J2D_UISCALE");
- }
-
- if (scale >= 1) {
- return scale;
- }
-
- return getScale("GDK_SCALE");
+ return getNativeScaleFactor();
}
--- a/jdk/src/java.desktop/unix/native/libsplashscreen/splashscreen_config.h Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/unix/native/libsplashscreen/splashscreen_config.h Mon Mar 21 09:36:54 2016 -0700
@@ -39,6 +39,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+#include "systemScale.h"
typedef uint32_t rgbquad_t;
typedef uint16_t word_t;
@@ -57,5 +58,4 @@
#define INLINE static
#define SPLASHEXPORT
-
#endif
--- a/jdk/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c Mon Mar 21 09:36:54 2016 -0700
@@ -802,5 +802,51 @@
float *scaleFactor)
{
*scaleFactor = 1;
+#ifndef __linux__
+ return NULL;
+#endif
+ *scaleFactor = getNativeScaleFactor();
+ if (*scaleFactor == 2.0) {
+ char *scaledImgName = NULL;
+ size_t length = 0;
+ char *stringToAppend = ".java-scale2x";
+ char *dupFileName = strdup(fileName);
+ char *fileExtension = strrchr(dupFileName, '.');
+ if (fileExtension == NULL) {
+ length = strlen(dupFileName) + strlen(stringToAppend) + 1;
+ scaledImgName = SAFE_SIZE_ARRAY_ALLOC(malloc, length, sizeof (char));
+ int retVal = snprintf(scaledImgName, length, "%s%s",
+ dupFileName, stringToAppend);
+ if(retVal < 0 || (retVal != length - 1)) {
+ free(scaledImgName);
+ free(dupFileName);
+ *scaleFactor = 1;
+ return NULL;
+ }
+ } else {
+ int length_without_ext = fileExtension - dupFileName;
+ length = length_without_ext +
+ strlen(stringToAppend) + strlen(fileExtension) + 1;
+ scaledImgName = SAFE_SIZE_ARRAY_ALLOC(malloc, length, sizeof (char));
+ int retVal = snprintf(scaledImgName, length, "%.*s%s%s",
+ length_without_ext, dupFileName, stringToAppend, fileExtension);
+ if(retVal < 0 || retVal != length - 1) {
+ free(scaledImgName);
+ free(dupFileName);
+ *scaleFactor = 1;
+ return NULL;
+ }
+ }
+ free(dupFileName);
+ FILE *fp;
+ if (!(fp = fopen(scaledImgName, "r"))) {
+ *scaleFactor = 1;
+ free(scaledImgName);
+ return NULL;
+ }
+ fclose(fp);
+ return scaledImgName;
+ }
return NULL;
}
+
--- a/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DSurfaceData.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DSurfaceData.java Mon Mar 21 09:36:54 2016 -0700
@@ -703,20 +703,13 @@
}
@Override
- public boolean copyArea(SunGraphics2D sg2d,
- int x, int y, int w, int h, int dx, int dy)
- {
- if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
- sg2d.compositeState < SunGraphics2D.COMP_XOR)
- {
- x += sg2d.transX;
- y += sg2d.transY;
-
- d3dRenderPipe.copyArea(sg2d, x, y, w, h, dx, dy);
-
- return true;
+ public boolean copyArea(SunGraphics2D sg2d, int x, int y, int w, int h,
+ int dx, int dy) {
+ if (sg2d.compositeState >= SunGraphics2D.COMP_XOR) {
+ return false;
}
- return false;
+ d3dRenderPipe.copyArea(sg2d, x, y, w, h, dx, dy);
+ return true;
}
@Override
--- a/jdk/src/java.desktop/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java Mon Mar 21 09:36:54 2016 -0700
@@ -311,13 +311,10 @@
int x, int y, int w, int h, int dx, int dy)
{
CompositeType comptype = sg2d.imageComp;
- if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
- sg2d.clipState != SunGraphics2D.CLIP_SHAPE &&
+ if (sg2d.clipState != SunGraphics2D.CLIP_SHAPE &&
(CompositeType.SrcOverNoEa.equals(comptype) ||
CompositeType.SrcNoEa.equals(comptype)))
{
- x += sg2d.transX;
- y += sg2d.transY;
int dstx1 = x + dx;
int dsty1 = y + dy;
int dstx2 = dstx1 + w;
--- a/jdk/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp Mon Mar 21 09:36:54 2016 -0700
@@ -31,6 +31,8 @@
#include "awt_Object.h"
#include "awt_Component.h"
+#include "math.h"
+
// Important note about VC6 and VC7 (or XP Platform SDK) !
//
// These type definitions have been imported from UxTheme.h
@@ -745,6 +747,23 @@
return NULL;
}
+void rescale(SIZE *size) {
+ HWND hWnd = ::GetDesktopWindow();
+ HDC hDC = ::GetDC(hWnd);
+ int dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX);
+ int dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY);
+
+ if (dpiX !=0 && dpiX != 96) {
+ float invScaleX = 96.0f / dpiX;
+ size->cx = (int)round(size->cx * invScaleX);
+ }
+ if (dpiY != 0 && dpiY != 96) {
+ float invScaleY = 96.0f / dpiY;
+ size->cy = (int)round(size->cy * invScaleY);
+ }
+ ::ReleaseDC(hWnd, hDC);
+}
+
/*
* Class: sun_awt_windows_ThemeReader
* Method: getPartSize
@@ -770,6 +789,8 @@
dimMID = env->GetMethodID(dimClassID, "<init>", "(II)V");
CHECK_NULL_RETURN(dimMID, NULL);
}
+
+ rescale(&size);
jobject dimObj = env->NewObject(dimClassID, dimMID, size.cx, size.cy);
if (safe_ExceptionOccurred(env)) {
env->ExceptionDescribe();
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp Mon Mar 21 09:36:54 2016 -0700
@@ -35,6 +35,8 @@
#include <shellapi.h>
#include <shlobj.h>
+#include "math.h"
+
// WDesktopProperties fields
jfieldID AwtDesktopProperties::pDataID = 0;
jmethodID AwtDesktopProperties::setBooleanPropertyID = 0;
@@ -79,18 +81,35 @@
}
}
+void getInvScale(float &invScaleX, float &invScaleY) {
+ HWND hWnd = ::GetDesktopWindow();
+ HDC hDC = ::GetDC(hWnd);
+ int dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX);
+ int dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY);
+ ::ReleaseDC(hWnd, hDC);
+ invScaleX = (dpiX == 0.0f) ? 1.0f : 96.0f / dpiX;
+ invScaleY = (dpiY == 0.0f) ? 1.0f : 96.0f / dpiY;
+}
+
+int rescale(int value, float invScale){
+ return invScale == 1.0f ? value : (int)round(value * invScale);
+}
+
void AwtDesktopProperties::GetSystemProperties() {
HDC dc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
if (dc != NULL) {
try {
- SetFontProperty(dc, ANSI_FIXED_FONT, TEXT("win.ansiFixed.font"));
- SetFontProperty(dc, ANSI_VAR_FONT, TEXT("win.ansiVar.font"));
- SetFontProperty(dc, DEVICE_DEFAULT_FONT, TEXT("win.deviceDefault.font"));
- SetFontProperty(dc, DEFAULT_GUI_FONT, TEXT("win.defaultGUI.font"));
- SetFontProperty(dc, OEM_FIXED_FONT, TEXT("win.oemFixed.font"));
- SetFontProperty(dc, SYSTEM_FONT, TEXT("win.system.font"));
- SetFontProperty(dc, SYSTEM_FIXED_FONT, TEXT("win.systemFixed.font"));
+ float invScaleX;
+ float invScaleY;
+ getInvScale(invScaleX, invScaleY);
+ SetFontProperty(dc, ANSI_FIXED_FONT, TEXT("win.ansiFixed.font"), 1.0f);
+ SetFontProperty(dc, ANSI_VAR_FONT, TEXT("win.ansiVar.font"), 1.0f);
+ SetFontProperty(dc, DEVICE_DEFAULT_FONT, TEXT("win.deviceDefault.font"), 1.0f);
+ SetFontProperty(dc, DEFAULT_GUI_FONT, TEXT("win.defaultGUI.font"), invScaleY);
+ SetFontProperty(dc, OEM_FIXED_FONT, TEXT("win.oemFixed.font"), 1.0f);
+ SetFontProperty(dc, SYSTEM_FONT, TEXT("win.system.font"), 1.0f);
+ SetFontProperty(dc, SYSTEM_FIXED_FONT, TEXT("win.systemFixed.font"), 1.0f);
}
catch (std::bad_alloc&) {
DeleteDC(dc);
@@ -266,31 +285,35 @@
}
VERIFY( SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncmetrics.cbSize, &ncmetrics, FALSE) );
- SetFontProperty( TEXT("win.frame.captionFont"), ncmetrics.lfCaptionFont );
- SetIntegerProperty( TEXT("win.frame.captionHeight"), ncmetrics.iCaptionHeight );
- SetIntegerProperty( TEXT("win.frame.captionButtonWidth"), ncmetrics.iCaptionWidth );
- SetIntegerProperty( TEXT("win.frame.captionButtonHeight"), ncmetrics.iCaptionHeight );
- SetFontProperty( TEXT("win.frame.smallCaptionFont"), ncmetrics.lfSmCaptionFont );
- SetIntegerProperty( TEXT("win.frame.smallCaptionHeight"), ncmetrics.iSmCaptionHeight );
- SetIntegerProperty( TEXT("win.frame.smallCaptionButtonWidth"), ncmetrics.iSmCaptionWidth );
- SetIntegerProperty( TEXT("win.frame.smallCaptionButtonHeight"), ncmetrics.iSmCaptionHeight );
- SetIntegerProperty( TEXT("win.frame.sizingBorderWidth"), ncmetrics.iBorderWidth );
+ float invScaleX;
+ float invScaleY;
+ getInvScale(invScaleX, invScaleY);
+
+ SetFontProperty(TEXT("win.frame.captionFont"), ncmetrics.lfCaptionFont, invScaleY);
+ SetIntegerProperty(TEXT("win.frame.captionHeight"), rescale(ncmetrics.iCaptionHeight, invScaleY));
+ SetIntegerProperty(TEXT("win.frame.captionButtonWidth"), rescale(ncmetrics.iCaptionWidth, invScaleX));
+ SetIntegerProperty(TEXT("win.frame.captionButtonHeight"), rescale(ncmetrics.iCaptionHeight, invScaleY));
+ SetFontProperty(TEXT("win.frame.smallCaptionFont"), ncmetrics.lfSmCaptionFont, invScaleY);
+ SetIntegerProperty(TEXT("win.frame.smallCaptionHeight"), rescale(ncmetrics.iSmCaptionHeight, invScaleY));
+ SetIntegerProperty(TEXT("win.frame.smallCaptionButtonWidth"), rescale(ncmetrics.iSmCaptionWidth, invScaleX));
+ SetIntegerProperty(TEXT("win.frame.smallCaptionButtonHeight"), rescale(ncmetrics.iSmCaptionHeight, invScaleY));
+ SetIntegerProperty(TEXT("win.frame.sizingBorderWidth"), rescale(ncmetrics.iBorderWidth, invScaleX));
// menu properties
- SetFontProperty( TEXT("win.menu.font"), ncmetrics.lfMenuFont );
- SetIntegerProperty( TEXT("win.menu.height"), ncmetrics.iMenuHeight );
- SetIntegerProperty( TEXT("win.menu.buttonWidth"), ncmetrics.iMenuWidth );
+ SetFontProperty(TEXT("win.menu.font"), ncmetrics.lfMenuFont, invScaleY);
+ SetIntegerProperty(TEXT("win.menu.height"), rescale(ncmetrics.iMenuHeight, invScaleY));
+ SetIntegerProperty(TEXT("win.menu.buttonWidth"), rescale(ncmetrics.iMenuWidth, invScaleX));
// scrollbar properties
- SetIntegerProperty( TEXT("win.scrollbar.width"), ncmetrics.iScrollWidth );
- SetIntegerProperty( TEXT("win.scrollbar.height"), ncmetrics.iScrollHeight );
+ SetIntegerProperty(TEXT("win.scrollbar.width"), rescale(ncmetrics.iScrollWidth, invScaleX));
+ SetIntegerProperty(TEXT("win.scrollbar.height"), rescale(ncmetrics.iScrollHeight, invScaleY));
// status bar and tooltip properties
- SetFontProperty( TEXT("win.status.font"), ncmetrics.lfStatusFont );
- SetFontProperty( TEXT("win.tooltip.font"), ncmetrics.lfStatusFont );
+ SetFontProperty(TEXT("win.status.font"), ncmetrics.lfStatusFont, invScaleY);
+ SetFontProperty(TEXT("win.tooltip.font"), ncmetrics.lfStatusFont, invScaleY);
// message box properties
- SetFontProperty( TEXT("win.messagebox.font"), ncmetrics.lfMessageFont );
+ SetFontProperty(TEXT("win.messagebox.font"), ncmetrics.lfMessageFont, invScaleY);
}
void AwtDesktopProperties::GetIconParameters() {
@@ -302,10 +325,13 @@
iconmetrics.cbSize = sizeof(iconmetrics);
VERIFY( SystemParametersInfo(SPI_GETICONMETRICS, iconmetrics.cbSize, &iconmetrics, FALSE) );
- SetIntegerProperty(TEXT("win.icon.hspacing"), iconmetrics.iHorzSpacing);
- SetIntegerProperty(TEXT("win.icon.vspacing"), iconmetrics.iVertSpacing);
+ float invScaleX;
+ float invScaleY;
+ getInvScale(invScaleX, invScaleY);
+ SetIntegerProperty(TEXT("win.icon.hspacing"), rescale(iconmetrics.iHorzSpacing, invScaleX));
+ SetIntegerProperty(TEXT("win.icon.vspacing"), rescale(iconmetrics.iVertSpacing, invScaleY));
SetBooleanProperty(TEXT("win.icon.titleWrappingOn"), iconmetrics.iTitleWrap != 0);
- SetFontProperty(TEXT("win.icon.font"), iconmetrics.lfFont);
+ SetFontProperty(TEXT("win.icon.font"), iconmetrics.lfFont, invScaleY);
}
/*
Windows settings for these are also in the registry
@@ -718,6 +744,7 @@
}
void AwtDesktopProperties::SetIntegerProperty(LPCTSTR propName, int value) {
+
jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
throw std::bad_alloc();
@@ -752,8 +779,8 @@
}
void AwtDesktopProperties::SetFontProperty(HDC dc, int fontID,
- LPCTSTR propName) {
- HGDIOBJ font = GetStockObject(fontID);
+ LPCTSTR propName, float invScale) {
+ HGDIOBJ font = GetStockObject(fontID);
if (font != NULL && SelectObject(dc, font) != NULL) {
int length = GetTextFace(dc, 0, NULL);
@@ -789,8 +816,8 @@
throw std::bad_alloc();
}
- jint pointSize = metrics.tmHeight -
- metrics.tmInternalLeading;
+ jint pointSize = rescale(metrics.tmHeight -
+ metrics.tmInternalLeading, invScale);
jint style = java_awt_Font_PLAIN;
if (metrics.tmWeight >= FW_BOLD) {
@@ -818,7 +845,8 @@
}
}
-void AwtDesktopProperties::SetFontProperty(LPCTSTR propName, const LOGFONT & font) {
+void AwtDesktopProperties::SetFontProperty(LPCTSTR propName, const LOGFONT & font,
+ float invScale) {
jstring fontName;
jint pointSize;
jint style;
@@ -836,7 +864,7 @@
ReleaseDC(NULL, hdc);
#endif
// Java uses point sizes, but assumes 1 pixel = 1 point
- pointSize = -font.lfHeight;
+ pointSize = rescale(-font.lfHeight, invScale);
// convert Windows font style to Java style
style = java_awt_Font_PLAIN;
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.h Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.h Mon Mar 21 09:36:54 2016 -0700
@@ -73,8 +73,8 @@
void SetIntegerProperty(LPCTSTR, int);
void SetStringProperty(LPCTSTR, LPTSTR);
void SetColorProperty(LPCTSTR, DWORD);
- void SetFontProperty(HDC, int, LPCTSTR);
- void SetFontProperty(LPCTSTR, const LOGFONT &);
+ void SetFontProperty(HDC, int, LPCTSTR, float invScale);
+ void SetFontProperty(LPCTSTR, const LOGFONT &, float invScale);
void SetSoundProperty(LPCTSTR, LPCTSTR);
JNIEnv * GetEnv() {
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DnDDT.cpp Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DnDDT.cpp Mon Mar 21 09:36:54 2016 -0700
@@ -127,6 +127,16 @@
return (ULONG)refs;
}
+void ScaleDown(POINT &cp, HWND m_window) {
+ int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(m_window);
+ Devices::InstanceAccess devices;
+ AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
+ if (device) {
+ cp.x = device->ScaleDownX(cp.x);
+ cp.y = device->ScaleDownY(cp.y);
+ }
+}
+
/**
* DragEnter
*/
@@ -176,6 +186,7 @@
cp.x = pt.x - wr.left;
cp.y = pt.y - wr.top;
+ ScaleDown(cp, m_window);
jint actions = call_dTCenter(env, m_dtcp, m_target,
(jint)cp.x, (jint)cp.y,
@@ -237,6 +248,7 @@
cp.x = pt.x - wr.left;
cp.y = pt.y - wr.top;
+ ScaleDown(cp, m_window);
actions = call_dTCmotion(env, m_dtcp, m_target,(jint)cp.x, (jint)cp.y,
::convertDROPEFFECTToActions(mapModsToDROPEFFECT(*pdwEffect, grfKeyState)),
@@ -336,6 +348,7 @@
cp.x = pt.x - wr.left;
cp.y = pt.y - wr.top;
+ ScaleDown(cp, m_window);
m_dropActions = java_awt_dnd_DnDConstants_ACTION_NONE;
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_TextArea.cpp Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_TextArea.cpp Mon Mar 21 09:36:54 2016 -0700
@@ -225,31 +225,18 @@
/*
* We consume WM_MOUSEMOVE while the left mouse button is pressed,
- * so we have to simulate autoscrolling when mouse is moved outside
- * of the client area.
+ * so we have to simulate selection autoscrolling when mouse is moved
+ * outside of the client area.
*/
POINT p;
RECT r;
- BOOL bScrollLeft = FALSE;
- BOOL bScrollRight = FALSE;
- BOOL bScrollUp = FALSE;
BOOL bScrollDown = FALSE;
p.x = msg->pt.x;
p.y = msg->pt.y;
VERIFY(::GetClientRect(GetHWnd(), &r));
- if (p.x < 0) {
- bScrollLeft = TRUE;
- p.x = 0;
- } else if (p.x > r.right) {
- bScrollRight = TRUE;
- p.x = r.right - 1;
- }
- if (p.y < 0) {
- bScrollUp = TRUE;
- p.y = 0;
- } else if (p.y > r.bottom) {
+ if (p.y > r.bottom) {
bScrollDown = TRUE;
p.y = r.bottom - 1;
}
@@ -269,32 +256,7 @@
EditSetSel(cr);
}
-
- if (bScrollLeft == TRUE || bScrollRight == TRUE) {
- SCROLLINFO si;
- memset(&si, 0, sizeof(si));
- si.cbSize = sizeof(si);
- si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
-
- VERIFY(::GetScrollInfo(GetHWnd(), SB_HORZ, &si));
- if (bScrollLeft == TRUE) {
- si.nPos = si.nPos - si.nPage / 2;
- si.nPos = max(si.nMin, si.nPos);
- } else if (bScrollRight == TRUE) {
- si.nPos = si.nPos + si.nPage / 2;
- si.nPos = min(si.nPos, si.nMax);
- }
- /*
- * Okay to use 16-bit position since RichEdit control adjusts
- * its scrollbars so that their range is always 16-bit.
- */
- DASSERT(abs(si.nPos) < 0x8000);
- SendMessage(WM_HSCROLL,
- MAKEWPARAM(SB_THUMBPOSITION, LOWORD(si.nPos)));
- }
- if (bScrollUp == TRUE) {
- SendMessage(EM_LINESCROLL, 0, -1);
- } else if (bScrollDown == TRUE) {
+ if (bScrollDown == TRUE) {
SendMessage(EM_LINESCROLL, 0, 1);
}
delete msg;
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_TextField.cpp Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_TextField.cpp Mon Mar 21 09:36:54 2016 -0700
@@ -157,27 +157,12 @@
/*
* We consume WM_MOUSEMOVE while the left mouse button is pressed,
- * so we have to simulate autoscrolling when mouse is moved outside
- * of the client area.
+ * so we have to simulate selection autoscrolling when mouse is moved
+ * outside of the client area.
*/
POINT p;
- RECT r;
- BOOL bScrollLeft = FALSE;
- BOOL bScrollRight = FALSE;
- BOOL bScrollUp = FALSE;
- BOOL bScrollDown = FALSE;
-
p.x = msg->pt.x;
p.y = msg->pt.y;
- VERIFY(::GetClientRect(GetHWnd(), &r));
-
- if (p.x < 0) {
- bScrollLeft = TRUE;
- p.x = 0;
- } else if (p.x > r.right) {
- bScrollRight = TRUE;
- p.x = r.right - 1;
- }
LONG lCurPos = EditGetCharFromPos(p);
if (GetStartSelectionPos() != -1 &&
@@ -193,32 +178,6 @@
EditSetSel(cr);
}
-
- if (bScrollLeft == TRUE || bScrollRight == TRUE) {
- SCROLLINFO si;
- memset(&si, 0, sizeof(si));
- si.cbSize = sizeof(si);
- si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
-
- SendMessage(EM_SHOWSCROLLBAR, SB_HORZ, TRUE);
- VERIFY(::GetScrollInfo(GetHWnd(), SB_HORZ, &si));
- SendMessage(EM_SHOWSCROLLBAR, SB_HORZ, FALSE);
-
- if (bScrollLeft == TRUE) {
- si.nPos = si.nPos - si.nPage / 2;
- si.nPos = max(si.nMin, si.nPos);
- } else if (bScrollRight == TRUE) {
- si.nPos = si.nPos + si.nPage / 2;
- si.nPos = min(si.nPos, si.nMax);
- }
- /*
- * Okay to use 16-bit position since RichEdit control adjusts
- * its scrollbars so that their range is always 16-bit.
- */
- DASSERT(abs(si.nPos) < 0x8000);
- SendMessage(WM_HSCROLL,
- MAKEWPARAM(SB_THUMBPOSITION, LOWORD(si.nPos)));
- }
delete msg;
return mrConsume;
} else if (msg->message == WM_KEYDOWN) {
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Window.cpp Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Window.cpp Mon Mar 21 09:36:54 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, 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
@@ -1154,6 +1154,7 @@
void AwtWindow::InitOwner(AwtWindow *owner)
{
DASSERT(owner != NULL);
+ AwtWindow *initialOwner = owner;
while (owner != NULL && owner->IsSimpleWindow()) {
HWND ownerOwnerHWND = ::GetWindow(owner->GetHWnd(), GW_OWNER);
@@ -1163,6 +1164,9 @@
}
owner = (AwtWindow *)AwtComponent::GetComponent(ownerOwnerHWND);
}
+ if (!owner) {
+ owner = initialOwner->GetOwningFrameOrDialog();
+ }
m_owningFrameDialog = (AwtFrame *)owner;
}
--- a/jdk/src/jdk.accessibility/windows/classes/com/sun/java/accessibility/internal/AccessBridge.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/src/jdk.accessibility/windows/classes/com/sun/java/accessibility/internal/AccessBridge.java Mon Mar 21 09:36:54 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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
@@ -1408,7 +1408,9 @@
s.indexOf(AccessibleState.MANAGES_DESCENDANTS.toDisplayString(Locale.US)) == -1) {
// Indicate whether this component manages its own
// children
- AccessibleRole role = ac.getAccessibleRole();
+ AccessibleRole role = InvocationUtils.invokeAndWait(() -> {
+ return ac.getAccessibleRole();
+ }, ac);
if (role == AccessibleRole.LIST ||
role == AccessibleRole.TABLE ||
role == AccessibleRole.TREE) {
@@ -1666,7 +1668,9 @@
*/
private AccessibleComponent getAccessibleComponentFromContext(AccessibleContext ac) {
if (ac != null) {
- AccessibleComponent acmp = ac.getAccessibleComponent();
+ AccessibleComponent acmp = InvocationUtils.invokeAndWait(() -> {
+ return ac.getAccessibleComponent();
+ }, ac);
if (acmp != null) {
debugString("Returning AccessibleComponent Context");
return acmp;
--- a/jdk/test/java/awt/Focus/MouseClickRequestFocusRaceTest/MouseClickRequestFocusRaceTest.html Mon Mar 21 08:48:34 2016 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-<!--
- Copyright (c) 2006, 2014, 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.
--->
-
-<html>
-<!--
- @test
- @bug 5028014
- @summary Focus request & mouse click being performed nearly synchronously shouldn't break the focus subsystem
- @author anton.tarasov@sun.com: area=awt-focus
- @run applet MouseClickRequestFocusRaceTest.html
- -->
-<head>
-<title>MouseClickRequestFocusRaceTest</title>
-</head>
-<body>
-
-<h1>MouseClickRequestFocusRaceTest<br>Bug ID: 5028014</h1>
-
-<p>See the dialog box (usually in upper left corner) for instructions</p>
-
-<APPLET CODE=MouseClickRequestFocusRaceTest.class WIDTH=200 HEIGHT=200></APPLET>
-</body>
-</html>
--- a/jdk/test/java/awt/Focus/MouseClickRequestFocusRaceTest/MouseClickRequestFocusRaceTest.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/test/java/awt/Focus/MouseClickRequestFocusRaceTest/MouseClickRequestFocusRaceTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, 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
@@ -21,57 +21,59 @@
* questions.
*/
-/*
- test
- @bug 5028014
- @summary Focus request & mouse click performed nearly synchronously shouldn't lead to a focus race.
- @author anton.tarasov@sun.com: area=awt-focus
- @run applet MouseClickRequestFocusRaceTest.html
-*/
+import java.awt.AWTException;
+import java.awt.FlowLayout;
+import java.awt.KeyboardFocusManager;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
-import java.awt.*;
-import javax.swing.*;
-import java.awt.event.*;
-import java.applet.Applet;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import javax.swing.WindowConstants;
+
+import jdk.testlibrary.OSInfo;
-public class MouseClickRequestFocusRaceTest extends Applet {
- Robot robot;
- JFrame frame1 = new JFrame("Frame-1") {
+/**
+ * @test
+ * @bug 5028014
+ * @summary Focus request & mouse click being performed nearly synchronously
+ * shouldn't break the focus subsystem
+ * @author anton.tarasov@sun.com: area=awt-focus
+ * @library ../../../../lib/testlibrary
+ * @build jdk.testlibrary.OSInfo
+ * @run main MouseClickRequestFocusRaceTest
+ */
+public class MouseClickRequestFocusRaceTest {
+ static Robot robot;
+ static JFrame frame1 = new JFrame("Frame-1") {
public String toString() { return "Frame-1";}
};
- JFrame frame2 = new JFrame("Frame-2") {
+ static JFrame frame2 = new JFrame("Frame-2") {
public String toString() { return "Frame-2";}
};
- JButton button1 = new JButton("button-1") {
+ static JButton button1 = new JButton("button-1") {
public String toString() { return "button-1";}
};
- JButton button2 = new JButton("button-2") {
+ static JButton button2 = new JButton("button-2") {
public String toString() { return "button-2";}
};
- JPopupMenu popup = new JPopupMenu();
+ static JPopupMenu popup = new JPopupMenu();
public static void main(String[] args) {
- MouseClickRequestFocusRaceTest app = new MouseClickRequestFocusRaceTest();
- app.init();
- app.start();
- }
-
- public void init() {
try {
robot = new Robot();
+ robot.setAutoWaitForIdle(true);
+ robot.setAutoDelay(100);
} catch (AWTException e) {
throw new RuntimeException("Error: unable to create robot", e);
}
- // Create instructions for the user here, as well as set up
- // the environment -- set the layout manager, add buttons,
- // etc.
- this.setLayout (new BorderLayout ());
- Sysout.createDialogWithInstructions(new String[]
- {"Automatic test. Simply wait until it is done."
- });
- }
-
- public void start() {
frame1.add(button1);
frame2.add(button2);
frame1.setBounds(0, 0, 200, 300);
@@ -110,198 +112,64 @@
frame1.setVisible(true);
frame2.setVisible(true);
-// ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+
robot.delay(1000);
-
- test();
+ try {
+ test();
+ } finally {
+ frame1.dispose();
+ frame2.dispose();
+ }
}
- public void test() {
+ public static void test() {
// Right click Frame-1
robot.mouseMove(frame1.getLocation().x + 100, frame1.getLocation().y + 200);
robot.mousePress(InputEvent.BUTTON3_MASK);
- robot.delay(100);
robot.mouseRelease(InputEvent.BUTTON3_MASK);
-// ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
robot.delay(1000);
// Left click Frame-2
robot.mouseMove(frame2.getLocation().x + 100, frame1.getLocation().y + 200);
robot.mousePress(InputEvent.BUTTON1_MASK);
- robot.delay(100);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
-// ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
robot.delay(1000);
JComponent focusOwner = (JComponent)KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
JFrame focusedWindow = (JFrame)KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
- Sysout.println("focus owner: " + focusOwner);
- Sysout.println("focused window: " + focusedWindow);
+ System.out.println("focus owner: " + focusOwner);
+ System.out.println("focused window: " + focusedWindow);
// Verify that the focused window is the ancestor of the focus owner
if (!focusedWindow.isAncestorOf(focusOwner)) {
- throw new TestFailedException("The focus owner is not in the focused window!");
+ throw new RuntimeException("The focus owner is not in the focused window!");
}
- // Try to close native focused window
- robot.keyPress(KeyEvent.VK_ALT);
- robot.keyPress(KeyEvent.VK_F4);
- robot.keyRelease(KeyEvent.VK_F4);
- robot.keyRelease(KeyEvent.VK_ALT);
-
-// ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
- robot.delay(1000);
-
- // Verify that the Java focused window really mapped the native focused window.
- if (focusedWindow.isVisible()) {
- throw new TestFailedException("The focused window is different on Java and on the native level.");
- }
- }
-
- class TestFailedException extends RuntimeException {
- public TestFailedException(String cause) {
- super("Test failed.");
- Sysout.println(cause);
+ if (!OSInfo.getOSType().equals(OSInfo.OSType.MACOSX)) {
+ // Try to close native focused window
+ robot.keyPress(KeyEvent.VK_ALT);
+ robot.keyPress(KeyEvent.VK_F4);
+ robot.keyRelease(KeyEvent.VK_F4);
+ robot.keyRelease(KeyEvent.VK_ALT);
+ robot.delay(1000);
+ // Verify that the Java focused window really mapped the native focused window.
+ if (focusedWindow.isVisible()) {
+ throw new RuntimeException("The focused window is different on Java and on the native level.");
+ }
+ } else {
+ // Try to move native focus to previous window
+ robot.keyPress(KeyEvent.VK_CONTROL);
+ robot.keyPress(KeyEvent.VK_F4);
+ robot.keyRelease(KeyEvent.VK_F4);
+ robot.keyRelease(KeyEvent.VK_CONTROL);
+ robot.delay(1000);
+ // Verify that the Java focused window really mapped the native focused window.
+ if (focusedWindow.isFocused()) {
+ throw new RuntimeException("The focused window is different on Java and on the native level.");
+ }
}
}
}
-
-/****************************************************
- Standard Test Machinery
- DO NOT modify anything below -- it's a standard
- chunk of code whose purpose is to make user
- interaction uniform, and thereby make it simpler
- to read and understand someone else's test.
- ****************************************************/
-
-/**
- This is part of the standard test machinery.
- It creates a dialog (with the instructions), and is the interface
- for sending text messages to the user.
- To print the instructions, send an array of strings to Sysout.createDialog
- WithInstructions method. Put one line of instructions per array entry.
- To display a message for the tester to see, simply call Sysout.println
- with the string to be displayed.
- This mimics System.out.println but works within the test harness as well
- as standalone.
- */
-
-class Sysout
-{
- static TestDialog dialog;
-
- public static void createDialogWithInstructions( String[] instructions )
- {
- dialog = new TestDialog( new Frame(), "Instructions" );
- dialog.printInstructions( instructions );
-// dialog.setVisible(true);
- println( "Any messages for the tester will display here." );
- }
-
- public static void createDialog( )
- {
- dialog = new TestDialog( new Frame(), "Instructions" );
- String[] defInstr = { "Instructions will appear here. ", "" } ;
- dialog.printInstructions( defInstr );
-// dialog.setVisible(true);
- println( "Any messages for the tester will display here." );
- }
-
-
- public static void printInstructions( String[] instructions )
- {
- dialog.printInstructions( instructions );
- }
-
-
- public static void println( String messageIn )
- {
- dialog.displayMessage( messageIn );
- }
-
-}// Sysout class
-
-/**
- This is part of the standard test machinery. It provides a place for the
- test instructions to be displayed, and a place for interactive messages
- to the user to be displayed.
- To have the test instructions displayed, see Sysout.
- To have a message to the user be displayed, see Sysout.
- Do not call anything in this dialog directly.
- */
-class TestDialog extends Dialog
-{
-
- TextArea instructionsText;
- TextArea messageText;
- int maxStringLength = 80;
-
- //DO NOT call this directly, go through Sysout
- public TestDialog( Frame frame, String name )
- {
- super( frame, name );
- int scrollBoth = TextArea.SCROLLBARS_BOTH;
- instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
- add( "North", instructionsText );
-
- messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
- add("Center", messageText);
-
- pack();
-
-// setVisible(true);
- }// TestDialog()
-
- //DO NOT call this directly, go through Sysout
- public void printInstructions( String[] instructions )
- {
- //Clear out any current instructions
- instructionsText.setText( "" );
-
- //Go down array of instruction strings
-
- String printStr, remainingStr;
- for( int i=0; i < instructions.length; i++ )
- {
- //chop up each into pieces maxSringLength long
- remainingStr = instructions[ i ];
- while( remainingStr.length() > 0 )
- {
- //if longer than max then chop off first max chars to print
- if( remainingStr.length() >= maxStringLength )
- {
- //Try to chop on a word boundary
- int posOfSpace = remainingStr.
- lastIndexOf( ' ', maxStringLength - 1 );
-
- if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
-
- printStr = remainingStr.substring( 0, posOfSpace + 1 );
- remainingStr = remainingStr.substring( posOfSpace + 1 );
- }
- //else just print
- else
- {
- printStr = remainingStr;
- remainingStr = "";
- }
-
- instructionsText.append( printStr + "\n" );
-
- }// while
-
- }// for
-
- }//printInstructions()
-
- //DO NOT call this directly, go through Sysout
- public void displayMessage( String messageIn )
- {
- messageText.append( messageIn + "\n" );
- System.out.println(messageIn);
- }
-
-}// TestDialog class
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Graphics/CopyScaledArea/CopyScaledAreaTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2015, 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.*;
+import java.awt.image.BufferedImage;
+import java.awt.image.VolatileImage;
+import static sun.awt.OSInfo.*;
+
+/**
+ * @test
+ * @bug 8069348
+ * @summary SunGraphics2D.copyArea() does not properly work for scaled graphics
+ * @modules java.desktop/sun.awt
+ * @run main/othervm -Dsun.java2d.uiScale=2 CopyScaledAreaTest
+ * @run main/othervm -Dsun.java2d.opengl=true -Dsun.java2d.uiScale=2 CopyScaledAreaTest
+ * @run main/othervm -Dsun.java2d.d3d=true -Dsun.java2d.uiScale=2 CopyScaledAreaTest
+ * @run main/othervm -Dsun.java2d.d3d=false -Dsun.java2d.opengl=false
+ * -Dsun.java2d.uiScale=2 CopyScaledAreaTest
+ */
+public class CopyScaledAreaTest {
+
+ private static final int IMAGE_WIDTH = 800;
+ private static final int IMAGE_HEIGHT = 800;
+ private static final int X = 50;
+ private static final int Y = 50;
+ private static final int W = 100;
+ private static final int H = 75;
+ private static final int DX = 15;
+ private static final int DY = 10;
+ private static final int N = 3;
+ private static final Color BACKGROUND_COLOR = Color.YELLOW;
+ private static final Color FILL_COLOR = Color.ORANGE;
+ private static final double[][] SCALES = {{1.3, 1.4}, {0.3, 2.3}, {2.7, 0.1}};
+
+ private static boolean isSupported() {
+ String d3d = System.getProperty("sun.java2d.d3d");
+ return !Boolean.getBoolean(d3d) || getOSType() == OSType.WINDOWS;
+ }
+
+ private static int scale(int x, double scale) {
+ return (int) Math.floor(x * scale);
+ }
+
+ private static VolatileImage createVolatileImage(GraphicsConfiguration conf) {
+ return conf.createCompatibleVolatileImage(IMAGE_WIDTH, IMAGE_HEIGHT);
+ }
+
+ // rendering to the image
+ private static void renderOffscreen(VolatileImage vImg,
+ GraphicsConfiguration conf,
+ double scaleX,
+ double scaleY)
+ {
+ int attempts = 0;
+ do {
+
+ if (attempts > 10) {
+ throw new RuntimeException("Too many attempts!");
+ }
+
+ if (vImg.validate(conf) == VolatileImage.IMAGE_INCOMPATIBLE) {
+ // old vImg doesn't work with new GraphicsConfig; re-create it
+ vImg = createVolatileImage(conf);
+ }
+ Graphics2D g = vImg.createGraphics();
+ //
+ // miscellaneous rendering commands...
+ //
+ g.setColor(BACKGROUND_COLOR);
+ g.fillRect(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);
+ g.scale(scaleX, scaleY);
+
+ g.setColor(FILL_COLOR);
+ g.fillRect(X, Y, W, H);
+
+ for (int i = 0; i < N; i++) {
+ g.copyArea(X + i * DX, Y + i * DY, W, H, DX, DY);
+ }
+ g.dispose();
+ attempts++;
+ } while (vImg.contentsLost());
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ if (!isSupported()) {
+ return;
+ }
+
+ GraphicsConfiguration graphicsConfiguration =
+ GraphicsEnvironment.getLocalGraphicsEnvironment()
+ .getDefaultScreenDevice().getDefaultConfiguration();
+
+ for(double[] scales: SCALES){
+ testScale(scales[0], scales[1], graphicsConfiguration);
+ }
+ }
+
+ private static void testScale(double scaleX, double scaleY,
+ GraphicsConfiguration gc) throws Exception
+ {
+
+ BufferedImage buffImage = new BufferedImage(IMAGE_WIDTH, IMAGE_HEIGHT,
+ BufferedImage.TYPE_INT_RGB);
+ Graphics g = buffImage.createGraphics();
+
+ VolatileImage vImg = createVolatileImage(gc);
+
+ int attempts = 0;
+ do {
+
+ if (attempts > 10) {
+ throw new RuntimeException("Too many attempts!");
+ }
+
+ int returnCode = vImg.validate(gc);
+ if (returnCode == VolatileImage.IMAGE_RESTORED) {
+ // Contents need to be restored
+ renderOffscreen(vImg, gc, scaleX, scaleY); // restore contents
+ } else if (returnCode == VolatileImage.IMAGE_INCOMPATIBLE) {
+ // old vImg doesn't work with new GraphicsConfig; re-create it
+ vImg = createVolatileImage(gc);
+ renderOffscreen(vImg, gc, scaleX, scaleY);
+ }
+ g.drawImage(vImg, 0, 0, null);
+ attempts++;
+ } while (vImg.contentsLost());
+
+ g.dispose();
+
+ int x = scale(X + N * DX, scaleX) + 1;
+ int y = scale(Y + N * DY, scaleY) + 1;
+ int w = scale(W, scaleX) - 2;
+ int h = scale(H, scaleY) - 2;
+
+ for (int i = x; i < x + w; i++) {
+ for (int j = y; j < y + h; j++) {
+ if (buffImage.getRGB(i, j) != FILL_COLOR.getRGB()) {
+ throw new RuntimeException("Wrong rectangle color!");
+ }
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/PrintJob/HighResTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,412 @@
+/*
+ * Copyright (c) 2016, 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 4227128 8066139
+ @summary Test printing at resolutions > 72dpi
+ @author dpm: area=awt.print
+ @run main/manual HighResTest
+ */
+import java.awt.Button;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.JobAttributes;
+import java.awt.PageAttributes;
+import java.awt.PrintJob;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.JobAttributes.DialogType;
+import java.awt.JobAttributes.SidesType;
+import java.awt.PageAttributes.OrientationRequestedType;
+import java.awt.PageAttributes.OriginType;
+import java.awt.Dialog;
+import java.awt.Panel;
+import java.awt.TextArea;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+public class HighResTest {
+ static Frame f = new Frame();
+
+ private static void init() {
+ String[] instructions = {
+ "To be able to run this test it is required to have a default",
+ "printer configured in your user environment.",
+ "If no default printer exists, then test passes.",
+ " ",
+ "There will be 2 print dialogs. The first dialog should show",
+ "portrait as the selected orientation. The 2nd dialog should show",
+ "landscape as the selected orientation.",
+ " ",
+ "Visual inspection of the printed pages is needed. A passing",
+ "test will print 2 pages in portrait and 2 pages in landscape.",
+ "The pages have on the center of the page the text \"Center\"",
+ "2 rectangles will appear above and below it, the one below is",
+ "filled."
+ };
+ Sysout.createDialog();
+ Sysout.printInstructions(instructions);
+
+ PrintJob job = null;
+ Dimension dim = null;
+ JobAttributes jobAttributes = new JobAttributes();
+ PageAttributes pageAttributes = new PageAttributes();
+ String center = "Center";
+ Font font = new Font("SansSerif", Font.PLAIN, 200);
+ FontMetrics metrics = null;
+ int width = 0;
+ Graphics g = null;
+
+ jobAttributes.setDialog(DialogType.NATIVE);
+ pageAttributes.setOrigin(OriginType.PRINTABLE);
+ pageAttributes.setPrinterResolution(new int[]{1200, 1200, 3});
+ pageAttributes.setOrientationRequested(
+ OrientationRequestedType.PORTRAIT);
+ jobAttributes.setSides(SidesType.TWO_SIDED_LONG_EDGE);
+
+ job = f.getToolkit().getPrintJob(f, "Portrait Test", jobAttributes,
+ pageAttributes);
+ if (job != null) {
+ dim = job.getPageDimension();
+ for (int i = 0; i < 2; i++) {
+ g = job.getGraphics();
+
+ g.drawLine(0, 0, dim.width, 0);
+ g.drawLine(dim.width, 0, dim.width, dim.height);
+ g.drawLine(dim.width, dim.height, 0, dim.height);
+ g.drawLine(0, dim.height, 0, 0);
+
+ g.drawRect(dim.width / 2 - 200, dim.height / 3 - 300, 400, 600);
+ g.fillRect(dim.width / 2 - 200, 2 * dim.height / 3 - 300, 400, 600);
+
+ g.setFont(font);
+ metrics = g.getFontMetrics();
+ width = metrics.stringWidth(center);
+ g.setColor(Color.black);
+ g.drawString(center, (dim.width / 2) - (width / 2), dim.height / 2);
+
+ g.dispose();
+ }
+ job.end();
+ job = null;
+ }
+
+ pageAttributes.setOrientationRequested(
+ OrientationRequestedType.LANDSCAPE);
+
+ job = f.getToolkit().getPrintJob(f, "Landscape Test", jobAttributes,
+ pageAttributes);
+ if (job != null) {
+ dim = job.getPageDimension();
+ for (int i = 0; i < 2; i++) {
+ g = job.getGraphics();
+ g.drawLine(0, 0, dim.width, 0);
+ g.drawLine(dim.width, 0, dim.width, dim.height);
+ g.drawLine(dim.width, dim.height, 0, dim.height);
+ g.drawLine(0, dim.height, 0, 0);
+
+ g.drawRect(dim.width / 2 - 200, dim.height / 3 - 300, 400, 600);
+ g.fillRect(dim.width / 2 - 200, 2 * dim.height / 3 - 300, 400, 600);
+
+ g.setFont(font);
+ metrics = g.getFontMetrics();
+ width = metrics.stringWidth(center);
+ g.setColor(Color.black);
+ g.drawString(center, (dim.width / 2) - (width / 2), dim.height / 2);
+
+ g.dispose();
+ }
+ job.end();
+ job = null;
+ }
+ System.out.println("done");
+ }
+
+
+
+ /**
+ * ***************************************************
+ * Standard Test Machinery Section DO NOT modify anything in this section -- it's a
+ standard chunk of code which has all of the
+ synchronisation necessary for the test harness.
+ By keeping it the same in all tests, it is easier
+ to read and understand someone else's test, as
+ well as insuring that all tests behave correctly
+ with the test harness.
+ There is a section following this for test-defined
+ classes
+ *****************************************************
+ */
+ private static boolean theTestPassed = false;
+ private static boolean testGeneratedInterrupt = false;
+ private static String failureMessage = "";
+
+ private static Thread mainThread = null;
+
+ private static int sleepTime = 300000;
+
+ public static void main(String args[]) throws InterruptedException {
+ mainThread = Thread.currentThread();
+ try {
+ init();
+ } catch (TestPassedException e) {
+ //The test passed, so just return from main and harness will
+ // interepret this return as a pass
+ return;
+ }
+ //At this point, neither test passed nor test failed has been
+ // called -- either would have thrown an exception and ended the
+ // test, so we know we have multiple threads.
+
+ //Test involves other threads, so sleep and wait for them to
+ // called pass() or fail()
+ try {
+ Thread.sleep(sleepTime);
+ //Timed out, so fail the test
+ throw new RuntimeException("Timed out after " + sleepTime / 1000 + " seconds");
+ } catch (InterruptedException e) {
+ if (!testGeneratedInterrupt) {
+ throw e;
+ }
+
+ //reset flag in case hit this code more than once for some reason (just safety)
+ testGeneratedInterrupt = false;
+ if (theTestPassed == false) {
+ throw new RuntimeException(failureMessage);
+ }
+ }
+
+ }//main
+
+ public static synchronized void setTimeoutTo(int seconds) {
+ sleepTime = seconds * 1000;
+ }
+
+ public static synchronized void pass() {
+ Sysout.println("The test passed.");
+ //first check if this is executing in main thread
+ if (mainThread == Thread.currentThread()) {
+ //Still in the main thread, so set the flag just for kicks,
+ // and throw a test passed exception which will be caught
+ // and end the test.
+ theTestPassed = true;
+ throw new TestPassedException();
+ }
+ //pass was called from a different thread, so set the flag and interrupt
+ // the main thead.
+ theTestPassed = true;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ Sysout.dispose();
+ }//pass()
+
+ public static synchronized void fail() {
+ //test writer didn't specify why test failed, so give generic
+ fail("it just plain failed! :-)");
+ }
+
+ public static synchronized void fail(String whyFailed) {
+ Sysout.println("The test failed: " + whyFailed);
+ //check if this called from main thread
+ if (mainThread == Thread.currentThread()) {
+ //If main thread, fail now 'cause not sleeping
+ throw new RuntimeException(whyFailed);
+ }
+ theTestPassed = false;
+ testGeneratedInterrupt = true;
+ failureMessage = whyFailed;
+ mainThread.interrupt();
+ Sysout.dispose();
+ }//fail()
+
+ }// class HighResTest
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+ {
+ }
+
+//*********** End Standard Test Machinery Section **********
+
+//************** End classes defined for the test *******************
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout {
+ private static TestDialog dialog;
+
+ public static void createDialogWithInstructions(String[] instructions) {
+ dialog = new TestDialog(new Frame(), "Instructions");
+ dialog.printInstructions(instructions);
+ println("Any messages for the tester will display here.");
+ }
+
+ public static void createDialog() {
+ dialog = new TestDialog(new Frame(), "Instructions");
+ String[] defInstr = {"Instructions will appear here. ", ""};
+ dialog.printInstructions(defInstr);
+ println("Any messages for the tester will display here.");
+ }
+
+
+ public static void printInstructions(String[] instructions) {
+ dialog.printInstructions(instructions);
+ }
+
+
+ public static void println(String messageIn) {
+ dialog.displayMessage(messageIn);
+ }
+
+ public static void dispose() {
+ Sysout.println("Shutting down the Java process..");
+ HighResTest.f.dispose();
+ dialog.dispose();
+ }
+ }// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog implements ActionListener
+{
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+ Panel buttonP = new Panel();
+ Button passB = new Button("pass");
+ Button failB = new Button("fail");
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog(Frame frame, String name) {
+ super(frame, name);
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
+ add("North", instructionsText);
+
+ messageText = new TextArea("", 5, maxStringLength, scrollBoth);
+ add("Center", messageText);
+
+ passB = new Button("pass");
+ passB.setActionCommand("pass");
+ passB.addActionListener(this);
+ buttonP.add("East", passB);
+
+ failB = new Button("fail");
+ failB.setActionCommand("fail");
+ failB.addActionListener(this);
+ buttonP.add("West", failB);
+
+ add("South", buttonP);
+ pack();
+
+ show();
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions(String[] instructions) {
+ //Clear out any current instructions
+ instructionsText.setText("");
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for (int i = 0; i < instructions.length; i++) {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[i];
+ while (remainingStr.length() > 0) {
+ //if longer than max then chop off first max chars to print
+ if (remainingStr.length() >= maxStringLength) {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf(' ', maxStringLength - 1);
+
+ if (posOfSpace <= 0) {
+ posOfSpace = maxStringLength - 1;
+ }
+
+ printStr = remainingStr.substring(0, posOfSpace + 1);
+ remainingStr = remainingStr.substring(posOfSpace + 1);
+ } //else just print
+ else {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append(printStr + "\n");
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage(String messageIn) {
+ messageText.append(messageIn + "\n");
+ }
+
+ //catch presses of the passed and failed buttons.
+ //simply call the standard pass() or fail() static methods of
+ //HighResTest
+ public void actionPerformed(ActionEvent e) {
+ if (e.getActionCommand() == "pass") {
+ HighResTest.pass();
+ } else {
+ HighResTest.fail();
+ }
+ }
+}// TestDialog class
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/SplashScreen/MultiResolutionSplash/unix/UnixMultiResolutionSplashTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,241 @@
+/*
+ * Copyright (c) 2016, 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.Color;
+import java.awt.Dialog;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Panel;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.SplashScreen;
+import java.awt.TextField;
+import java.awt.Window;
+import java.awt.event.KeyEvent;
+import java.awt.image.BufferedImage;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.imageio.ImageIO;
+
+/**
+ * @test @bug 8145174
+ * @summary HiDPI splash screen support on Linux
+ * @modules java.desktop/sun.java2d
+ * @run main UnixMultiResolutionSplashTest
+ */
+public class UnixMultiResolutionSplashTest {
+
+ private static final int IMAGE_WIDTH = 300;
+ private static final int IMAGE_HEIGHT = 200;
+ private static int inx = 0;
+ private static final ImageInfo[] tests = {
+ new ImageInfo("splash1.png", "splash1.java-scale2x.png", Color.BLUE, Color.GREEN),
+ new ImageInfo("splash2", "splash2.java-scale2x", Color.WHITE, Color.BLACK),
+ new ImageInfo("splash3.", "splash3.java-scale2x.", Color.YELLOW, Color.RED)
+ };
+
+ public static void main(String[] args) throws Exception {
+
+ if (args.length == 0) {
+ generateImages();
+ for (ImageInfo test : tests) {
+ createChildProcess(test);
+ }
+ } else {
+ int index = Integer.parseInt(args[0]);
+ testSplash(tests[index]);
+ }
+ }
+
+ static void createChildProcess(ImageInfo test) {
+ String javaPath = System.getProperty("java.home");
+ File file = new File(test.name1x);
+ String classPathDir = System.getProperty("java.class.path");
+ Map<String, String> env = new HashMap<String, String>();
+ env.put("GDK_SCALE", "2");
+ int exitValue = doExec(env, javaPath + File.separator + "bin" + File.separator
+ + "java", "-splash:" + file.getAbsolutePath(), "-cp",
+ classPathDir, "UnixMultiResolutionSplashTest", String.valueOf(inx++));
+ if (exitValue != 0) {
+ throw new RuntimeException("Test Failed");
+ }
+ }
+
+ static void testSplash(ImageInfo test) throws Exception {
+ SplashScreen splashScreen = SplashScreen.getSplashScreen();
+ if (splashScreen == null) {
+ throw new RuntimeException("Splash screen is not shown!");
+ }
+ Graphics2D g = splashScreen.createGraphics();
+ Rectangle splashBounds = splashScreen.getBounds();
+ int screenX = (int) splashBounds.getCenterX();
+ int screenY = (int) splashBounds.getCenterY();
+ System.out.println(screenX);
+ System.out.println(screenY);
+ Robot robot = new Robot();
+ Color splashScreenColor = robot.getPixelColor(screenX, screenY);
+
+ float scaleFactor = getScaleFactor();
+ Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;
+ if (!compare(testColor, splashScreenColor)) {
+ throw new RuntimeException(
+ "Image with wrong resolution is used for splash screen!");
+ }
+ }
+
+ static int doExec(Map<String, String> envToSet, String... cmds) {
+ Process p = null;
+ ProcessBuilder pb = new ProcessBuilder(cmds);
+ Map<String, String> env = pb.environment();
+ for (String cmd : cmds) {
+ System.out.print(cmd + " ");
+ }
+ System.out.println();
+ if (envToSet != null) {
+ env.putAll(envToSet);
+ }
+ BufferedReader rdr = null;
+ try {
+ List<String> outputList = new ArrayList<>();
+ pb.redirectErrorStream(true);
+ p = pb.start();
+ rdr = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ String in = rdr.readLine();
+ while (in != null) {
+ outputList.add(in);
+ in = rdr.readLine();
+ System.out.println(in);
+ }
+ p.waitFor();
+ p.destroy();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ return p.exitValue();
+ }
+
+ static void testFocus() throws Exception {
+
+ System.out.println("Focus Test!");
+ Robot robot = new Robot();
+ robot.setAutoDelay(50);
+ Frame frame = new Frame();
+ frame.setSize(100, 100);
+ String test = "123";
+ TextField textField = new TextField(test);
+ textField.selectAll();
+ frame.add(textField);
+ frame.setVisible(true);
+ robot.waitForIdle();
+
+ robot.keyPress(KeyEvent.VK_A);
+ robot.keyRelease(KeyEvent.VK_A);
+ robot.keyPress(KeyEvent.VK_B);
+ robot.keyRelease(KeyEvent.VK_B);
+ robot.waitForIdle();
+
+ frame.dispose();
+ if (!textField.getText().equals("ab")) {
+ throw new RuntimeException("Focus is lost!");
+ }
+ }
+
+ static boolean compare(Color c1, Color c2) {
+ return compare(c1.getRed(), c2.getRed())
+ && compare(c1.getGreen(), c2.getGreen())
+ && compare(c1.getBlue(), c2.getBlue());
+ }
+
+ static boolean compare(int n, int m) {
+ return Math.abs(n - m) <= 50;
+ }
+
+ static float getScaleFactor() {
+
+ final Dialog dialog = new Dialog((Window) null);
+ dialog.setSize(100, 100);
+ dialog.setModal(true);
+ float[] scaleFactors = new float[1];
+ Panel panel = new Panel() {
+
+ @Override
+ public void paint(Graphics g) {
+ String scaleStr = System.getenv("GDK_SCALE");
+ if (scaleStr != null && !scaleStr.equals("")) {
+ try {
+ scaleFactors[0] = Float.valueOf(scaleStr);
+ } catch (NumberFormatException ex) {
+ scaleFactors[0] = 1.0f;
+ }
+ }
+ dialog.setVisible(false);
+ }
+ };
+ dialog.add(panel);
+ dialog.setVisible(true);
+ dialog.dispose();
+ return scaleFactors[0];
+ }
+
+ static void generateImages() throws Exception {
+ for (ImageInfo test : tests) {
+ generateImage(test.name1x, test.color1x, 1);
+ generateImage(test.name2x, test.color2x, 2);
+ }
+ }
+
+ static void generateImage(String name, Color color, int scale) throws Exception {
+ File file = new File(name);
+ if (file.exists()) {
+ return;
+ }
+ BufferedImage image = new BufferedImage(scale * IMAGE_WIDTH, scale * IMAGE_HEIGHT,
+ BufferedImage.TYPE_INT_RGB);
+ Graphics g = image.getGraphics();
+ g.setColor(color);
+ g.fillRect(0, 0, scale * IMAGE_WIDTH, scale * IMAGE_HEIGHT);
+ ImageIO.write(image, "png", file);
+ }
+
+ static class ImageInfo {
+
+ final String name1x;
+ final String name2x;
+ final Color color1x;
+ final Color color2x;
+
+ public ImageInfo(String name1x, String name2x, Color color1x, Color color2x) {
+ this.name1x = name1x;
+ this.name2x = name2x;
+ this.color1x = color1x;
+ this.color2x = color2x;
+ }
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/TextArea/OverScrollTest/OverScrollTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2016, 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 8149636
+ @summary TextArea over scrolls to right when selecting text towards right.
+ @requires os.family == "windows"
+ @run main OverScrollTest
+ */
+
+import java.awt.Frame;
+import java.awt.FlowLayout;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.TextArea;
+import java.awt.event.InputEvent;
+
+public class OverScrollTest {
+ Frame mainFrame;
+ TextArea textArea;
+ Robot robot;
+
+ OverScrollTest() {
+ try {
+ robot = new Robot();
+ } catch (Exception ex) {
+ throw new RuntimeException(ex.getMessage());
+ }
+
+ mainFrame = new Frame();
+ mainFrame.setSize(400, 200);
+ mainFrame.setLocation(200, 200);
+ mainFrame.setLayout(new FlowLayout());
+
+ textArea = new TextArea(2, 10);
+ textArea.setSize(300, 100);
+ textArea.setText("123456 789123");
+ mainFrame.add(textArea);
+ mainFrame.setVisible(true);
+ textArea.requestFocusInWindow();
+ }
+
+ public void dispose() {
+ if (mainFrame != null) {
+ mainFrame.dispose();
+ }
+ }
+
+ public void performTest() {
+ Point loc = textArea.getLocationOnScreen();
+ Rectangle textAreaBounds = new Rectangle();
+ textArea.getBounds(textAreaBounds);
+
+ // Move mouse at center in first row of TextArea.
+ robot.mouseMove(loc.x + textAreaBounds.width / 2, loc.y + 5);
+
+ // Perform selection by scrolling to right from end of char sequence.
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ for (int i = 0; i < textAreaBounds.width; i += 15) {
+ robot.mouseMove(i + loc.x + textAreaBounds.width / 2, loc.y + 5);
+ robot.delay(10);
+ }
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+
+ // Perform double click on beginning word of TextArea
+ robot.mouseMove(loc.x + 5, loc.y + 5);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.delay(100);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+
+ dispose();
+ if (!textArea.getSelectedText().contains("123456")) {
+ throw new RuntimeException ("TextArea over scrolled towards right. "
+ + "Selected text should contain: '123456' "
+ + "Actual selected test: '" + textArea.getSelectedText() + "'");
+ }
+ }
+
+ public static void main(String argv[]) throws RuntimeException {
+ OverScrollTest test = new OverScrollTest();
+ test.performTest();
+ }
+}
--- a/jdk/test/java/awt/TextArea/UsingWithMouse/SelectionAutoscrollTest.html Mon Mar 21 08:48:34 2016 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-<!--
- Copyright (c) 2007, 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.
--->
-
-<html>
-<!--
- @test
- @bug 6497109
- @summary TextArea must have selection expanding, and also be autoscrolled, if mouse is dragged from inside.
- @author Konstantin Voloshin: area=TextArea
- @library ../../regtesthelpers
- @build Util
- @run applet SelectionAutoscrollTest.html
- -->
-<head>
-<title> </title>
-</head>
-<body>
-
-<h1>SelectionAutoscrollTest<br>Bug ID: 6497109</h1>
-
-<p> This is an AUTOMATIC test, simply wait for completion </p>
-
-<APPLET CODE="SelectionAutoscrollTest.class" WIDTH=200 HEIGHT=200></APPLET>
-</body>
-</html>
--- a/jdk/test/java/awt/TextArea/UsingWithMouse/SelectionAutoscrollTest.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/test/java/awt/TextArea/UsingWithMouse/SelectionAutoscrollTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, 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
@@ -22,11 +22,13 @@
*/
/*
- test
- @bug 6497109
+ @test
+ @bug 6497109 6734341
@summary TextArea must have selection expanding, and also be autoscrolled, if mouse is dragged from inside.
+ @library ../../regtesthelpers
+ @build Util
@author Konstantin Voloshin: area=TextArea
- @run applet SelectionAutoscrollTest.html
+ @run main SelectionAutoscrollTest
*/
/**
@@ -38,12 +40,10 @@
*/
-import java.applet.Applet;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.GridLayout;
import java.awt.TextArea;
-
import java.awt.Point;
import java.awt.Dimension;
import java.awt.event.MouseEvent;
@@ -52,16 +52,18 @@
import test.java.awt.regtesthelpers.Util;
-public class SelectionAutoscrollTest extends Applet {
+public class SelectionAutoscrollTest {
TextArea textArea;
Robot robot;
final int desiredSelectionEnd = ('z'-'a'+1)*2; // 52
final static int SCROLL_DELAY = 10; // ms
- public void start () {
- createObjects();
- manipulateMouse();
- checkResults();
+ public static void main(String[] args) {
+ SelectionAutoscrollTest selectionAutoscrollTest
+ = new SelectionAutoscrollTest();
+ selectionAutoscrollTest.createObjects();
+ selectionAutoscrollTest.manipulateMouse();
+ selectionAutoscrollTest.checkResults();
}
void createObjects() {
@@ -102,7 +104,7 @@
robot.mousePress( MouseEvent.BUTTON1_MASK );
Util.waitForIdle( robot );
- for( int tremble=0; tremble < desiredSelectionEnd; ++tremble ) {
+ for( int tremble=0; tremble < 10; ++tremble ) {
// Mouse is moved repeatedly here (with conservatively chosen
// ammount of times), to give some time/chance for TextArea to
// autoscroll and for text-selection to expand to the end.
@@ -125,7 +127,7 @@
// and this is probably a bug). But, starting with 2nd iteration,
// all events received will be mouse-dragged events.
- moveMouseBelowTextArea( tremble%2!=0 );
+ moveMouseBelowTextArea( tremble );
Util.waitForIdle( robot );
// it is needed to add some small delay on Gnome
waitUntilScrollIsPerformed(robot);
@@ -138,16 +140,28 @@
void moveMouseToCenterOfTextArea() {
Dimension d = textArea.getSize();
Point l = textArea.getLocationOnScreen();
- robot.mouseMove( (int)(l.x+d.width*.5), (int)(l.y+d.height*.5) );
+ Util.mouseMove(robot, l, new Point((int) (l.x + d.width * .5),
+ (int) (l.y + d.height * .5)));
}
- void moveMouseBelowTextArea( boolean shift ) {
+ void moveMouseBelowTextArea(int tremble) {
Dimension d = textArea.getSize();
Point l = textArea.getLocationOnScreen();
- int x = (int)(l.x+d.width*.5);
- int y = (int)(l.y+d.height*1.5);
- if( shift ) y+=15;
- robot.mouseMove( x, y );
+ Point p1;
+ if (tremble == 0) {
+ p1 = new Point((int) (l.x + d.width * .5),
+ (int) (l.y + d.height * 0.5));
+ } else {
+ p1 = new Point((int) (l.x + d.width * .5),
+ (int) (l.y + d.height * 1.5));
+ }
+ Point p2 = new Point((int) (l.x + d.width * .5),
+ (int) (l.y + d.height * 1.5) + 15);
+ if (tremble % 2 == 0) {
+ Util.mouseMove(robot, p1, p2);
+ } else {
+ Util.mouseMove(robot, p2, p1);
+ }
}
void waitUntilScrollIsPerformed(Robot robot) {
@@ -160,15 +174,11 @@
}
void checkResults() {
- //try { Thread.sleep( 30*1000 ); }
- //catch( Exception e ) { throw new RuntimeException( e ); }
-
final int currentSelectionEnd = textArea.getSelectionEnd();
-
System.out.println(
- "TEST: Selection range after test is: ( "
- + textArea.getSelectionStart() + ", "
- + currentSelectionEnd + " )"
+ "TEST: Selection range after test is: ( "
+ + textArea.getSelectionStart() + ", "
+ + currentSelectionEnd + " )"
);
boolean resultOk = ( currentSelectionEnd == desiredSelectionEnd );
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/TextField/OverScrollTest/OverScrollTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2016, 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 8149636
+ @summary TextField over scrolls to right when selecting text towards right.
+ @requires os.family == "windows"
+ @run main OverScrollTest
+ */
+
+import java.awt.Frame;
+import java.awt.FlowLayout;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.TextField;
+import java.awt.event.InputEvent;
+
+public class OverScrollTest {
+ Frame mainFrame;
+ TextField textField;
+ Robot robot;
+
+ OverScrollTest() {
+ try {
+ robot = new Robot();
+ } catch (Exception ex) {
+ throw new RuntimeException(ex.getMessage());
+ }
+
+ mainFrame = new Frame();
+ mainFrame.setSize(400, 200);
+ mainFrame.setLocation(200, 200);
+ mainFrame.setLayout(new FlowLayout());
+
+ textField = new TextField(10);
+ textField.setSize(300, 100);
+ textField.setText("123456 789123");
+ mainFrame.add(textField);
+ mainFrame.setVisible(true);
+ textField.requestFocusInWindow();
+ }
+
+ public void dispose() {
+ if (mainFrame != null) {
+ mainFrame.dispose();
+ }
+ }
+
+ public void performTest() {
+ Point loc = textField.getLocationOnScreen();
+ Rectangle textFieldBounds = new Rectangle();
+ textField.getBounds(textFieldBounds);
+
+ // Move mouse at center in first row of TextField.
+ robot.mouseMove(loc.x + textFieldBounds.width / 2, loc.y + 5);
+
+ // Perform selection by scrolling to right from end of char sequence.
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ for (int i = 0; i < textFieldBounds.width; i += 15) {
+ robot.mouseMove(i + loc.x + textFieldBounds.width / 2, loc.y + 5);
+ robot.delay(10);
+ }
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+
+ // Perform double click on beginning word of TextField
+ robot.mouseMove(loc.x + 5, loc.y + 5);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.delay(100);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+
+ dispose();
+ if (!textField.getSelectedText().contains("123456")) {
+ throw new RuntimeException ("TextField over scrolled towards right. "
+ + "Selected text should contain: '123456' "
+ + "Actual selected test: '" + textField.getSelectedText() + "'");
+ }
+ }
+
+ public static void main(String argv[]) throws RuntimeException {
+ OverScrollTest test = new OverScrollTest();
+ test.performTest();
+ }
+}
--- a/jdk/test/java/awt/TextField/ScrollSelectionTest/ScrollSelectionTest.html Mon Mar 21 08:48:34 2016 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-<!--
- Copyright (c) 2008, 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.
--->
-
-<html>
-<!--
- @test
- @bug 4118621
- @summary tests that selected text isn't scrolled if there is enough room.
- @author prs: area=TextField
- @run applet/manual=yesno ScrollSelectionTest.html
- -->
-<head>
-<title> ScrollSelectionTest </title>
-</head>
-<body>
-
-<h1>ScrollSelectionTest<br>4118621: </h1>
-
-<p> See the dialog box (usually in upper left corner) for instructions</p>
-
-<APPLET CODE="ScrollSelectionTest.class" WIDTH=300 HEIGHT=300></APPLET>
-</body>
-</html>
--- a/jdk/test/java/awt/TextField/ScrollSelectionTest/ScrollSelectionTest.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/test/java/awt/TextField/ScrollSelectionTest/ScrollSelectionTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, 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
@@ -22,193 +22,240 @@
*/
/*
- test
- @bug 4118621
- @summary tests that selected text isn't scrolled when there is enough room.
- @author prs: area=TextField
- @run applet/manual=yesno ScrollSelectionTest.html
-*/
+ @test
+ @bug 4118621 8149636
+ @summary Test the selection scrolling in TextField.
+ @run main/manual ScrollSelectionTest
+ */
+import java.awt.Button;
+import java.awt.Dialog;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.Panel;
+import java.awt.TextArea;
+import java.awt.TextField;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
-/**
- * ScrollSelectionTest.java
- *
- * summary: tests that selected text isn't scrolled when there is enough room.
- */
+public class ScrollSelectionTest {
-import java.applet.Applet;
-import java.awt.Dialog;
-import java.awt.Frame;
-import java.awt.TextField;
-import java.awt.TextArea;
+ static Frame mainFrame;
+ static TextField textField;
-public class ScrollSelectionTest extends Applet
- {
-
- Frame frame = new Frame("ScrollSelectionTest frame");
- TextField tf = new TextField(40);
-
- public void init()
- {
- tf.setText("abcdefghijklmnopqrstuvwxyz");
- frame.add(tf);
- tf.select(0, 20);
+ private static void init() throws Exception {
+ String[] instructions
+ = {
+ "INSTRUCTIONS: There are 2 Tests",
+ "Test1: Text visibility with Scroll",
+ "This is a test for a win32 specific problem",
+ "If you see all the letters from 'a' to 'z' and",
+ "letters from 'a' to 't' are selected then test passes.",
+ "You may have to activate the frame to see the selection",
+ "highlighted (e.g. by clicking on frame's title).",
+ ".",
+ "Test2: Flicker with selection scroll",
+ "Mouse press on the TextField text.",
+ "Move mouse towards left or right with selecting text.",
+ "Move mouse away outside the bounds of TextField.",
+ "No flicker should be observed.",
+ };
- String[] instructions = {
- "INSTRUCTIONS:",
- "This is a test for a win32 specific problem",
- "If you see all the letters from 'a' to 'z' and",
- "letters from 'a' to 't' are selected then test passes.",
- "You may have to activate the frame to see the selection"
- + " highlighted (e.g. by clicking on frame's title)."
- };
- Sysout.createDialogWithInstructions( instructions );
+ Sysout.createDialog();
+ Sysout.printInstructions(instructions);
+ }
- }// init()
+ public static void initTestWindow() {
+ mainFrame = new Frame("ScrollSelectionTest frame");
+ mainFrame.setBounds(500, 0, 400, 200);
- public void start ()
- {
- setSize (300,300);
- setVisible(true);
-
- frame.setVisible(true);
- frame.setBounds (400, 0, 300, 300);
-
- }// start()
+ textField = new TextField(40);
+ textField.setText("abcdefghijklmnopqrstuvwxyz");
+ mainFrame.add(textField);
+ mainFrame.setLayout(new FlowLayout());
+ textField.select(0, 20);
+ mainFrame.setVisible(true);
+ }
- }// class ScrollSelectionTest
-
-/****************************************************
- Standard Test Machinery
- DO NOT modify anything below -- it's a standard
- chunk of code whose purpose is to make user
- interaction uniform, and thereby make it simpler
- to read and understand someone else's test.
- ****************************************************/
+ public static void dispose() {
+ Sysout.dispose();
+ mainFrame.dispose();
+ }
-/**
- This is part of the standard test machinery.
- It creates a dialog (with the instructions), and is the interface
- for sending text messages to the user.
- To print the instructions, send an array of strings to Sysout.createDialog
- WithInstructions method. Put one line of instructions per array entry.
- To display a message for the tester to see, simply call Sysout.println
- with the string to be displayed.
- This mimics System.out.println but works within the test harness as well
- as standalone.
- */
+ /**
+ * ***************************************************
+ * Standard Test Machinery Section DO NOT modify anything in this section --
+ * it's a standard chunk of code which has all of the synchronization
+ * necessary for the test harness. By keeping it the same in all tests, it
+ * is easier to read and understand someone else's test, as well as insuring
+ * that all tests behave correctly with the test harness. There is a section
+ * following this for test-defined classes
+ * ****************************************************
+ */
+ private static boolean theTestPassed = false;
+ private static boolean testGeneratedInterrupt = false;
+ private static String failureMessage = "";
+ private static Thread mainThread = null;
+ final private static int sleepTime = 300000;
-class Sysout
- {
- private static TestDialog dialog;
+ public static void main(String args[]) throws Exception {
+ mainThread = Thread.currentThread();
+ try {
+ init();
+ initTestWindow();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ try {
+ mainThread.sleep(sleepTime);
+ } catch (InterruptedException e) {
+ dispose();
+ if (testGeneratedInterrupt && !theTestPassed) {
+ throw new Exception(failureMessage);
+ }
+ }
+ if (!testGeneratedInterrupt) {
+ dispose();
+ throw new RuntimeException("Timed out after " + sleepTime / 1000
+ + " seconds");
+ }
+ }
- public static void createDialogWithInstructions( String[] instructions )
- {
- dialog = new TestDialog( new Frame(), "Instructions" );
- dialog.printInstructions( instructions );
- dialog.show();
- println( "Any messages for the tester will display here." );
+ public static synchronized void pass() {
+ theTestPassed = true;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
}
- public static void createDialog( )
- {
- dialog = new TestDialog( new Frame(), "Instructions" );
- String[] defInstr = { "Instructions will appear here. ", "" } ;
- dialog.printInstructions( defInstr );
- dialog.show();
- println( "Any messages for the tester will display here." );
+ public static synchronized void fail(String whyFailed) {
+ theTestPassed = false;
+ testGeneratedInterrupt = true;
+ failureMessage = whyFailed;
+ mainThread.interrupt();
+ }
+}
+
+// *********** End Standard Test Machinery Section **********
+/**
+ * **************************************************
+ * Standard Test Machinery DO NOT modify anything below -- it's a standard chunk
+ * of code whose purpose is to make user interaction uniform, and thereby make
+ * it simpler to read and understand someone else's test.
+ * **************************************************
+ */
+/**
+ * This is part of the standard test machinery. It creates a dialog (with the
+ * instructions), and is the interface for sending text messages to the user. To
+ * print the instructions, send an array of strings to Sysout.createDialog
+ * WithInstructions method. Put one line of instructions per array entry. To
+ * display a message for the tester to see, simply call Sysout.println with the
+ * string to be displayed. This mimics System.out.println but works within the
+ * test harness as well as standalone.
+ */
+class Sysout {
+ private static TestDialog dialog;
+ private static Frame frame;
+
+ public static void createDialog() {
+ frame = new Frame();
+ dialog = new TestDialog(frame, "Instructions");
+ String[] defInstr = {"Instructions will appear here. ", ""};
+ dialog.printInstructions(defInstr);
+ dialog.setVisible(true);
+ println("Any messages for the tester will display here.");
}
-
- public static void printInstructions( String[] instructions )
- {
- dialog.printInstructions( instructions );
+ public static void printInstructions(String[] instructions) {
+ dialog.printInstructions(instructions);
}
-
- public static void println( String messageIn )
- {
- dialog.displayMessage( messageIn );
+ public static void println(String messageIn) {
+ dialog.displayMessage(messageIn);
}
- }// Sysout class
+ public static void dispose() {
+ dialog.dispose();
+ frame.dispose();
+ }
+}
/**
- This is part of the standard test machinery. It provides a place for the
- test instructions to be displayed, and a place for interactive messages
- to the user to be displayed.
- To have the test instructions displayed, see Sysout.
- To have a message to the user be displayed, see Sysout.
- Do not call anything in this dialog directly.
- */
-class TestDialog extends Dialog
- {
-
- TextArea instructionsText;
- TextArea messageText;
- int maxStringLength = 80;
-
- //DO NOT call this directly, go through Sysout
- public TestDialog( Frame frame, String name )
- {
- super( frame, name );
- int scrollBoth = TextArea.SCROLLBARS_BOTH;
- instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
- add( "North", instructionsText );
-
- messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
- add("South", messageText);
-
- pack();
-
- show();
- }// TestDialog()
-
- //DO NOT call this directly, go through Sysout
- public void printInstructions( String[] instructions )
- {
- //Clear out any current instructions
- instructionsText.setText( "" );
-
- //Go down array of instruction strings
+ * This is part of the standard test machinery. It provides a place for the test
+ * instructions to be displayed, and a place for interactive messages to the
+ * user to be displayed. To have the test instructions displayed, see Sysout. To
+ * have a message to the user be displayed, see Sysout. Do not call anything in
+ * this dialog directly.
+ */
+class TestDialog extends Dialog implements ActionListener {
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+ Panel buttonP;
+ Button failB;
+ Button passB;
- String printStr, remainingStr;
- for( int i=0; i < instructions.length; i++ )
- {
- //chop up each into pieces maxSringLength long
- remainingStr = instructions[ i ];
- while( remainingStr.length() > 0 )
- {
- //if longer than max then chop off first max chars to print
- if( remainingStr.length() >= maxStringLength )
- {
- //Try to chop on a word boundary
- int posOfSpace = remainingStr.
- lastIndexOf( ' ', maxStringLength - 1 );
+ // DO NOT call this directly, go through Sysout
+ public TestDialog(Frame frame, String name) {
+ super(frame, name);
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
+ add("North", instructionsText);
- if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+ messageText = new TextArea("", 5, maxStringLength, scrollBoth);
+ add("Center", messageText);
- printStr = remainingStr.substring( 0, posOfSpace + 1 );
- remainingStr = remainingStr.substring( posOfSpace + 1 );
- }
- //else just print
- else
- {
- printStr = remainingStr;
- remainingStr = "";
- }
+ buttonP = new Panel();
+ passB = new Button("pass");
+ passB.setActionCommand("pass");
+ passB.addActionListener(this);
+ buttonP.add("East", passB);
- instructionsText.append( printStr + "\n" );
-
- }// while
-
- }// for
+ failB = new Button("Fail");
+ failB.setActionCommand("fail");
+ failB.addActionListener(this);
+ buttonP.add("West", failB);
- }//printInstructions()
-
- //DO NOT call this directly, go through Sysout
- public void displayMessage( String messageIn )
- {
- messageText.append( messageIn + "\n" );
+ add("South", buttonP);
+ pack();
+ setVisible(true);
}
- }// TestDialog class
+ // DO NOT call this directly, go through Sysout
+ public void printInstructions(String[] instructions) {
+ instructionsText.setText("");
+ String printStr, remainingStr;
+ for (int i = 0; i < instructions.length; i++) {
+ remainingStr = instructions[i];
+ while (remainingStr.length() > 0) {
+ if (remainingStr.length() >= maxStringLength) {
+ int posOfSpace = remainingStr.
+ lastIndexOf(' ', maxStringLength - 1);
+
+ if (posOfSpace <= 0) {
+ posOfSpace = maxStringLength - 1;
+ }
+
+ printStr = remainingStr.substring(0, posOfSpace + 1);
+ remainingStr = remainingStr.substring(posOfSpace + 1);
+ }
+ else {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+ instructionsText.append(printStr + "\n");
+ }
+ }
+ }
+
+ public void displayMessage(String messageIn) {
+ messageText.append(messageIn + "\n");
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (e.getActionCommand().equals("pass")) {
+ ScrollSelectionTest.pass();
+ } else {
+ ScrollSelectionTest.fail("User Clicked Fail");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/FindOwner/FindOwnerTest.html Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,43 @@
+<!--
+ Copyright (c) 2015, 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 8139227
+ @summary Text fields in JPopupMenu structure do not receive focus in hosted
+ Applets
+ @author Semyon Sadetsky
+ @run applet FindOwnerTest.html
+-->
+
+<html>
+<head>
+ <title>Testing Menus</title>
+</head>
+<body>
+<applet id="ownerTester"
+ name="Testing Owner"
+ code="FindOwnerTest.class"
+ width="250" height="150">
+</applet>
+</body>
+</html>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/FindOwner/FindOwnerTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2015, 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 8139227
+ @summary Text fields in JPopupMenu structure do not receive focus in hosted
+ Applets
+ @author Semyon Sadetsky
+ @run applet FindOwnerTest.html
+*/
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+public class FindOwnerTest extends Applet
+{
+
+ private boolean gained;
+
+ public void init() {
+ super.init();
+ }
+
+ @Override
+ public void start() {
+ Window owner = SwingUtilities.windowForComponent(this);
+
+ Window window1 = new Window(owner);
+ window1.setVisible(true);
+
+ Window window2 = new Window(window1);
+ window2.setFocusable(true);
+ JTextField field = new JTextField("JTextField");
+ field.addFocusListener(new FocusListener() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ gained = true;
+ }
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ }
+ });
+ window2.setBounds(100, 100, 200, 200);
+ window2.add(field);
+ window2.setVisible(true);
+
+ try {
+ gained = false;
+ Robot robot = new Robot();
+ robot.setAutoDelay(50);
+ robot.waitForIdle();
+ robot.delay(200);
+
+ Point p = field.getLocationOnScreen();
+ System.out.println(p);
+ robot.mouseMove(p.x + 1, p.y + 1);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+ robot.delay(200);
+
+ if (!gained) {
+ throw new Exception("Focus is not gained upon mouse click");
+ }
+ System.out.println("ok");
+ } catch (SecurityException e) {
+
+ JOptionPane optionPane = new JOptionPane(
+ "You are in the browser so test is manual. Try to " +
+ "click \"JTextField\" in the opened window then press OK " +
+ "below",
+ JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
+ JDialog dialog =
+ optionPane.createDialog(null,"FindOwnerTest instruction");
+ dialog.setModalityType(Dialog.ModalityType.DOCUMENT_MODAL);
+ dialog.setVisible(true);
+ if (!gained) {
+ throw new RuntimeException(
+ "Focus is not gained upon mouse click");
+ }
+ System.out.println("ok");
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ window1.dispose();
+ stop();
+ }
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/MultiWindowApp/ChildAlwaysOnTopTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2015, 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 @summary setAlwaysOnTop doesn't behave correctly in Linux/Solaris under
+ * certain scenarios
+ * @bug 8021961
+ * @author Semyon Sadetsky
+ * @run main ChildAlwaysOnTopTest
+ */
+
+import javax.swing.*;
+import java.awt.*;
+
+public class ChildAlwaysOnTopTest {
+
+ private static Window win1;
+ private static Window win2;
+ private static Point point;
+
+ public static void main(String[] args) throws Exception {
+ if( Toolkit.getDefaultToolkit().isAlwaysOnTopSupported() ) {
+
+
+ test(null);
+
+ Window f = new Frame();
+ f.setBackground(Color.darkGray);
+ f.setSize(500, 500);
+ try {
+ test(f);
+ } finally {
+ f.dispose();
+ }
+
+ f = new Frame();
+ f.setBackground(Color.darkGray);
+ f.setSize(500, 500);
+ f.setVisible(true);
+ f = new Dialog((Frame)f);
+ try {
+ test(f);
+ } finally {
+ ((Frame)f.getParent()).dispose();
+ }
+ }
+ System.out.println("ok");
+ }
+
+ public static void test(Window parent) throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ win1 = parent == null ? new JDialog() : new JDialog(parent);
+ win1.setName("top");
+ win2 = parent == null ? new JDialog() : new JDialog(parent);
+ win2.setName("behind");
+ win1.setSize(200, 200);
+ Panel panel = new Panel();
+ panel.setBackground(Color.GREEN);
+ win1.add(panel);
+ panel = new Panel();
+ panel.setBackground(Color.RED);
+ win2.add(panel);
+ win1.setAlwaysOnTop(true);
+ win2.setAlwaysOnTop(false);
+ win1.setVisible(true);
+ }
+ });
+
+ Robot robot = new Robot();
+ robot.delay(200);
+ robot.waitForIdle();
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ point = win1.getLocationOnScreen();
+ win2.setBounds(win1.getBounds());
+ win2.setVisible(true);
+ }
+ });
+
+ robot.delay(200);
+ robot.waitForIdle();
+
+ Color color = robot.getPixelColor(point.x + 100, point.y + 100);
+ if(!color.equals(Color.GREEN)) {
+ win1.dispose();
+ win2.dispose();
+ throw new RuntimeException("alawaysOnTop window is sent back by " +
+ "another child window setVisible(). " + color);
+ }
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ win2.toFront();
+ if (parent != null) {
+ parent.setLocation(win1.getLocation());
+ parent.toFront();
+ }
+ }
+ });
+
+ robot.delay(200);
+ robot.waitForIdle();
+
+ color = robot.getPixelColor(point.x + 100, point.y + 100);
+ if(!color.equals(Color.GREEN)) {
+ win1.dispose();
+ win2.dispose();
+ throw new RuntimeException("alawaysOnTop window is sent back by " +
+ "another child window toFront(). " + color);
+ }
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ win1.setAlwaysOnTop(false);
+ if (parent != null) {
+ parent.setVisible(false);
+ parent.setVisible(true);
+ }
+ win2.toFront();
+ }
+ });
+
+ robot.delay(200);
+ robot.waitForIdle();
+
+ color = robot.getPixelColor(point.x + 100, point.y + 100);
+ if(!color.equals(Color.RED)) {
+ throw new RuntimeException("Failed to unset alawaysOnTop " + color);
+ }
+
+ win1.dispose();
+ win2.dispose();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/font/FontScaling/FontScalingTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2016, 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 javax.swing.JButton;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+/*
+ * @test
+ * @bug 8076545
+ * @summary Text size is twice bigger under Windows L&F on Win 8.1 with
+ * HiDPI display
+ */
+public class FontScalingTest {
+
+ public static void main(String[] args) throws Exception {
+ int metalFontSize = getFontSize(MetalLookAndFeel.class.getName());
+ int systemFontSize = getFontSize(UIManager.getSystemLookAndFeelClassName());
+
+ if (Math.abs(systemFontSize - metalFontSize) > 8) {
+ throw new RuntimeException("System L&F is too big!");
+ }
+ }
+
+ private static int getFontSize(String laf) throws Exception {
+
+ UIManager.setLookAndFeel(laf);
+ final int[] sizes = new int[1];
+
+ SwingUtilities.invokeAndWait(() -> {
+ JButton button = new JButton("Test");
+ sizes[0] = button.getFont().getSize();
+ });
+
+ return sizes[0];
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/image/DrawImage/ScaledImageAlphaTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2016, 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 8139183
+ * @summary Test verifies whether alpha channel of a translucent
+ * image is proper or not after scaling through drawImage.
+ * @run main ScaledImageAlphaTest
+ */
+
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsEnvironment;
+import java.awt.Transparency;
+import java.awt.image.BufferedImage;
+import java.awt.image.VolatileImage;
+
+public class ScaledImageAlphaTest {
+
+ static final int translucentAlpha = 128, opaqueAlpha = 255;
+ static final int[] translucentVariants = new int[] {
+ BufferedImage.TYPE_INT_ARGB,
+ BufferedImage.TYPE_INT_ARGB_PRE,
+ BufferedImage.TYPE_4BYTE_ABGR,
+ BufferedImage.TYPE_4BYTE_ABGR_PRE
+ };
+ static final int[] alphaValues = new int[] {
+ translucentAlpha,
+ opaqueAlpha
+ };
+ static int width = 50, height = 50;
+ static int scaleX = 5, scaleY = 5, scaleWidth = 40, scaleHeight = 40;
+
+ private static void verifyAlpha(Color color, int alpha) {
+
+ /* if extracted alpha value is equal alpha that we set
+ * for background color, alpha channel is not lost
+ * while scaling otherwise we have lost alpha channel.
+ */
+ int extractedAlpha = color.getAlpha();
+
+ if (extractedAlpha != alpha) {
+ throw new RuntimeException("Alpha channel for background"
+ + " is lost while scaling");
+ }
+ }
+
+ private static void validateBufferedImageAlpha() {
+
+ Color backgroundColor, extractedColor;
+ // verify for all translucent buffered image types
+ for (int type : translucentVariants) {
+ // verify for both opaque and translucent background color
+ for (int alpha : alphaValues) {
+ // create BufferedImage of dimension (50,50)
+ BufferedImage img = new
+ BufferedImage(width, height, type);
+ Graphics2D imgGraphics = (Graphics2D)img.getGraphics();
+ /* scale image to smaller dimension and set any
+ * background color with alpha.
+ */
+ backgroundColor = new Color(0, 255, 0, alpha);
+ imgGraphics.
+ drawImage(img, scaleX, scaleY, scaleWidth, scaleHeight,
+ backgroundColor, null);
+ imgGraphics.dispose();
+
+ /* get pixel information for background color with
+ * scaled coordinates.
+ */
+ extractedColor = new Color(img.getRGB(scaleX, scaleY), true);
+ verifyAlpha(extractedColor, alpha);
+ }
+ }
+ }
+
+ private static void validateVolatileImageAlpha() {
+
+ Color backgroundColor, extractedColor;
+ VolatileImage img;
+ BufferedImage bufImg = new
+ BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+ for (int alpha : alphaValues) {
+ backgroundColor = new Color(0, 255, 0, alpha);
+ do {
+ img = createVolatileImage(width, height,
+ Transparency.TRANSLUCENT);
+ Graphics2D imgGraphics = (Graphics2D)img.getGraphics();
+ // clear VolatileImage as by default it has white opaque image
+ imgGraphics.setComposite(AlphaComposite.Clear);
+ imgGraphics.fillRect(0,0, width, height);
+
+ imgGraphics.setComposite(AlphaComposite.SrcOver);
+ /* scale image to smaller dimension and set background color
+ * to green with translucent alpha.
+ */
+ imgGraphics.
+ drawImage(img, scaleX, scaleY, scaleWidth, scaleHeight,
+ backgroundColor, null);
+ //get BufferedImage out of VolatileImage
+ bufImg = img.getSnapshot();
+ imgGraphics.dispose();
+ } while (img.contentsLost());
+
+ /* get pixel information for background color with
+ * scaled coordinates.
+ */
+ extractedColor = new Color(bufImg.getRGB(scaleX, scaleY), true);
+ verifyAlpha(extractedColor, alpha);
+ }
+ }
+
+ private static VolatileImage createVolatileImage(int width, int height,
+ int transparency) {
+ GraphicsEnvironment ge = GraphicsEnvironment.
+ getLocalGraphicsEnvironment();
+ GraphicsConfiguration gc = ge.getDefaultScreenDevice().
+ getDefaultConfiguration();
+
+ VolatileImage image = gc.createCompatibleVolatileImage(width, height,
+ transparency);
+ return image;
+ }
+
+ public static void main(String[] args) {
+ // test alpha channel with different types of BufferedImage
+ validateBufferedImageAlpha();
+ // test alpha channel with VolatileImage
+ validateVolatileImageAlpha();
+ }
+}
--- a/jdk/test/java/awt/image/multiresolution/BaseMultiResolutionImageTest.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/test/java/awt/image/multiresolution/BaseMultiResolutionImageTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -191,6 +191,17 @@
if (!passed) {
throw new RuntimeException("Resolution variants list is modifiable!");
}
+
+ passed = false;
+ try {
+ mrImage.getGraphics();
+ } catch (UnsupportedOperationException e) {
+ passed = true;
+ }
+
+ if (!passed) {
+ throw new RuntimeException("getGraphics() method shouldn't be supported!");
+ }
}
private static int getSize(int i) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/image/multiresolution/Corrupted2XImageTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2016, 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 8142406
+ * @author a.stepanov
+ * @summary [HiDPI] [macosx] check that for a pair of images
+ * (image.ext, image@2x.ext) the 1st one is loaded
+ * in case if the 2nd is corrupted
+ *
+ * @requires (os.family == "mac")
+ *
+ * @library ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @run main Corrupted2XImageTest
+ */
+
+import java.awt.*;
+import java.awt.geom.AffineTransform;
+import java.awt.image.*;
+import java.io.*;
+
+import javax.imageio.ImageIO;
+
+public class Corrupted2XImageTest extends Frame {
+
+ private static final int SZ = 200;
+ private static final Color C = Color.BLUE;
+
+ private final String format, name1x, name2x;
+
+ public Corrupted2XImageTest(String format) throws IOException {
+
+ this.format = format;
+ name1x = "test." + format;
+ name2x = "test@2x." + format;
+ createFiles();
+ }
+
+ private void UI() {
+
+ setTitle(format);
+ setSize(SZ, SZ);
+ setResizable(false);
+ setLocation(50, 50);
+ setVisible(true);
+ }
+
+ @Override
+ public void paint(Graphics g) {
+
+ Image img = Toolkit.getDefaultToolkit().getImage(
+ new File(name1x).getAbsolutePath());
+ g.drawImage(img, 0, 0, this);
+ }
+
+ private void createFiles() throws IOException {
+
+ BufferedImage img =
+ new BufferedImage(SZ, SZ, BufferedImage.TYPE_INT_RGB);
+ Graphics g = img.getGraphics();
+ g.setColor(C);
+ g.fillRect(0, 0, SZ, SZ);
+ ImageIO.write(img, format, new File(name1x));
+
+ // corrupted @2x "image" - just a text file
+ Writer writer = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(new File(name2x)), "utf-8"));
+ writer.write("corrupted \"image\"");
+ writer.close();
+ }
+
+ // need this for jpg
+ private static boolean cmpColors(Color c1, Color c2) {
+
+ int tol = 10;
+ return (
+ Math.abs(c2.getRed() - c1.getRed() ) < tol &&
+ Math.abs(c2.getGreen() - c1.getGreen()) < tol &&
+ Math.abs(c2.getBlue() - c1.getBlue() ) < tol);
+ }
+
+ private void doTest() throws Exception {
+
+ ExtendedRobot r = new ExtendedRobot();
+ System.out.println("format: " + format);
+ r.waitForIdle(1000);
+ EventQueue.invokeAndWait(this::UI);
+ r.waitForIdle(1000);
+ Point loc = getLocationOnScreen();
+ Color c = r.getPixelColor(loc.x + SZ / 2, loc.y + SZ / 2);
+ if (!cmpColors(c, C)) {
+ throw new RuntimeException("test failed, color = " + c); }
+ System.out.println("ok");
+ dispose();
+ }
+
+ private static boolean is2x() {
+
+ AffineTransform tr = GraphicsEnvironment.getLocalGraphicsEnvironment().
+ getDefaultScreenDevice().getDefaultConfiguration().
+ getDefaultTransform();
+ return Math.min(tr.getScaleX(), tr.getScaleY()) > 1.001;
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ // TODO: update the test with sun.java2d.uiScale option (remove is2x())
+ // after fix of JDK-8150844 enh. to run it on non-HiDPI machines as well
+ if (is2x()) {
+ // formats supported by Toolkit.getImage()
+ for (String format: new String[]{"gif", "jpg", "png"}) {
+ (new Corrupted2XImageTest(format)).doTest();
+ }
+ } else {
+ System.out.println("this test is for HiDPI only");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/image/multiresolution/MultiResolutionJOptionPaneIconTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2016, 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 8150176 8150844
+ @author a.stepanov
+ @summary Check if correct resolution variant is used
+ for JOptionPane dialog / internal frame icons.
+ @library ../../../../lib/testlibrary/
+ @build ExtendedRobot
+ @run main/othervm/timeout=300 -Dsun.java2d.uiScale=1 MultiResolutionJOptionPaneIconTest
+ @run main/othervm/timeout=300 -Dsun.java2d.uiScale=2 MultiResolutionJOptionPaneIconTest
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.image.*;
+import javax.swing.*;
+
+public class MultiResolutionJOptionPaneIconTest implements ActionListener {
+
+ private final static Color C1X = Color.ORANGE, C2X = Color.CYAN;
+
+ private final boolean isInternal;
+
+ private volatile JFrame test;
+ private volatile JDialog dialog;
+ private volatile JInternalFrame frame;
+ private final JDesktopPane parentPane = new JDesktopPane();
+ private final JButton run = new JButton("run");
+
+ private final ExtendedRobot robot = new ExtendedRobot();
+
+ private static BufferedImage getSquare(int sz, Color c) {
+
+ BufferedImage img = new BufferedImage(sz, sz, BufferedImage.TYPE_INT_RGB);
+ Graphics g = img.getGraphics();
+ g.setColor(c);
+ g.fillRect(0, 0, sz, sz);
+ return img;
+ }
+
+ private static Icon getIcon() {
+
+ BaseMultiResolutionImage mri = new BaseMultiResolutionImage(
+ new BufferedImage[]{getSquare(16, C1X), getSquare(32, C2X)});
+ return new ImageIcon(mri);
+ }
+
+ public MultiResolutionJOptionPaneIconTest(boolean internal,
+ UIManager.LookAndFeelInfo lf) throws Exception {
+
+ UIManager.setLookAndFeel(lf.getClassName());
+
+ isInternal = internal;
+ robot.setAutoDelay(50);
+ SwingUtilities.invokeAndWait(this::UI);
+ }
+
+ private void UI() {
+
+ test = new JFrame();
+ test.setLayout(new BorderLayout());
+ test.add(parentPane, BorderLayout.CENTER);
+ run.addActionListener(this);
+ test.add(run, BorderLayout.SOUTH);
+ test.setUndecorated(true);
+ test.setSize(400, 300);
+ test.setLocation(50, 50);
+ test.setVisible(true);
+ }
+
+ private void disposeAll() {
+
+ if (dialog != null) { dialog.dispose(); }
+ if (frame != null) { frame.dispose(); }
+ if (test != null) { test.dispose(); }
+ }
+
+ public void doTest() throws Exception {
+
+ robot.waitForIdle(1000);
+ clickButton(robot);
+ robot.waitForIdle(2000);
+
+ Component c = isInternal ?
+ frame.getContentPane() : dialog.getContentPane();
+
+ System.out.println("\ncheck " + (isInternal ? "internal frame" :
+ "dialog") + " icon:");
+
+ Point pt = c.getLocationOnScreen();
+ checkColors(pt.x, c.getWidth(), pt.y, c.getHeight());
+ System.out.println("ok");
+ robot.waitForIdle();
+ SwingUtilities.invokeAndWait(this::disposeAll);
+ robot.waitForIdle();
+ }
+
+ private void checkColors(int x0, int w, int y0, int h) {
+
+ boolean is2x = "2".equals(System.getProperty("sun.java2d.uiScale"));
+ Color
+ expected = is2x ? C2X : C1X,
+ unexpected = is2x ? C1X : C2X;
+
+ for (int y = y0; y < y0 + h; y += 5) {
+ for (int x = x0; x < x0 + w; x += 5) {
+
+ Color c = robot.getPixelColor(x, y);
+ if (c.equals(unexpected)) {
+ throw new RuntimeException(
+ "invalid color was found, test failed");
+ } else if (c.equals(expected)) { return; }
+ }
+ }
+
+ // no icon found at all
+ throw new RuntimeException("the icon wasn't found");
+ }
+
+ private void showDialogOrFrame() {
+
+ JOptionPane pane = new JOptionPane("",
+ JOptionPane.DEFAULT_OPTION,
+ JOptionPane.INFORMATION_MESSAGE,
+ getIcon());
+ pane.setOptions(new Object[]{}); // no buttons
+
+ if (isInternal) {
+ frame = pane.createInternalFrame(parentPane, "");
+ frame.setLocation(0, 0);
+ frame.setVisible(true);
+ } else {
+ dialog = pane.createDialog(parentPane, "");
+ dialog.setVisible(true);
+ }
+ }
+
+ public void clickButton(ExtendedRobot robot) {
+
+ Point pt = run.getLocationOnScreen();
+ robot.mouseMove(pt.x + run.getWidth() / 2, pt.y + run.getHeight() / 2);
+ robot.waitForIdle();
+ robot.click();
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent event) { showDialogOrFrame(); }
+
+
+ public static void main(String[] args) throws Exception {
+
+ for (UIManager.LookAndFeelInfo LF: UIManager.getInstalledLookAndFeels()) {
+ System.out.println("\nL&F: " + LF.getName());
+ (new MultiResolutionJOptionPaneIconTest(false, LF)).doTest();
+ (new MultiResolutionJOptionPaneIconTest(true , LF)).doTest();
+ }
+ }
+}
--- a/jdk/test/java/awt/image/multiresolution/MultiResolutionRenderingHintsTest.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/test/java/awt/image/multiresolution/MultiResolutionRenderingHintsTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -47,6 +47,7 @@
* @author Alexander Scherbatiy
* @summary Custom MultiResolution image support on HiDPI displays
* @modules java.desktop/sun.java2d
+ * @modules java.desktop/sun.java2d.loops
* @run main MultiResolutionRenderingHintsTest
*/
public class MultiResolutionRenderingHintsTest {
--- a/jdk/test/java/awt/image/multiresolution/MultiResolutionTrayIconTest/MultiResolutionTrayIconTest.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/test/java/awt/image/multiresolution/MultiResolutionTrayIconTest/MultiResolutionTrayIconTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -90,8 +90,10 @@
BufferedImage nok = generateImage(w / 2 + 2, h / 2 + 2, Color.RED);
BaseMultiResolutionImage mri =
new BaseMultiResolutionImage(new BufferedImage[] {nok, img});
- icon = new TrayIcon(img);
+ icon = new TrayIcon(img);
+ icon.setImageAutoSize(true); // just in case
iconMRI = new TrayIcon(mri);
+ iconMRI.setImageAutoSize(true);
}
private void doTest() {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/image/multiresolution/MultiresolutionIconTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,238 @@
+/*
+ * Copyright (c) 2016, 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 8150724 8151303
+ * @author a.stepanov
+ * @summary Check that correct resolution variants are chosen for icons
+ * when multiresolution image is used for their construction.
+ *
+ * @requires (os.family != "mac")
+ *
+ * @library ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @run main/othervm/timeout=240 -Dsun.java2d.uiScale=1 MultiresolutionIconTest
+ * @run main/othervm/timeout=240 -Dsun.java2d.uiScale=2 MultiresolutionIconTest
+ */
+
+
+// TODO: please remove the "@requires" tag after 8151303 fix
+
+
+import java.awt.*;
+import java.awt.event.InputEvent;
+import java.awt.geom.AffineTransform;
+import java.awt.image.BaseMultiResolutionImage;
+import java.awt.image.BufferedImage;
+import javax.swing.*;
+
+public class MultiresolutionIconTest extends JFrame {
+
+ private final static int SZ = 100;
+ private final static int N = 5; // number of components
+
+ private final static String SCALE = "sun.java2d.uiScale";
+ private final static Color C1X = Color.RED;
+ private final static Color C2X = Color.BLUE;
+
+ private JLabel lbl;
+ private JTabbedPane tabbedPane;
+
+ private final ExtendedRobot r;
+
+ private static BufferedImage generateImage(int sz, Color c) {
+
+ BufferedImage img = new BufferedImage(sz, sz, BufferedImage.TYPE_INT_RGB);
+ Graphics g = img.getGraphics();
+ g.setColor(c);
+ g.fillRect(0, 0, sz, sz);
+ return img;
+ }
+
+ public MultiresolutionIconTest(UIManager.LookAndFeelInfo lf) throws Exception {
+
+ UIManager.setLookAndFeel(lf.getClassName());
+ r = new ExtendedRobot();
+ SwingUtilities.invokeAndWait(this::UI);
+ }
+
+ private void UI() {
+
+ setUndecorated(true);
+
+ BufferedImage img1x = generateImage(SZ / 2, C1X);
+ BufferedImage img2x = generateImage(SZ, C2X);
+ BaseMultiResolutionImage mri = new BaseMultiResolutionImage(
+ new BufferedImage[]{img1x, img2x});
+ Icon icon = new ImageIcon(mri);
+
+ // hardcoded icon size for OS X (Mac OS X L&F) - see JDK-8151060
+ BufferedImage tab1x = generateImage(16, C1X);
+ BufferedImage tab2x = generateImage(32, C2X);
+ BaseMultiResolutionImage tabMRI = new BaseMultiResolutionImage(
+ new BufferedImage[]{tab1x, tab2x});
+ Icon tabIcon = new ImageIcon(tabMRI);
+
+ setSize((N + 1) * SZ, SZ);
+ setLocation(50, 50);
+
+ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ getContentPane().setLayout(new GridLayout(1, 1));
+
+ JPanel p = new JPanel();
+ p.setLayout(new GridLayout(1, N));
+
+ JButton btn = new JButton(icon);
+ p.add(btn);
+
+ JToggleButton tbn = new JToggleButton(icon);
+ p.add(tbn);
+
+ JRadioButton rbn = new JRadioButton(icon);
+ rbn.setHorizontalAlignment(SwingConstants.CENTER);
+ p.add(rbn);
+
+ JCheckBox cbx = new JCheckBox(icon);
+ cbx.setHorizontalAlignment(SwingConstants.CENTER);
+ p.add(cbx);
+
+ lbl = new JLabel(icon);
+ p.add(lbl);
+
+ tabbedPane = new JTabbedPane(JTabbedPane.LEFT);
+ tabbedPane.addTab("", tabIcon, p);
+ getContentPane().add(tabbedPane);
+
+ setResizable(false);
+ setVisible(true);
+ }
+
+ private static boolean is2x() {
+
+ AffineTransform tr = GraphicsEnvironment.getLocalGraphicsEnvironment().
+ getDefaultScreenDevice().getDefaultConfiguration().
+ getDefaultTransform();
+ return (Math.min(tr.getScaleX(), tr.getScaleY()) > 1.001);
+ }
+
+ private boolean checkPressedColor(int x, int y, Color ok) {
+
+ r.mouseMove(x, y);
+ r.waitForIdle();
+ r.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+ r.waitForIdle(100);
+ Color c = r.getPixelColor(x, y);
+ r.waitForIdle(100);
+ r.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+ r.waitForIdle(100);
+ if (!c.equals(ok)) { return false; }
+ // check the icon's color hasn't changed
+ // after the mouse was released
+ c = r.getPixelColor(x, y);
+ return c.equals(ok);
+ }
+
+ private boolean checkTabIcon(
+ int xStart, int xEnd, int yStart, int yEnd, Color ok, Color nok) {
+
+ for (int y = yStart; y < yEnd; y += 2) {
+ for (int x = xStart; x < xEnd; x += 2) {
+ Color c = r.getPixelColor(x, y);
+ if (c.equals(nok)) { return false; }
+ else if (c.equals(ok)) {
+ // shift a bit to avoid the selection effects
+ return checkPressedColor(x + 5, y + 5, ok);
+ }
+ }
+ }
+
+ return false; // didn't find the icon
+ }
+
+
+ private void doTest() {
+
+ r.waitForIdle(2000);
+ String scale = System.getProperty(SCALE);
+ System.out.println("scale = " + scale);
+ Color
+ expected = is2x() ? C2X : C1X,
+ unexpected = is2x() ? C1X : C2X;
+
+ Point p = lbl.getLocationOnScreen();
+ int x = p.x + lbl.getWidth() / 2;
+ int y = p.y + lbl.getHeight() / 2;
+ int w = lbl.getWidth();
+
+ boolean ok = true, curr;
+ Color c;
+ String components[] = new String[]{
+ "JLabel", "JCheckBox", "JRadioButton", "JToggleButton", "JButton"};
+ for (int i = 0; i < N; i++) {
+
+ curr = true;
+ int t = x - i * w;
+
+ // check icon color
+ c = r.getPixelColor(t, y);
+ System.out.print(components[i] + " icon: ");
+ if (!c.equals(expected)) {
+ curr = false;
+ } else {
+ // check icon color when mouse button pressed - see JDK-8151303
+ curr = checkPressedColor(t, y, expected);
+ }
+
+ System.out.println(curr ? "ok" : "nok");
+ ok = ok && curr;
+
+ r.waitForIdle();
+ }
+
+ int x0 = tabbedPane.getLocationOnScreen().x;
+ int x1 = x - ((N - 1) * w + w / 2);
+ int y0 = getLocationOnScreen().y;
+ int y1 = y0 + getHeight();
+ curr = checkTabIcon(x0, x1, y0, y1, expected, unexpected);
+
+ System.out.println("JTabbedPane icon: " + (curr ? "ok" : "nok"));
+ ok = ok && curr;
+
+ if (!ok) { throw new RuntimeException("test failed"); }
+
+ r.waitForIdle();
+ dispose();
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ // TODO: remove is2x() check after JDK-8150844 fix
+ if (is2x() != "2".equals(System.getProperty(SCALE))) { return; }
+
+ for (UIManager.LookAndFeelInfo LF: UIManager.getInstalledLookAndFeels()) {
+ System.out.println("\nL&F: " + LF.getName());
+ (new MultiresolutionIconTest(LF)).doTest();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/image/multiresolution/MultiresolutionSourceTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2016, 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 8151269
+ * @author a.stepanov
+ * @summary Multiresolution image: check that the base resolution variant
+ * source is passed to the corresponding ImageConsumer
+ * @run main MultiresolutionSourceTest
+ */
+
+import java.awt.*;
+import java.awt.image.*;
+
+public class MultiresolutionSourceTest {
+
+ private static class Checker implements ImageConsumer {
+
+ private final int refW, refH, refType;
+ private final boolean refHasAlpha;
+ private final Color refColor;
+
+ public Checker(int w,
+ int h,
+ Color c,
+ boolean hasAlpha,
+ int transferType) {
+ refW = w;
+ refH = h;
+ refColor = c;
+ refHasAlpha = hasAlpha;
+ refType = transferType;
+ }
+
+ @Override
+ public void imageComplete(int status) {}
+
+ @Override
+ public void setColorModel(ColorModel model) {
+
+ boolean a = model.hasAlpha();
+ if (a != refHasAlpha) {
+ throw new RuntimeException("invalid hasAlpha: " + a);
+ }
+
+ int tt = model.getTransferType();
+ if (tt != refType) {
+ throw new RuntimeException("invalid transfer type: " + tt);
+ }
+ }
+
+ @Override
+ public void setDimensions(int w, int h) {
+
+ if (w != refW) { throw new RuntimeException("invalid width: " + w +
+ ", expected: " + refW); }
+
+ if (h != refH) { throw new RuntimeException("invalid height: " + h +
+ ", expected: " + refH); }
+ }
+
+ @Override
+ public void setHints(int flags) {}
+
+ @Override
+ public void setPixels(int x, int y, int w, int h, ColorModel model,
+ byte pixels[], int offset, int scansize) {
+
+ for (int i = 0; i < pixels.length; i++) {
+ int p = pixels[i];
+ // just in case...
+ Color c = model.hasAlpha() ?
+ new Color(model.getRed (p),
+ model.getGreen(p),
+ model.getBlue (p),
+ model.getAlpha(p)) :
+ new Color(model.getRGB(p));
+
+ if (!c.equals(refColor)) {
+ throw new RuntimeException("invalid color: " + c +
+ ", expected: " + refColor);
+ }
+ }
+ }
+
+ @Override
+ public void setPixels(int x, int y, int w, int h, ColorModel model,
+ int pixels[], int offset, int scansize) {
+
+ for (int i = 0; i < pixels.length; i++) {
+ int p = pixels[i];
+ Color c = model.hasAlpha() ?
+ new Color(model.getRed (p),
+ model.getGreen(p),
+ model.getBlue (p),
+ model.getAlpha(p)) :
+ new Color(model.getRGB(p));
+
+ if (!c.equals(refColor)) {
+ throw new RuntimeException("invalid color: " + c +
+ ", expected: " + refColor);
+ }
+ }
+ }
+
+ @Override
+ public void setProperties(java.util.Hashtable props) {}
+ }
+
+ private static BufferedImage generateImage(int w, int h, Color c, int type) {
+
+ BufferedImage img = new BufferedImage(w, h, type);
+ Graphics g = img.getGraphics();
+ g.setColor(c);
+ g.fillRect(0, 0, w, h);
+ return img;
+ }
+
+ public static void main(String[] args) {
+
+ final int w1 = 20, w2 = 100, h1 = 30, h2 = 50;
+ final Color
+ c1 = new Color(255, 0, 0, 100), c2 = Color.BLACK, gray = Color.GRAY;
+
+ BufferedImage img1 =
+ generateImage(w1, h1, c1, BufferedImage.TYPE_INT_ARGB);
+
+ BufferedImage dummy =
+ generateImage(w1 + 5, h1 + 5, gray, BufferedImage.TYPE_BYTE_GRAY);
+
+ BufferedImage img2 =
+ generateImage(w2, h2, c2, BufferedImage.TYPE_BYTE_BINARY);
+
+ BufferedImage vars[] = new BufferedImage[] {img1, dummy, img2};
+
+ // default base image index (zero)
+ BaseMultiResolutionImage mri1 = new BaseMultiResolutionImage(vars);
+ // base image index = 2
+ BaseMultiResolutionImage mri2 = new BaseMultiResolutionImage(2, vars);
+
+ // do checks
+ mri1.getSource().startProduction(
+ new Checker(w1, h1, c1, true, DataBuffer.TYPE_INT));
+
+ mri2.getSource().startProduction(
+ new Checker(w2, h2, c2, false, DataBuffer.TYPE_BYTE));
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/keyboard/AllKeyCode/AllKeyCode.java Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,227 @@
+/*
+ * Copyright (c) 2016, 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 8149456 8147834 8150230
+ @requires os.family == "mac"
+ @summary KeyEvents for all keys
+ @run main AllKeyCode
+*/
+
+import java.awt.AWTException;
+import java.awt.GridBagLayout;
+import java.awt.Robot;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.Frame;
+import java.awt.TextArea;
+
+public class AllKeyCode extends Frame {
+
+ private static Frame frame;
+ private static TextArea textArea;
+ private static KeyListener keyListener;
+ private static int allKeyArr[];
+ private static int keyPressedIndex;
+
+ AllKeyCode() {
+ AllKeyCode.allKeyArr = new int[] {
+ KeyEvent.VK_BACK_SPACE,
+ KeyEvent.VK_TAB,
+ KeyEvent.VK_ENTER,
+ KeyEvent.VK_CLEAR,
+ KeyEvent.VK_SHIFT,
+ KeyEvent.VK_CONTROL,
+ KeyEvent.VK_ALT,
+ KeyEvent.VK_CAPS_LOCK,
+ KeyEvent.VK_ESCAPE,
+ KeyEvent.VK_SPACE,
+ KeyEvent.VK_PAGE_UP,
+ KeyEvent.VK_PAGE_DOWN,
+ KeyEvent.VK_END,
+ KeyEvent.VK_HOME,
+ KeyEvent.VK_LEFT,
+ KeyEvent.VK_UP,
+ KeyEvent.VK_RIGHT,
+ KeyEvent.VK_DOWN,
+ KeyEvent.VK_COMMA,
+ KeyEvent.VK_MINUS,
+ KeyEvent.VK_PERIOD,
+ KeyEvent.VK_SLASH,
+ KeyEvent.VK_0,
+ KeyEvent.VK_1,
+ KeyEvent.VK_2,
+ KeyEvent.VK_3,
+ KeyEvent.VK_4,
+ KeyEvent.VK_5,
+ KeyEvent.VK_6,
+ KeyEvent.VK_7,
+ KeyEvent.VK_8,
+ KeyEvent.VK_9,
+ KeyEvent.VK_SEMICOLON,
+ KeyEvent.VK_EQUALS,
+ KeyEvent.VK_A,
+ KeyEvent.VK_B,
+ KeyEvent.VK_C,
+ KeyEvent.VK_D,
+ KeyEvent.VK_E,
+ KeyEvent.VK_F,
+ KeyEvent.VK_G,
+ KeyEvent.VK_H,
+ KeyEvent.VK_I,
+ KeyEvent.VK_J,
+ KeyEvent.VK_K,
+ KeyEvent.VK_L,
+ KeyEvent.VK_M,
+ KeyEvent.VK_N,
+ KeyEvent.VK_O,
+ KeyEvent.VK_P,
+ KeyEvent.VK_Q,
+ KeyEvent.VK_R,
+ KeyEvent.VK_S,
+ KeyEvent.VK_T,
+ KeyEvent.VK_U,
+ KeyEvent.VK_V,
+ KeyEvent.VK_W,
+ KeyEvent.VK_X,
+ KeyEvent.VK_Y,
+ KeyEvent.VK_Z,
+ KeyEvent.VK_OPEN_BRACKET,
+ KeyEvent.VK_BACK_SLASH,
+ KeyEvent.VK_CLOSE_BRACKET,
+ KeyEvent.VK_NUMPAD0,
+ KeyEvent.VK_NUMPAD1,
+ KeyEvent.VK_NUMPAD2,
+ KeyEvent.VK_NUMPAD3,
+ KeyEvent.VK_NUMPAD4,
+ KeyEvent.VK_NUMPAD5,
+ KeyEvent.VK_NUMPAD6,
+ KeyEvent.VK_NUMPAD7,
+ KeyEvent.VK_NUMPAD8,
+ KeyEvent.VK_NUMPAD9,
+ KeyEvent.VK_MULTIPLY,
+ KeyEvent.VK_ADD,
+ KeyEvent.VK_SUBTRACT,
+ KeyEvent.VK_DECIMAL,
+ KeyEvent.VK_DIVIDE,
+ KeyEvent.VK_F1,
+ KeyEvent.VK_F2,
+ KeyEvent.VK_F3,
+ KeyEvent.VK_F4,
+ KeyEvent.VK_F5,
+ KeyEvent.VK_F6,
+ KeyEvent.VK_F7,
+ KeyEvent.VK_F8,
+ KeyEvent.VK_F9,
+ KeyEvent.VK_F10,
+ KeyEvent.VK_F11,
+ KeyEvent.VK_F12,
+ KeyEvent.VK_DELETE,
+ KeyEvent.VK_HELP,
+ KeyEvent.VK_META,
+ KeyEvent.VK_BACK_QUOTE,
+ KeyEvent.VK_QUOTE,
+ KeyEvent.VK_F13,
+ KeyEvent.VK_F14,
+ KeyEvent.VK_F15,
+ KeyEvent.VK_F16,
+ KeyEvent.VK_F17,
+ KeyEvent.VK_F18,
+ KeyEvent.VK_F19,
+ KeyEvent.VK_F20
+ };
+
+ keyPressedIndex = -1;
+ }
+
+ private void createAndShowGUI() {
+ frame = new Frame("Function Key Keycodes");
+ textArea = new TextArea();
+ textArea.setFocusable(true);
+ frame.add(textArea);
+ frame.pack();
+ frame.setSize(200, 200);
+
+ textArea.addKeyListener(keyListener = new KeyListener() {
+
+ @Override
+ public void keyTyped(KeyEvent ke) {
+ }
+
+ @Override
+ public void keyPressed(KeyEvent ke) {
+ if (allKeyArr[keyPressedIndex] != ke.getKeyCode()) {
+ throw new RuntimeException("Wrong keycode received");
+ }
+ }
+
+ @Override
+ public void keyReleased(KeyEvent ke) {
+ }
+ });
+ frame.setVisible(true);
+ }
+
+ private void removeListener() {
+ if (keyListener != null) {
+ textArea.removeKeyListener(keyListener);
+ keyListener = null;
+ }
+ }
+
+ @Override
+ public void dispose() {
+ if (null != frame) {
+ frame.dispose();
+ frame = null;
+ }
+ }
+
+ public void generateFunctionKeyPress() {
+ try {
+ Robot robot = new Robot();
+ robot.waitForIdle();
+
+ for (int i = 0; i < allKeyArr.length; i++) {
+ keyPressedIndex = i;
+ robot.keyPress(allKeyArr[i]);
+ robot.keyRelease(allKeyArr[i]);
+ robot.waitForIdle();
+ }
+ removeListener();
+
+ } catch (AWTException e) {
+ throw new RuntimeException("Robot creation failed");
+ }
+ }
+
+ public static void main(String args[]) {
+ AllKeyCode allKeyObj = new AllKeyCode();
+ allKeyObj.createAndShowGUI();
+ allKeyObj.generateFunctionKeyPress();
+ allKeyObj.dispose();
+
+ System.out.println("Test Passed");
+ }
+}
--- a/jdk/test/java/awt/print/PrinterJob/MultiMonPrintDlgTest.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/test/java/awt/print/PrinterJob/MultiMonPrintDlgTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -43,16 +43,18 @@
*/
public class MultiMonPrintDlgTest implements ActionListener {
- Frame primaryFrame = null;
- Frame secFrame = null;
- GraphicsDevice gd[] = GraphicsEnvironment.getLocalGraphicsEnvironment().
+ private static boolean testPassed;
+ private static Thread mainThread;
+ private static boolean testGeneratedInterrupt;
+ private static int sleepTime = 30000;
+ private static String message = "User has not executed the test";
+
+ static Frame primaryFrame = null;
+ static Frame secFrame = null;
+ static GraphicsDevice gd[] = GraphicsEnvironment.getLocalGraphicsEnvironment().
getScreenDevices();
- public MultiMonPrintDlgTest() throws Exception {
- if (gd.length <= 1) {
- System.out.println("This test should be run only on dual-monitor systems. Aborted!!");
- return;
- }
+ private static void init() throws Exception {
String[] instructions =
{
@@ -70,6 +72,10 @@
instructions,
"information", JOptionPane.INFORMATION_MESSAGE);
});
+ }
+
+ private void executeTest() {
+
GraphicsDevice defDev = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
int x = 0;
Frame f = null;
@@ -95,31 +101,67 @@
}
public void actionPerformed (ActionEvent ae) {
- try {
- javax.print.attribute.PrintRequestAttributeSet prSet =
- new javax.print.attribute.HashPrintRequestAttributeSet();
- java.awt.print.PrinterJob.getPrinterJob().pageDialog(prSet);
- Window w = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
- int dialogButton = JOptionPane.showConfirmDialog (w,
- "Did the pageDialog shown in non-default monitor?",
- null, JOptionPane.YES_NO_OPTION);
- if(dialogButton == JOptionPane.NO_OPTION) {
- throw new RuntimeException("PageDialog is shown in wrong monitor");
- }
+ javax.print.attribute.PrintRequestAttributeSet prSet =
+ new javax.print.attribute.HashPrintRequestAttributeSet();
+ java.awt.print.PrinterJob.getPrinterJob().pageDialog(prSet);
+ Window w = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
+ int dialogButton = JOptionPane.showConfirmDialog (w,
+ "Did the pageDialog shown in non-default monitor?",
+ null, JOptionPane.YES_NO_OPTION);
+ if(dialogButton == JOptionPane.NO_OPTION) {
+ fail("PageDialog is shown in wrong monitor");
+ } else {
java.awt.print.PrinterJob.getPrinterJob().printDialog(prSet);
dialogButton = JOptionPane.showConfirmDialog (w,
- "Did the printDialog shown in non-default monitor?",
- null, JOptionPane.YES_NO_OPTION);
+ "Did the printDialog shown in non-default monitor?",
+ null, JOptionPane.YES_NO_OPTION);
if(dialogButton == JOptionPane.NO_OPTION) {
- throw new RuntimeException("PrintDialog is shown in wrong monitor");
+ fail("PrintDialog is shown in wrong monitor");
+ } else {
+ pass();
}
- } finally {
- primaryFrame.dispose();
- secFrame.dispose();
}
}
+ private static void dispose() {
+ primaryFrame.dispose();
+ secFrame.dispose();
+ }
+
+ public static synchronized void pass() {
+ testPassed = true;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }
+
+ public static synchronized void fail(String msg) {
+ testPassed = false;
+ message = msg;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }
+
public static void main (String args[]) throws Exception {
+ if (gd.length <= 1) {
+ System.out.println("This test should be run only on dual-monitor systems. Aborted!!");
+ return;
+ }
+ init();
MultiMonPrintDlgTest test = new MultiMonPrintDlgTest();
+ test.executeTest();
+ mainThread = Thread.currentThread();
+
+ try {
+ mainThread.sleep(sleepTime);
+ } catch (InterruptedException ex) {
+ dispose();
+ if (!testPassed && testGeneratedInterrupt) {
+ throw new RuntimeException(message);
+ }
+ }
+ if (!testGeneratedInterrupt) {
+ dispose();
+ throw new RuntimeException(message);
+ }
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JDesktopPane/DesktopPaneBackgroundTest.java Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2016, 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 7012008
+* @summary Verify JDesktopPane Background Color for WLAF
+* @requires (os.family == "windows")
+* @run main DesktopPaneBackgroundTest
+ */
+import java.awt.Color;
+import java.awt.Toolkit;
+import javax.swing.JDesktopPane;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+
+public class DesktopPaneBackgroundTest {
+
+ private static Color defaultBackgroudColor;
+
+ public static void main(String[] args) throws Exception {
+ defaultBackgroudColor = (Color) Toolkit.getDefaultToolkit()
+ .getDesktopProperty("win.mdi.backgroundColor");
+
+ String[] lookAndFeel = new String[]{
+ "com.sun.java.swing.plaf.windows.WindowsLookAndFeel",
+ "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel"};
+
+ for (String laf : lookAndFeel) {
+ UIManager.setLookAndFeel(laf);
+
+ SwingUtilities.invokeAndWait(() -> {
+ JDesktopPane desktopPane = new JDesktopPane();
+
+ Color background = desktopPane.getBackground();
+ if (!background.equals(defaultBackgroudColor)) {
+ throw new RuntimeException("Invalid JDesktopPane "
+ + "Background Color for WLAF");
+ }
+ });
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JInternalFrame/8069348/bug8069348.java Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2015, 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.BorderLayout;
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import javax.swing.JDesktopPane;
+import javax.swing.JFrame;
+import javax.swing.JInternalFrame;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+import static sun.awt.OSInfo.*;
+
+/**
+ * @test
+ * @bug 8069348
+ * @summary SunGraphics2D.copyArea() does not properly work for scaled graphics
+ * @author Alexandr Scherbatiy
+ * @modules java.desktop/sun.awt
+ * @run main/othervm -Dsun.java2d.uiScale=2 bug8069348
+ * @run main/othervm -Dsun.java2d.opengl=true -Dsun.java2d.uiScale=2 bug8069348
+ * @run main/othervm -Dsun.java2d.d3d=true -Dsun.java2d.uiScale=2 bug8069348
+ */
+public class bug8069348 {
+
+ private static final int WIN_WIDTH = 500;
+ private static final int WIN_HEIGHT = 500;
+
+ private static final Color DESKTOPPANE_COLOR = Color.YELLOW;
+ private static final Color FRAME_COLOR = Color.ORANGE;
+
+ private static JFrame frame;
+ private static JInternalFrame internalFrame;
+
+ public static void main(String[] args) throws Exception {
+
+ if (!isSupported()) {
+ return;
+ }
+
+ try {
+
+ SwingUtilities.invokeAndWait(bug8069348::createAndShowGUI);
+
+ Robot robot = new Robot();
+ robot.setAutoDelay(50);
+ robot.waitForIdle();
+
+ Rectangle screenBounds = getInternalFrameScreenBounds();
+
+ int x = screenBounds.x + screenBounds.width / 2;
+ int y = screenBounds.y + 10;
+ int dx = screenBounds.width / 2;
+ int dy = screenBounds.height / 2;
+
+ robot.mouseMove(x, y);
+ robot.waitForIdle();
+
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseMove(x + dx, y + dy);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+
+ int cx = screenBounds.x + screenBounds.width + dx / 2;
+ int cy = screenBounds.y + screenBounds.height + dy / 2;
+
+ robot.mouseMove(cx, cy);
+ if (!FRAME_COLOR.equals(robot.getPixelColor(cx, cy))) {
+ throw new RuntimeException("Internal frame is not correctly dragged!");
+ }
+ } finally {
+ if (frame != null) {
+ frame.dispose();
+ }
+ }
+ }
+
+ private static boolean isSupported() {
+ String d3d = System.getProperty("sun.java2d.d3d");
+ return !Boolean.getBoolean(d3d) || getOSType() == OSType.WINDOWS;
+ }
+
+ private static Rectangle getInternalFrameScreenBounds() throws Exception {
+ Rectangle[] points = new Rectangle[1];
+ SwingUtilities.invokeAndWait(() -> {
+ points[0] = new Rectangle(internalFrame.getLocationOnScreen(),
+ internalFrame.getSize());
+ });
+ return points[0];
+ }
+
+ private static void createAndShowGUI() {
+
+ frame = new JFrame();
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ JDesktopPane desktopPane = new JDesktopPane();
+ desktopPane.setBackground(DESKTOPPANE_COLOR);
+
+ internalFrame = new JInternalFrame("Test") {
+
+ @Override
+ public void paint(Graphics g) {
+ super.paint(g);
+ g.setColor(FRAME_COLOR);
+ g.fillRect(0, 0, getWidth(), getHeight());
+ }
+ };
+ internalFrame.setSize(WIN_WIDTH / 3, WIN_HEIGHT / 3);
+ internalFrame.setVisible(true);
+ desktopPane.add(internalFrame);
+
+ JPanel panel = new JPanel();
+ panel.setLayout(new BorderLayout());
+ panel.add(desktopPane, BorderLayout.CENTER);
+ frame.add(panel);
+ frame.setSize(WIN_WIDTH, WIN_HEIGHT);
+ frame.setVisible(true);
+ frame.requestFocus();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JInternalFrame/8145896/TestJInternalFrameMaximize.java Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2016, 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 8145896
+ * @summary JInternalFrame setMaximum before adding to desktop throws null pointer exception
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main TestJInternalFrameMaximize
+ */
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.ActionEvent;
+import java.awt.event.InputEvent;
+import java.beans.PropertyVetoException;
+import javax.swing.JFrame;
+import javax.swing.JDesktopPane;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JInternalFrame;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+
+public class TestJInternalFrameMaximize {
+
+ private static JDesktopPane desktopPane;
+ private static JFrame frame;
+ private static int count = 0;
+ private static JMenu menu;
+ private static JMenuBar menuBar;
+ private static JMenuItem menuItem;
+ private static Robot robot;
+ private static volatile String errorMessage = "";
+
+ public static void main(String[] args) throws Exception {
+ robot = new Robot();
+ UIManager.LookAndFeelInfo[] lookAndFeelArray
+ = UIManager.getInstalledLookAndFeels();
+ for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) {
+ String lookAndFeelString = lookAndFeelItem.getClassName();
+ if (tryLookAndFeel(lookAndFeelString)) {
+ createUI();
+ robot.waitForIdle();
+ executeTest();
+ }
+ }
+ if (!"".equals(errorMessage)) {
+ throw new RuntimeException(errorMessage);
+ }
+ }
+
+ private static boolean tryLookAndFeel(String lookAndFeelString) {
+ try {
+ UIManager.setLookAndFeel(lookAndFeelString);
+ return true;
+ } catch (UnsupportedLookAndFeelException | ClassNotFoundException |
+ InstantiationException | IllegalAccessException e) {
+ errorMessage += e.getMessage() + "\n";
+ System.err.println("Caught Exception: " + e.getMessage());
+ return false;
+ }
+ }
+
+ private static void createUI() throws Exception {
+
+ SwingUtilities.invokeAndWait(() -> {
+ frame = new JFrame("Test Frame");
+ desktopPane = new JDesktopPane();
+ frame.getContentPane().add(desktopPane);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ menuBar = new JMenuBar();
+ frame.setJMenuBar(menuBar);
+
+ menu = new JMenu("File");
+ menuBar.add(menu);
+
+ menuItem = new JMenuItem("New Child");
+ menuItem.addActionListener((ActionEvent e) -> {
+ try {
+ JInternalFrame f = new JInternalFrame("Child "
+ + (++count), true, true, true, true);
+ f.setSize(200, 300);
+ f.setLocation(count * 20, count * 20);
+ f.setMaximum(true);
+ desktopPane.add(f);
+ f.setVisible(true);
+ } catch (PropertyVetoException ex) {
+ } catch (RuntimeException ex) {
+ errorMessage = "Test Failed";
+ } finally {
+ frame.dispose();
+ }
+ });
+ menu.add(menuItem);
+ frame.setSize(500, 500);
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ });
+ }
+
+ private static void executeTest() throws Exception {
+
+ Point point = Util.getCenterPoint(menu);
+ performMouseOperations(point);
+ point = Util.getCenterPoint(menuItem);
+ performMouseOperations(point);
+ }
+
+ private static void performMouseOperations(Point point) {
+ robot.mouseMove(point.x, point.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.delay(1000);
+ robot.waitForIdle();
+ }
+}
--- a/jdk/test/javax/swing/JPopupMenu/6544309/bug6544309.java Mon Mar 21 08:48:34 2016 -0700
+++ b/jdk/test/javax/swing/JPopupMenu/6544309/bug6544309.java Mon Mar 21 09:36:54 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, 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
@@ -30,9 +30,14 @@
@run main bug6544309
*/
-import javax.swing.*;
-import java.awt.event.*;
-import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+
+import javax.swing.JDialog;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import javax.swing.SwingUtilities;
public class bug6544309 {
private JDialog dialog;
@@ -41,6 +46,8 @@
public static void main(String[] args) throws Exception {
robot = new ExtendedRobot();
+ // move mouse outside menu to prevent auto selection
+ robot.mouseMove(100,100);
final bug6544309 test = new bug6544309();
try {
SwingUtilities.invokeAndWait(new Runnable() {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTextArea/8149849/DNDTextToScaledArea.java Mon Mar 21 09:36:54 2016 -0700
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2016, 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.BorderLayout;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+
+/**
+ * @test
+ * @bug 8149849
+ * @summary [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or
+ * other text component) when scale > 1
+ * @run main/othervm -Dsun.java2d.uiScale=2 DNDTextToScaledArea
+ */
+public class DNDTextToScaledArea {
+
+ private static final String TEXT = "ABCDEFGH";
+ private static JFrame frame;
+ private static JTextArea srcTextArea;
+ private static JTextArea dstTextArea;
+ private static volatile Point srcPoint;
+ private static volatile Point dstPoint;
+ private static volatile boolean passed = false;
+
+ public static void main(String[] args) throws Exception {
+ Robot robot = new Robot();
+ robot.setAutoDelay(50);
+
+ SwingUtilities.invokeAndWait(DNDTextToScaledArea::createAndShowGUI);
+ robot.waitForIdle();
+
+ SwingUtilities.invokeAndWait(() -> {
+ srcPoint = getPoint(srcTextArea, 0.1);
+ dstPoint = getPoint(dstTextArea, 0.75);
+ });
+ robot.waitForIdle();
+
+ dragAndDrop(robot, srcPoint, dstPoint);
+ robot.waitForIdle();
+
+ SwingUtilities.invokeAndWait(() -> {
+ passed = TEXT.equals(dstTextArea.getText());
+ frame.dispose();
+ });
+ robot.waitForIdle();
+
+ if (!passed) {
+ throw new RuntimeException("Text Drag and Drop failed!");
+ }
+ }
+
+ private static void createAndShowGUI() {
+
+ frame = new JFrame();
+ frame.setSize(300, 300);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ JPanel panel = new JPanel(new BorderLayout());
+
+ srcTextArea = new JTextArea(TEXT);
+ srcTextArea.setDragEnabled(true);
+ srcTextArea.selectAll();
+ dstTextArea = new JTextArea();
+
+ panel.add(dstTextArea, BorderLayout.CENTER);
+ panel.add(srcTextArea, BorderLayout.SOUTH);
+
+ frame.getContentPane().add(panel);
+ frame.setVisible(true);
+ }
+
+ private static Point getPoint(Component component, double scale) {
+ Point point = component.getLocationOnScreen();
+ Dimension bounds = component.getSize();
+ point.translate((int) (bounds.width * scale), (int) (bounds.height * scale));
+ return point;
+ }
+
+ public static void dragAndDrop(Robot robot, Point src, Point dst) throws Exception {
+
+ int x1 = src.x;
+ int y1 = src.y;
+ int x2 = dst.x;
+ int y2 = dst.y;
+ robot.mouseMove(x1, y1);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+
+ float dmax = (float) Math.max(Math.abs(x2 - x1), Math.abs(y2 - y1));
+ float dx = (x2 - x1) / dmax;
+ float dy = (y2 - y1) / dmax;
+
+ for (int i = 0; i <= dmax; i += 5) {
+ robot.mouseMove((int) (x1 + dx * i), (int) (y1 + dy * i));
+ }
+
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ }
+}