Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
f5fe9e18
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f5fe9e18
编写于
2月 08, 2017
作者:
A
asaha
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
2c37c8d8
861dcf05
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
1265 addition
and
79 deletion
+1265
-79
.hgtags
.hgtags
+4
-0
src/macosx/native/sun/awt/AWTWindow.m
src/macosx/native/sun/awt/AWTWindow.m
+2
-2
src/share/classes/com/sun/jndi/ldap/pool/Connections.java
src/share/classes/com/sun/jndi/ldap/pool/Connections.java
+19
-15
src/share/classes/com/sun/jndi/ldap/pool/Pool.java
src/share/classes/com/sun/jndi/ldap/pool/Pool.java
+17
-9
src/share/classes/javax/swing/plaf/basic/BasicLabelUI.java
src/share/classes/javax/swing/plaf/basic/BasicLabelUI.java
+133
-25
src/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java
...share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java
+13
-2
src/windows/native/sun/windows/awt_FileDialog.cpp
src/windows/native/sun/windows/awt_FileDialog.cpp
+8
-23
src/windows/native/sun/windows/awt_FileDialog.h
src/windows/native/sun/windows/awt_FileDialog.h
+0
-3
test/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java
...ava/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java
+81
-0
test/java/awt/FileDialog/DeleteInsideFileDialog/DeleteInsideFileDialogTest.java
...og/DeleteInsideFileDialog/DeleteInsideFileDialogTest.java
+81
-0
test/java/awt/Frame/NormalToIconified/NormalToIconifiedTest.java
...va/awt/Frame/NormalToIconified/NormalToIconifiedTest.java
+105
-0
test/java/awt/Frame/ObscuredFrame/ObscuredFrameTest.java
test/java/awt/Frame/ObscuredFrame/ObscuredFrameTest.java
+71
-0
test/java/awt/MouseInfo/GetPointerInfoTest.java
test/java/awt/MouseInfo/GetPointerInfoTest.java
+73
-0
test/java/awt/MouseInfo/MultiscreenPointerInfo.java
test/java/awt/MouseInfo/MultiscreenPointerInfo.java
+90
-0
test/javax/swing/JMenuItem/8152981/MenuItemIconTest.java
test/javax/swing/JMenuItem/8152981/MenuItemIconTest.java
+114
-0
test/javax/swing/plaf/basic/BasicLabelUI/bug7172652.java
test/javax/swing/plaf/basic/BasicLabelUI/bug7172652.java
+172
-0
test/javax/xml/ws/8159058/SaajEmptyNamespaceTest.java
test/javax/xml/ws/8159058/SaajEmptyNamespaceTest.java
+282
-0
未找到文件。
.hgtags
浏览文件 @
f5fe9e18
...
...
@@ -664,6 +664,8 @@ d2d8b67021a0f41e0eabd711bfd87a943dc0a8d5 jdk8u112-b14
60767ec3909b3d0cb26dd7b3f952c62053719dda jdk8u112-b15
5dd7e4bae5c2f1ee4f80c5570e7e3e2f715f7a32 jdk8u112-b16
41fac11792c1ee6945f56721ee558a7424395a81 jdk8u112-b31
548a51660ee94aeb77b2432594aeb87f87c21697 jdk8u112-b32
a334b0815d34948188537a177a32cee27007ea2c jdk8u112-b33
ab5ff8f1e52c5e3ca02e988f4d978af63ceca5b8 jdk8u121-b00
5f0839ac7e0d25dd1ae705df496b12ca76c26d59 jdk8u121-b01
f91e3aa155b3c6774afb456db15fb358313d5771 jdk8u121-b02
...
...
@@ -678,6 +680,8 @@ d66de7e2f672a1ff6947846818412fa899456972 jdk8u121-b10
ec72a941be0a50ab77f5375cf710bc06e4f118d3 jdk8u121-b11
9561afc12df843ef21ecd9d7b3633371e7a2bfc4 jdk8u121-b12
2974746e56192cdd14fc2dd43179bcf28e4faf4a jdk8u121-b13
4f69f3363a2ecee8d3df2b046266a76c2a805139 jdk8u121-b31
ec26e3331158912f86268ef473e64514c70cbd52 jdk8u121-b32
032874d46bf95478cb86690b3c91d335c0764b0b jdk8u131-b00
bea5b22daf5ddd941f3bcbf7a4e5fc5244ceb788 jdk8u131-b01
a01d217a232906e82f80e5bc3db4d60c4c74716e jdk8u131-b02
...
...
src/macosx/native/sun/awt/AWTWindow.m
浏览文件 @
f5fe9e18
...
...
@@ -330,7 +330,7 @@ AWT_ASSERT_APPKIT_THREAD;
+
(
NSArray
*
)
getWindowLayers
{
static
NSArray
*
windowLayers
;
static
dispatch_once_t
token
;
// Initialize the list of possible window layers
dispatch_once
(
&
token
,
^
{
// The layers are ordered from front to back, (i.e. the toppest one is the first)
...
...
@@ -362,7 +362,7 @@ AWT_ASSERT_APPKIT_THREAD;
}
+
(
NSInteger
)
getTopmostWindowUnderMouseIDImpl
:(
NSInteger
)
windowLayer
{
NSInteger
result
=
-
1
;
NSInteger
result
=
-
1
;
NSRect
screenRect
=
[[
NSScreen
mainScreen
]
frame
];
NSPoint
nsMouseLocation
=
[
NSEvent
mouseLocation
];
...
...
src/share/classes/com/sun/jndi/ldap/pool/Connections.java
浏览文件 @
f5fe9e18
...
...
@@ -27,7 +27,6 @@ package com.sun.jndi.ldap.pool;
import
java.util.ArrayList
;
// JDK 1.2
import
java.util.List
;
import
java.util.Iterator
;
import
java.lang.ref.Reference
;
import
java.lang.ref.SoftReference
;
...
...
@@ -290,23 +289,28 @@ final class Connections implements PoolCallback {
* @param threshold an entry idle since this time has expired.
* @return true if no more connections in list
*/
synchronized
boolean
expire
(
long
threshold
)
{
Iterator
<
ConnectionDesc
>
iter
=
conns
.
iterator
();
ConnectionDesc
entry
;
while
(
iter
.
hasNext
())
{
entry
=
iter
.
next
();
if
(
entry
.
expire
(
threshold
))
{
d
(
"expire(): removing "
,
entry
);
td
(
"Expired "
,
entry
);
iter
.
remove
();
// remove from pool
boolean
expire
(
long
threshold
)
{
List
<
ConnectionDesc
>
clonedConns
;
synchronized
(
this
)
{
clonedConns
=
new
ArrayList
<>(
conns
);
}
List
<
ConnectionDesc
>
expired
=
new
ArrayList
<>();
// Don't need to call notify() because we're
// removing only idle connections. If there were
// idle connections, then there should be no waiters.
for
(
ConnectionDesc
entry
:
clonedConns
)
{
d
(
"expire(): "
,
entry
);
if
(
entry
.
expire
(
threshold
))
{
expired
.
add
(
entry
);
td
(
"expire(): Expired "
,
entry
);
}
}
return
conns
.
isEmpty
();
// whether whole list has 'expired'
synchronized
(
this
)
{
conns
.
removeAll
(
expired
);
// Don't need to call notify() because we're
// removing only idle connections. If there were
// idle connections, then there should be no waiters.
return
conns
.
isEmpty
();
// whether whole list has 'expired'
}
}
/**
...
...
src/share/classes/com/sun/jndi/ldap/pool/Pool.java
浏览文件 @
f5fe9e18
...
...
@@ -25,11 +25,11 @@
package
com.sun.jndi.ldap.pool
;
import
java.util.ArrayList
;
import
java.util.Map
;
import
java.util.WeakHashMap
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.LinkedList
;
import
java.io.PrintStream
;
...
...
@@ -166,17 +166,25 @@ final public class Pool {
* and removed.
*/
public
void
expire
(
long
threshold
)
{
Collection
<
ConnectionsRef
>
copy
;
synchronized
(
map
)
{
Iterator
<
ConnectionsRef
>
iter
=
map
.
values
().
iterator
();
Connections
conns
;
while
(
iter
.
hasNext
())
{
conns
=
iter
.
next
().
getConnections
();
if
(
conns
.
expire
(
threshold
))
{
d
(
"expire(): removing "
,
conns
);
iter
.
remove
();
}
copy
=
new
ArrayList
<>(
map
.
values
());
}
ArrayList
<
ConnectionsRef
>
removed
=
new
ArrayList
<>();
Connections
conns
;
for
(
ConnectionsRef
ref
:
copy
)
{
conns
=
ref
.
getConnections
();
if
(
conns
.
expire
(
threshold
))
{
d
(
"expire(): removing "
,
conns
);
removed
.
add
(
ref
);
}
}
synchronized
(
map
)
{
map
.
values
().
removeAll
(
removed
);
}
expungeStaleConnections
();
}
...
...
src/share/classes/javax/swing/plaf/basic/BasicLabelUI.java
浏览文件 @
f5fe9e18
/*
* Copyright (c) 1997, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
5
, 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
...
...
@@ -80,6 +80,14 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
* This method is here so that a subclass could do Label specific
* layout and to shorten the method name a little.
*
* @param label an instance of {@code JLabel}
* @param fontMetrics a font metrics
* @param text a text
* @param icon an icon
* @param viewR a bounding rectangle to lay out label
* @param iconR a bounding rectangle to lay out icon
* @param textR a bounding rectangle to lay out text
* @return a possibly clipped version of the compound labels string
* @see SwingUtilities#layoutCompoundLabel
*/
protected
String
layoutCL
(
...
...
@@ -109,6 +117,11 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
/**
* Paint clippedText at textX, textY with the labels foreground color.
*
* @param l an instance of {@code JLabel}
* @param g an instance of {@code Graphics}
* @param s a text
* @param textX an X coordinate
* @param textY an Y coordinate
* @see #paint
* @see #paintDisabledText
*/
...
...
@@ -125,6 +138,11 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
* Paint clippedText at textX, textY with background.lighter() and then
* shifted down and to the right by one pixel with background.darker().
*
* @param l an instance of {@code JLabel}
* @param g an instance of {@code Graphics}
* @param s a text
* @param textX an X coordinate
* @param textY an Y coordinate
* @see #paint
* @see #paintEnabledText
*/
...
...
@@ -329,26 +347,46 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
public
void
uninstallUI
(
JComponent
c
)
{
uninstallDefaults
((
JLabel
)
c
);
uninstallComponents
((
JLabel
)
c
);
uninstallListeners
((
JLabel
)
c
);
uninstallKeyboardActions
((
JLabel
)
c
);
uninstallDefaults
((
JLabel
)
c
);
uninstallComponents
((
JLabel
)
c
);
uninstallListeners
((
JLabel
)
c
);
uninstallKeyboardActions
((
JLabel
)
c
);
}
protected
void
installDefaults
(
JLabel
c
){
LookAndFeel
.
installColorsAndFont
(
c
,
"Label.background"
,
"Label.foreground"
,
"Label.font"
);
LookAndFeel
.
installProperty
(
c
,
"opaque"
,
Boolean
.
FALSE
);
}
/**
* Installs default properties.
*
* @param c an instance of {@code JLabel}
*/
protected
void
installDefaults
(
JLabel
c
){
LookAndFeel
.
installColorsAndFont
(
c
,
"Label.background"
,
"Label.foreground"
,
"Label.font"
);
LookAndFeel
.
installProperty
(
c
,
"opaque"
,
Boolean
.
FALSE
);
}
/**
* Registers listeners.
*
* @param c an instance of {@code JLabel}
*/
protected
void
installListeners
(
JLabel
c
){
c
.
addPropertyChangeListener
(
this
);
}
/**
* Registers components.
*
* @param c an instance of {@code JLabel}
*/
protected
void
installComponents
(
JLabel
c
){
BasicHTML
.
updateRenderer
(
c
,
c
.
getText
());
c
.
setInheritsPopupMenu
(
true
);
}
/**
* Registers keyboard actions.
*
* @param l an instance of {@code JLabel}
*/
protected
void
installKeyboardActions
(
JLabel
l
)
{
int
dka
=
l
.
getDisplayedMnemonic
();
Component
lf
=
l
.
getLabelFor
();
...
...
@@ -374,17 +412,37 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
}
}
/**
* Uninstalls default properties.
*
* @param c an instance of {@code JLabel}
*/
protected
void
uninstallDefaults
(
JLabel
c
){
}
/**
* Unregisters listeners.
*
* @param c an instance of {@code JLabel}
*/
protected
void
uninstallListeners
(
JLabel
c
){
c
.
removePropertyChangeListener
(
this
);
}
/**
* Unregisters components.
*
* @param c an instance of {@code JLabel}
*/
protected
void
uninstallComponents
(
JLabel
c
){
BasicHTML
.
updateRenderer
(
c
,
""
);
}
/**
* Unregisters keyboard actions.
*
* @param c an instance of {@code JLabel}
*/
protected
void
uninstallKeyboardActions
(
JLabel
c
)
{
SwingUtilities
.
replaceUIInputMap
(
c
,
JComponent
.
WHEN_FOCUSED
,
null
);
SwingUtilities
.
replaceUIInputMap
(
c
,
JComponent
.
WHEN_IN_FOCUSED_WINDOW
,
...
...
@@ -392,6 +450,12 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
SwingUtilities
.
replaceUIActionMap
(
c
,
null
);
}
/**
* Returns an instance of {@code BasicLabelUI}.
*
* @param c a component
* @return an instance of {@code BasicLabelUI}
*/
public
static
ComponentUI
createUI
(
JComponent
c
)
{
if
(
System
.
getSecurityManager
()
!=
null
)
{
AppContext
appContext
=
AppContext
.
getAppContext
();
...
...
@@ -440,7 +504,7 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
doPress
(
label
);
}
else
if
(
key
==
RELEASE
)
{
doRelease
(
label
);
doRelease
(
label
,
e
.
getActionCommand
()
!=
null
);
}
}
...
...
@@ -453,33 +517,77 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
SwingUtilities
.
replaceUIInputMap
(
label
,
JComponent
.
WHEN_FOCUSED
,
inputMap
);
}
int
dka
=
label
.
getDisplayedMnemonic
();
inputMap
.
put
(
KeyStroke
.
getKeyStroke
(
dka
,
BasicLookAndFeel
.
getFocusAcceleratorKeyMask
(),
true
),
RELEASE
);
putOnRelease
(
inputMap
,
dka
,
BasicLookAndFeel
.
getFocusAcceleratorKeyMask
());
// Need this when the sticky keys are enabled
inputMap
.
put
(
KeyStroke
.
getKeyStroke
(
dka
,
0
,
true
),
RELEASE
);
putOnRelease
(
inputMap
,
dka
,
0
);
// Need this if ALT is released before the accelerator
inputMap
.
put
(
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_ALT
,
0
,
true
),
RELEASE
);
putOnRelease
(
inputMap
,
KeyEvent
.
VK_ALT
,
0
);
label
.
requestFocus
();
}
}
private
void
doRelease
(
JLabel
label
)
{
private
void
doRelease
(
JLabel
label
,
boolean
isCommand
)
{
Component
labelFor
=
label
.
getLabelFor
();
if
(
labelFor
!=
null
&&
labelFor
.
isEnabled
())
{
InputMap
inputMap
=
SwingUtilities
.
getUIInputMap
(
label
,
JComponent
.
WHEN_FOCUSED
);
if
(
inputMap
!=
null
)
{
// inputMap should never be null.
if
(
label
.
hasFocus
())
{
InputMap
inputMap
=
SwingUtilities
.
getUIInputMap
(
label
,
JComponent
.
WHEN_FOCUSED
);
if
(
inputMap
!=
null
)
{
// inputMap should never be null.
int
dka
=
label
.
getDisplayedMnemonic
();
removeOnRelease
(
inputMap
,
dka
,
BasicLookAndFeel
.
getFocusAcceleratorKeyMask
());
removeOnRelease
(
inputMap
,
dka
,
0
);
removeOnRelease
(
inputMap
,
KeyEvent
.
VK_ALT
,
0
);
}
inputMap
=
SwingUtilities
.
getUIInputMap
(
label
,
JComponent
.
WHEN_IN_FOCUSED_WINDOW
);
if
(
inputMap
==
null
)
{
inputMap
=
new
InputMapUIResource
();
SwingUtilities
.
replaceUIInputMap
(
label
,
JComponent
.
WHEN_IN_FOCUSED_WINDOW
,
inputMap
);
}
int
dka
=
label
.
getDisplayedMnemonic
();
inputMap
.
remove
(
KeyStroke
.
getKeyStroke
(
dka
,
BasicLookAndFeel
.
getFocusAcceleratorKeyMask
(),
true
));
inputMap
.
remove
(
KeyStroke
.
getKeyStroke
(
dka
,
0
,
true
));
inputMap
.
remove
(
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_ALT
,
0
,
true
));
}
if
(
labelFor
instanceof
Container
&&
((
Container
)
labelFor
).
isFocusCycleRoot
())
{
labelFor
.
requestFocus
();
if
(
isCommand
)
{
putOnRelease
(
inputMap
,
KeyEvent
.
VK_ALT
,
0
);
}
else
{
putOnRelease
(
inputMap
,
dka
,
BasicLookAndFeel
.
getFocusAcceleratorKeyMask
());
// Need this when the sticky keys are enabled
putOnRelease
(
inputMap
,
dka
,
0
);
}
if
(
labelFor
instanceof
Container
&&
((
Container
)
labelFor
).
isFocusCycleRoot
())
{
labelFor
.
requestFocus
();
}
else
{
SwingUtilities2
.
compositeRequestFocus
(
labelFor
);
}
}
else
{
SwingUtilities2
.
compositeRequestFocus
(
labelFor
);
InputMap
inputMap
=
SwingUtilities
.
getUIInputMap
(
label
,
JComponent
.
WHEN_IN_FOCUSED_WINDOW
);
int
dka
=
label
.
getDisplayedMnemonic
();
if
(
inputMap
!=
null
)
{
if
(
isCommand
)
{
removeOnRelease
(
inputMap
,
dka
,
BasicLookAndFeel
.
getFocusAcceleratorKeyMask
());
removeOnRelease
(
inputMap
,
dka
,
0
);
}
else
{
removeOnRelease
(
inputMap
,
KeyEvent
.
VK_ALT
,
0
);
}
}
}
}
}
private
void
putOnRelease
(
InputMap
inputMap
,
int
keyCode
,
int
modifiers
)
{
inputMap
.
put
(
KeyStroke
.
getKeyStroke
(
keyCode
,
modifiers
,
true
),
RELEASE
);
}
private
void
removeOnRelease
(
InputMap
inputMap
,
int
keyCode
,
int
modifiers
)
{
inputMap
.
remove
(
KeyStroke
.
getKeyStroke
(
keyCode
,
modifiers
,
true
));
}
}
}
src/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java
浏览文件 @
f5fe9e18
...
...
@@ -180,6 +180,15 @@ public class BasicMenuItemUI extends MenuItemUI
arrowIcon
instanceof
UIResource
)
{
arrowIcon
=
UIManager
.
getIcon
(
prefix
+
".arrowIcon"
);
}
updateCheckIcon
();
}
/**
* Updates check Icon based on column layout
*/
private
void
updateCheckIcon
()
{
String
prefix
=
getPropertyPrefix
();
if
(
checkIcon
==
null
||
checkIcon
instanceof
UIResource
)
{
checkIcon
=
UIManager
.
getIcon
(
prefix
+
".checkIcon"
);
...
...
@@ -190,8 +199,8 @@ public class BasicMenuItemUI extends MenuItemUI
BasicGraphicsUtils
.
isLeftToRight
(
menuItem
),
menuItem
);
if
(
isColumnLayout
)
{
MenuItemCheckIconFactory
iconFactory
=
(
MenuItemCheckIconFactory
)
UIManager
.
get
(
prefix
+
".checkIconFactory"
);
(
MenuItemCheckIconFactory
)
UIManager
.
get
(
prefix
+
".checkIconFactory"
);
if
(
iconFactory
!=
null
&&
MenuItemLayoutHelper
.
useCheckAndArrow
(
menuItem
)
&&
iconFactory
.
isCompatible
(
checkIcon
,
prefix
))
{
...
...
@@ -966,6 +975,8 @@ public class BasicMenuItemUI extends MenuItemUI
BasicHTML
.
updateRenderer
(
lbl
,
text
);
}
else
if
(
name
==
"iconTextGap"
)
{
defaultTextIconGap
=
((
Number
)
e
.
getNewValue
()).
intValue
();
}
else
if
(
name
==
"horizontalTextPosition"
)
{
updateCheckIcon
();
}
}
}
...
...
src/windows/native/sun/windows/awt_FileDialog.cpp
浏览文件 @
f5fe9e18
...
...
@@ -349,9 +349,9 @@ AwtFileDialog::Show(void *p)
// show the Win32 file dialog
if
(
mode
==
java_awt_FileDialog_LOAD
)
{
result
=
AwtFileDialog
::
GetOpenFileName
(
&
ofn
);
result
=
::
GetOpenFileName
(
&
ofn
);
}
else
{
result
=
AwtFileDialog
::
GetSaveFileName
(
&
ofn
);
result
=
::
GetSaveFileName
(
&
ofn
);
}
// Fix for 4181310: FileDialog does not show up.
// If the dialog is not shown because of invalid file name
...
...
@@ -361,9 +361,9 @@ AwtFileDialog::Show(void *p)
if
(
dlgerr
==
FNERR_INVALIDFILENAME
)
{
_tcscpy_s
(
fileBuffer
,
bufferLimit
,
TEXT
(
""
));
if
(
mode
==
java_awt_FileDialog_LOAD
)
{
result
=
AwtFileDialog
::
GetOpenFileName
(
&
ofn
);
result
=
::
GetOpenFileName
(
&
ofn
);
}
else
{
result
=
AwtFileDialog
::
GetSaveFileName
(
&
ofn
);
result
=
::
GetSaveFileName
(
&
ofn
);
}
}
}
...
...
@@ -422,22 +422,6 @@ AwtFileDialog::Show(void *p)
delete
[]
ofn
.
lpstrFile
;
}
BOOL
AwtFileDialog
::
GetOpenFileName
(
LPOPENFILENAME
data
)
{
return
static_cast
<
BOOL
>
(
reinterpret_cast
<
INT_PTR
>
(
AwtToolkit
::
GetInstance
().
InvokeFunction
((
void
*
(
*
)(
void
*
))
::
GetOpenFileName
,
data
)));
}
BOOL
AwtFileDialog
::
GetSaveFileName
(
LPOPENFILENAME
data
)
{
return
static_cast
<
BOOL
>
(
reinterpret_cast
<
INT_PTR
>
(
AwtToolkit
::
GetInstance
().
InvokeFunction
((
void
*
(
*
)(
void
*
))
::
GetSaveFileName
,
data
)));
}
BOOL
AwtFileDialog
::
InheritsNativeMouseWheelBehavior
()
{
return
true
;}
void
AwtFileDialog
::
_DisposeOrHide
(
void
*
param
)
...
...
@@ -585,9 +569,10 @@ Java_sun_awt_windows_WFileDialogPeer__1show(JNIEnv *env, jobject peer)
*/
jobject
peerGlobal
=
env
->
NewGlobalRef
(
peer
);
AwtToolkit
::
GetInstance
().
InvokeFunction
(
AwtFileDialog
::
Show
,
peerGlobal
);
env
->
DeleteGlobalRef
(
peerGlobal
);
if
(
!
AwtToolkit
::
GetInstance
().
PostMessage
(
WM_AWT_INVOKE_METHOD
,
(
WPARAM
)
AwtFileDialog
::
Show
,
(
LPARAM
)
peerGlobal
))
{
env
->
DeleteGlobalRef
(
peerGlobal
);
}
CATCH_BAD_ALLOC
;
}
...
...
src/windows/native/sun/windows/awt_FileDialog.h
浏览文件 @
f5fe9e18
...
...
@@ -60,9 +60,6 @@ public:
static
void
Initialize
(
JNIEnv
*
env
,
jstring
filterDescription
);
static
void
Show
(
void
*
peer
);
static
BOOL
GetOpenFileName
(
LPOPENFILENAME
);
static
BOOL
GetSaveFileName
(
LPOPENFILENAME
);
virtual
BOOL
InheritsNativeMouseWheelBehavior
();
// some methods called on Toolkit thread
...
...
test/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java
0 → 100644
浏览文件 @
f5fe9e18
/*
* 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 8169589
* @summary Activating a dialog puts to back another dialog owned by the same frame
* @author Dmitry Markov
* @library ../../regtesthelpers
* @build Util
* @run main DialogAboveFrameTest
*/
import
java.awt.Color
;
import
java.awt.Dialog
;
import
java.awt.Frame
;
import
java.awt.Point
;
import
java.awt.Robot
;
import
test.java.awt.regtesthelpers.Util
;
public
class
DialogAboveFrameTest
{
public
static
void
main
(
String
[]
args
)
{
Robot
robot
=
Util
.
createRobot
();
Frame
frame
=
new
Frame
(
"Frame"
);
frame
.
setBackground
(
Color
.
BLUE
);
frame
.
setBounds
(
200
,
50
,
300
,
300
);
frame
.
setVisible
(
true
);
Dialog
dialog1
=
new
Dialog
(
frame
,
"Dialog 1"
,
false
);
dialog1
.
setBackground
(
Color
.
RED
);
dialog1
.
setBounds
(
100
,
100
,
200
,
200
);
dialog1
.
setVisible
(
true
);
Dialog
dialog2
=
new
Dialog
(
frame
,
"Dialog 2"
,
false
);
dialog2
.
setBackground
(
Color
.
GREEN
);
dialog2
.
setBounds
(
400
,
100
,
200
,
200
);
dialog2
.
setVisible
(
true
);
Util
.
waitForIdle
(
robot
);
Util
.
clickOnComp
(
dialog2
,
robot
);
Util
.
waitForIdle
(
robot
);
Point
point
=
dialog1
.
getLocationOnScreen
();
int
x
=
point
.
x
+
(
int
)(
dialog1
.
getWidth
()
*
0.9
);
int
y
=
point
.
y
+
(
int
)(
dialog1
.
getHeight
()
*
0.9
);
try
{
if
(!
robot
.
getPixelColor
(
x
,
y
).
equals
(
dialog1
.
getBackground
()))
{
throw
new
RuntimeException
(
"Test FAILED: Dialog is behind the frame"
);
}
}
finally
{
frame
.
dispose
();
dialog1
.
dispose
();
dialog2
.
dispose
();
}
}
}
test/java/awt/FileDialog/DeleteInsideFileDialog/DeleteInsideFileDialogTest.java
0 → 100644
浏览文件 @
f5fe9e18
/*
* 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 8075516
@requires os.family=="windows"
@summary Deleting a file from either the open or save java.awt.FileDialog
hangs.
@run main/manual DeleteInsideFileDialogTest
*/
import
java.awt.*
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
public
class
DeleteInsideFileDialogTest
{
private
static
Path
dir
;
private
static
Path
file1
;
private
static
Path
file2
;
private
static
Frame
f
;
private
static
FileDialog
fd
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
instructions
=
"1) Delete file deleteMe.tst in the opened File Dialog window"
+
" using the right click popup menu\n"
+
"2) Select thenSelectMe.tst file in the File Dialog and press"
+
" Open (if this is not possible the test fails)\n"
;
dir
=
Files
.
createTempDirectory
(
"Test"
);
file1
=
Files
.
createFile
(
Paths
.
get
(
dir
.
toString
(),
"deleteMe.tst"
));
file2
=
Files
.
createFile
(
Paths
.
get
(
dir
.
toString
(),
"thenSelectMe.tst"
));
try
{
f
=
new
Frame
(
"Instructions"
);
f
.
add
(
new
TextArea
(
instructions
,
6
,
60
,
TextArea
.
SCROLLBARS_NONE
));
f
.
pack
();
f
.
setLocation
(
100
,
500
);
f
.
setVisible
(
true
);
fd
=
new
FileDialog
((
Frame
)
null
);
fd
.
setDirectory
(
dir
.
toString
());
fd
.
setVisible
(
true
);
if
(
fd
.
getFile
()
==
null
)
{
throw
new
RuntimeException
(
"Failed"
);
}
}
finally
{
if
(
fd
!=
null
)
{
fd
.
dispose
();
}
if
(
f
!=
null
)
{
f
.
dispose
();
}
Files
.
deleteIfExists
(
file1
);
Files
.
deleteIfExists
(
file2
);
Files
.
deleteIfExists
(
dir
);
}
}
}
test/java/awt/Frame/NormalToIconified/NormalToIconifiedTest.java
0 → 100644
浏览文件 @
f5fe9e18
/*
* 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 8171949
* @summary Tests that bitwise mask is set and state listener is notified during state transition.
* @author Dmitry Markov
* @library ../../regtesthelpers
* @build Util
* @run main NormalToIconifiedTest
*/
import
java.awt.Frame
;
import
java.awt.Robot
;
import
java.awt.event.WindowEvent
;
import
java.awt.event.WindowStateListener
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
test.java.awt.regtesthelpers.Util
;
public
class
NormalToIconifiedTest
{
private
static
final
AtomicBoolean
listenerNotified
=
new
AtomicBoolean
(
false
);
public
static
void
main
(
String
[]
args
)
{
Robot
robot
=
Util
.
createRobot
();
Frame
testFrame
=
new
Frame
(
"Test Frame"
);
testFrame
.
setSize
(
200
,
200
);
testFrame
.
addWindowStateListener
(
new
WindowStateListener
()
{
@Override
public
void
windowStateChanged
(
WindowEvent
e
)
{
listenerNotified
.
set
(
true
);
synchronized
(
listenerNotified
)
{
listenerNotified
.
notifyAll
();
}
}
});
testFrame
.
setVisible
(
true
);
Frame
mainFrame
=
new
Frame
(
"Main Frame"
);
mainFrame
.
setSize
(
200
,
200
);
mainFrame
.
setLocationRelativeTo
(
null
);
mainFrame
.
setVisible
(
true
);
Util
.
waitForIdle
(
robot
);
try
{
Util
.
clickOnComp
(
mainFrame
,
robot
);
Util
.
waitForIdle
(
robot
);
// NORMAL -> ICONIFIED
listenerNotified
.
set
(
false
);
testFrame
.
setExtendedState
(
Frame
.
ICONIFIED
);
Util
.
waitForIdle
(
robot
);
Util
.
waitForCondition
(
listenerNotified
,
2000
);
if
(!
listenerNotified
.
get
())
{
throw
new
RuntimeException
(
"Test FAILED! Window state listener was not notified during NORMAL to"
+
"ICONIFIED transition"
);
}
if
(
testFrame
.
getExtendedState
()
!=
Frame
.
ICONIFIED
)
{
throw
new
RuntimeException
(
"Test FAILED! Frame is not in ICONIFIED state"
);
}
// ICONIFIED -> NORMAL
listenerNotified
.
set
(
false
);
testFrame
.
setExtendedState
(
Frame
.
NORMAL
);
Util
.
waitForIdle
(
robot
);
Util
.
waitForCondition
(
listenerNotified
,
2000
);
if
(!
listenerNotified
.
get
())
{
throw
new
RuntimeException
(
"Test FAILED! Window state listener was not notified during ICONIFIED to"
+
"NORMAL transition"
);
}
if
(
testFrame
.
getExtendedState
()
!=
Frame
.
NORMAL
)
{
throw
new
RuntimeException
(
"Test FAILED! Frame is not in NORMAL state"
);
}
}
finally
{
testFrame
.
dispose
();
mainFrame
.
dispose
();
}
}
}
test/java/awt/Frame/ObscuredFrame/ObscuredFrameTest.java
0 → 100644
浏览文件 @
f5fe9e18
/*
* 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 8171952
* @summary Tests that getMousePosition() returns null for obscured component.
* @author Dmitry Markov
* @library ../../regtesthelpers
* @build Util
* @run main ObscuredFrameTest
*/
import
java.awt.*
;
import
test.java.awt.regtesthelpers.Util
;
public
class
ObscuredFrameTest
{
public
static
void
main
(
String
[]
args
)
{
Robot
robot
=
Util
.
createRobot
();
Frame
frame
=
new
Frame
(
"Obscured Frame"
);
frame
.
setSize
(
200
,
200
);
frame
.
setLocationRelativeTo
(
null
);
Button
button
=
new
Button
(
"Button"
);
frame
.
add
(
button
);
Dialog
dialog
=
new
Dialog
(
frame
,
"Visible Dialog"
,
false
);
dialog
.
setSize
(
200
,
200
);
dialog
.
setLocationRelativeTo
(
null
);
dialog
.
setVisible
(
true
);
frame
.
setVisible
(
true
);
Util
.
waitForIdle
(
robot
);
Util
.
pointOnComp
(
button
,
robot
);
Util
.
waitForIdle
(
robot
);
robot
.
delay
(
2000
);
try
{
if
(
button
.
getMousePosition
()
!=
null
)
{
throw
new
RuntimeException
(
"Test Failed! Mouse position is not null for obscured component."
);
}
}
finally
{
frame
.
dispose
();
dialog
.
dispose
();
}
}
}
test/java/awt/MouseInfo/GetPointerInfoTest.java
0 → 100644
浏览文件 @
f5fe9e18
/*
* Copyright (c) 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.
*/
/*
@test
@summary unit test for getPointerInfo() from MouseInfo class
@author dav@sparc.spb.su: area=
@bug 4009555
@run main GetPointerInfoTest
*/
import
java.awt.*
;
/**
* Simply check the result on non-null and results are correct.
*/
public
class
GetPointerInfoTest
{
private
static
final
String
successStage
=
"Test stage completed.Passed."
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
GraphicsEnvironment
ge
=
GraphicsEnvironment
.
getLocalGraphicsEnvironment
();
GraphicsDevice
[]
gds
=
ge
.
getScreenDevices
();
int
gdslen
=
gds
.
length
;
System
.
out
.
println
(
"There are "
+
gdslen
+
" Graphics Devices"
);
if
(
gdslen
==
0
)
{
System
.
out
.
println
(
"Nothing to be done."
);
return
;
}
Robot
robot
=
new
Robot
(
gds
[
0
]);
robot
.
setAutoDelay
(
0
);
robot
.
setAutoWaitForIdle
(
true
);
robot
.
delay
(
10
);
robot
.
waitForIdle
();
Point
p
=
new
Point
(
101
,
99
);
robot
.
mouseMove
(
p
.
x
,
p
.
y
);
PointerInfo
pi
=
MouseInfo
.
getPointerInfo
();
if
(
pi
==
null
)
{
throw
new
RuntimeException
(
"Test failed. getPointerInfo() returned null value."
);
}
else
{
System
.
out
.
println
(
successStage
);
}
Point
piLocation
=
pi
.
getLocation
();
if
(
piLocation
.
x
!=
p
.
x
||
piLocation
.
y
!=
p
.
y
)
{
throw
new
RuntimeException
(
"Test failed.getPointerInfo() returned incorrect result."
);
}
else
{
System
.
out
.
println
(
successStage
);
}
System
.
out
.
println
(
"Test PASSED."
);
}
}
test/java/awt/MouseInfo/MultiscreenPointerInfo.java
0 → 100644
浏览文件 @
f5fe9e18
/*
* Copyright (c) 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.
*/
/*
@test
@summary unit test for getPointerInfo() from MouseInfo class
@author prs@sparc.spb.su: area=
@bug 4009555
@run main MultiscreenPointerInfo
*/
import
java.awt.*
;
/**
* Simply check the result on non-null and results are correct.
*/
public
class
MultiscreenPointerInfo
{
private
static
final
String
successStage
=
"Test stage completed.Passed."
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
GraphicsEnvironment
ge
=
GraphicsEnvironment
.
getLocalGraphicsEnvironment
();
GraphicsDevice
[]
gds
=
ge
.
getScreenDevices
();
int
gdslen
=
gds
.
length
;
System
.
out
.
println
(
"There are "
+
gdslen
+
" Graphics Devices"
);
if
(
gdslen
<
2
)
{
System
.
out
.
println
(
"Nothing to be done. PASSED automatically."
);
return
;
}
Rectangle
rx
=
gds
[
1
].
getDefaultConfiguration
().
getBounds
();
Robot
robot
;
if
(
rx
.
x
==
0
&&
rx
.
y
==
0
)
{
// Assuming independent graphics devices
robot
=
new
Robot
(
gds
[
1
]);
}
else
{
// Means we have a virtual device
robot
=
new
Robot
(
gds
[
0
]);
}
robot
.
setAutoDelay
(
0
);
robot
.
setAutoWaitForIdle
(
true
);
robot
.
delay
(
10
);
robot
.
waitForIdle
();
Point
p
=
new
Point
(
rx
.
x
+
101
,
rx
.
y
+
99
);
robot
.
mouseMove
(
p
.
x
,
p
.
y
);
PointerInfo
pi
=
MouseInfo
.
getPointerInfo
();
if
(
pi
==
null
)
{
throw
new
RuntimeException
(
"Test failed. getPointerInfo() returned null value."
);
}
else
{
System
.
out
.
println
(
successStage
);
}
Point
piLocation
=
pi
.
getLocation
();
if
(
piLocation
.
x
!=
p
.
x
||
piLocation
.
y
!=
p
.
y
)
{
throw
new
RuntimeException
(
"Test failed.getPointerInfo() returned incorrect location."
);
}
else
{
System
.
out
.
println
(
successStage
);
}
GraphicsDevice
dev
=
pi
.
getDevice
();
if
(
dev
!=
gds
[
1
])
{
throw
new
RuntimeException
(
"Test failed.getPointerInfo() returned incorrect device."
);
}
else
{
System
.
out
.
println
(
successStage
);
}
System
.
out
.
println
(
"Test PASSED."
);
}
}
test/javax/swing/JMenuItem/8152981/MenuItemIconTest.java
0 → 100644
浏览文件 @
f5fe9e18
/*
* 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 8152981
* @summary Double icons with JMenuItem setHorizontalTextPosition on Win 10
* @requires (os.family == "windows")
* @run main MenuItemIconTest
*/
import
java.awt.Color
;
import
java.awt.Dimension
;
import
java.awt.Graphics
;
import
java.awt.Point
;
import
java.awt.Robot
;
import
java.awt.image.BufferedImage
;
import
javax.swing.ImageIcon
;
import
javax.swing.JFrame
;
import
javax.swing.JMenuBar
;
import
javax.swing.JMenuItem
;
import
javax.swing.SwingConstants
;
import
javax.swing.SwingUtilities
;
import
javax.swing.UIManager
;
import
javax.swing.UnsupportedLookAndFeelException
;
public
class
MenuItemIconTest
{
private
static
JFrame
frame
;
private
static
Robot
robot
;
private
static
String
errorMessage
=
""
;
private
static
JMenuItem
menuItem
;
private
static
final
int
IMAGE_WIDTH_AND_HEIGHT
=
25
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
robot
=
new
Robot
();
String
name
=
UIManager
.
getSystemLookAndFeelClassName
();
try
{
UIManager
.
setLookAndFeel
(
name
);
}
catch
(
ClassNotFoundException
|
InstantiationException
|
IllegalAccessException
|
UnsupportedLookAndFeelException
e
)
{
throw
new
RuntimeException
(
"Test Failed"
);
}
createUI
();
robot
.
waitForIdle
();
executeTest
();
if
(!
""
.
equals
(
errorMessage
))
{
throw
new
RuntimeException
(
errorMessage
);
}
}
private
static
void
createUI
()
throws
Exception
{
SwingUtilities
.
invokeAndWait
(()
->
{
frame
=
new
JFrame
();
frame
.
setTitle
(
"Test"
);
JMenuBar
menuBar
=
new
JMenuBar
();
ImageIcon
icon
=
createIcon
();
menuItem
=
new
JMenuItem
(
"Command"
,
icon
);
menuItem
.
setHorizontalTextPosition
(
SwingConstants
.
LEFT
);
menuBar
.
add
(
menuItem
);
frame
.
setJMenuBar
(
menuBar
);
frame
.
setPreferredSize
(
new
Dimension
(
500
,
500
));
frame
.
pack
();
frame
.
setVisible
(
true
);
frame
.
setLocationRelativeTo
(
null
);
});
}
private
static
void
checkPixeclColor
(
int
x
,
int
y
)
{
robot
.
delay
(
2000
);
robot
.
mouseMove
(
x
,
y
);
Color
c
=
robot
.
getPixelColor
(
x
,
y
);
if
(
c
.
getRed
()
==
255
)
{
errorMessage
=
"Test Failed"
;
}
robot
.
delay
(
5000
);
frame
.
dispose
();
}
protected
static
ImageIcon
createIcon
()
{
BufferedImage
bi
=
new
BufferedImage
(
IMAGE_WIDTH_AND_HEIGHT
,
IMAGE_WIDTH_AND_HEIGHT
,
BufferedImage
.
TYPE_INT_ARGB
);
Graphics
g
=
bi
.
createGraphics
();
g
.
setColor
(
Color
.
RED
);
g
.
fillOval
(
0
,
0
,
IMAGE_WIDTH_AND_HEIGHT
,
IMAGE_WIDTH_AND_HEIGHT
);
return
new
ImageIcon
(
bi
);
}
private
static
void
executeTest
()
throws
Exception
{
Point
point
=
menuItem
.
getLocationOnScreen
();
checkPixeclColor
(
point
.
x
+
IMAGE_WIDTH_AND_HEIGHT
/
2
,
point
.
y
+
IMAGE_WIDTH_AND_HEIGHT
/
2
);
}
}
test/javax/swing/plaf/basic/BasicLabelUI/bug7172652.java
0 → 100644
浏览文件 @
f5fe9e18
/*
* 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 7172652
@summary With JDK 1.7 text field does not obtain focus when using mnemonic Alt/Key combin
@author Semyon Sadetsky
@library /lib/testlibrary
@build jdk.testlibrary.OSInfo
@run main bug7172652
*/
import
javax.swing.*
;
import
javax.swing.event.ChangeEvent
;
import
javax.swing.event.ChangeListener
;
import
java.awt.*
;
import
java.awt.event.KeyEvent
;
import
jdk.testlibrary.OSInfo
;
public
class
bug7172652
{
private
static
JMenu
menu
;
private
static
JFrame
frame
;
private
static
Boolean
selected
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
OSInfo
.
getOSType
()
!=
OSInfo
.
OSType
.
WINDOWS
)
{
System
.
out
.
println
(
"ok"
);
return
;
}
UIManager
.
setLookAndFeel
(
UIManager
.
getSystemLookAndFeelClassName
());
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
setup
();
}
});
test
();
SwingUtilities
.
invokeLater
(
new
Runnable
()
{
@Override
public
void
run
()
{
frame
.
dispose
();
}
});
}
private
static
void
test
()
throws
Exception
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
menu
.
getModel
().
addChangeListener
(
new
ChangeListener
()
{
@Override
public
void
stateChanged
(
ChangeEvent
e
)
{
selected
=
menu
.
isSelected
();
}
});
}
});
Robot
robot
=
new
Robot
();
robot
.
setAutoDelay
(
200
);
robot
.
keyPress
(
KeyEvent
.
VK_ALT
);
robot
.
keyPress
(
KeyEvent
.
VK_F
);
robot
.
keyRelease
(
KeyEvent
.
VK_F
);
robot
.
keyRelease
(
KeyEvent
.
VK_ALT
);
robot
.
waitForIdle
();
if
(
selected
!=
null
)
{
throw
new
RuntimeException
(
"Menu is notified selected= "
+
selected
);
}
robot
.
keyPress
(
KeyEvent
.
VK_ALT
);
robot
.
keyPress
(
KeyEvent
.
VK_F
);
robot
.
keyRelease
(
KeyEvent
.
VK_F
);
robot
.
keyRelease
(
KeyEvent
.
VK_ALT
);
if
(
selected
!=
null
)
{
throw
new
RuntimeException
(
"Menu is notified selected= "
+
selected
);
}
robot
.
waitForIdle
();
robot
.
keyPress
(
KeyEvent
.
VK_ALT
);
robot
.
keyPress
(
KeyEvent
.
VK_F
);
robot
.
keyRelease
(
KeyEvent
.
VK_F
);
robot
.
keyRelease
(
KeyEvent
.
VK_ALT
);
if
(
selected
!=
null
)
{
throw
new
RuntimeException
(
"Menu is notified selected= "
+
selected
);
}
robot
.
waitForIdle
();
robot
.
keyPress
(
KeyEvent
.
VK_ALT
);
robot
.
keyPress
(
KeyEvent
.
VK_F
);
robot
.
keyRelease
(
KeyEvent
.
VK_F
);
robot
.
keyRelease
(
KeyEvent
.
VK_ALT
);
if
(
selected
!=
null
)
{
throw
new
RuntimeException
(
"Menu is notified selected= "
+
selected
);
}
robot
.
waitForIdle
();
System
.
out
.
printf
(
"ok"
);
}
private
static
void
setup
()
{
JLabel
firstLbl
=
new
JLabel
(
"First name"
);
JLabel
lastLbl
=
new
JLabel
(
"Last name"
);
JMenuBar
menuBar
=
new
JMenuBar
();
JTextField
firstTxtFld
=
new
JTextField
(
20
);
JTextField
lastTxtFld
=
new
JTextField
(
20
);
JDesktopPane
desktopPane
=
new
JDesktopPane
();
JInternalFrame
iframe
=
new
JInternalFrame
(
"A frame"
,
true
,
true
,
true
,
true
);
// Set an initial size
iframe
.
setSize
(
200
,
220
);
// By default, internal frames are not visible; make it visible
iframe
.
setVisible
(
true
);
JPanel
pane
=
new
JPanel
();
pane
.
setLayout
(
new
FlowLayout
());
pane
.
add
(
firstLbl
);
pane
.
add
(
firstTxtFld
);
pane
.
add
(
lastLbl
);
pane
.
add
(
lastTxtFld
);
firstLbl
.
setLabelFor
(
firstTxtFld
);
firstLbl
.
setDisplayedMnemonic
(
'F'
);
lastLbl
.
setLabelFor
(
lastTxtFld
);
lastLbl
.
setDisplayedMnemonic
(
'L'
);
iframe
.
getContentPane
().
add
(
pane
);
iframe
.
setJMenuBar
(
menuBar
);
menu
=
new
JMenu
(
"FirstMenu"
);
//m.setMnemonic('i');
menuBar
.
add
(
menu
);
desktopPane
.
add
(
iframe
);
frame
=
new
JFrame
();
frame
.
setUndecorated
(
true
);
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
frame
.
getContentPane
().
add
(
desktopPane
);
frame
.
setSize
(
300
,
300
);
frame
.
setVisible
(
true
);
}
}
test/javax/xml/ws/8159058/SaajEmptyNamespaceTest.java
0 → 100644
浏览文件 @
f5fe9e18
/*
* Copyright (c) 2017, 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 8159058
* @summary Test that empty default namespace declaration clears the
* default namespace value
* @compile -XDignore.symbol.file SaajEmptyNamespaceTest.java
* @run testng/othervm SaajEmptyNamespaceTest
*/
import
com.sun.xml.internal.ws.api.SOAPVersion
;
import
com.sun.xml.internal.ws.api.message.saaj.SAAJFactory
;
import
com.sun.xml.internal.ws.message.stream.StreamMessage
;
import
java.io.ByteArrayInputStream
;
import
java.io.StringReader
;
import
java.io.StringWriter
;
import
java.io.UnsupportedEncodingException
;
import
javax.xml.namespace.QName
;
import
javax.xml.soap.MessageFactory
;
import
javax.xml.soap.SOAPBody
;
import
javax.xml.soap.SOAPElement
;
import
javax.xml.soap.SOAPException
;
import
javax.xml.soap.SOAPMessage
;
import
javax.xml.stream.XMLInputFactory
;
import
javax.xml.stream.XMLStreamReader
;
import
javax.xml.transform.OutputKeys
;
import
javax.xml.transform.Transformer
;
import
javax.xml.transform.TransformerException
;
import
javax.xml.transform.TransformerFactory
;
import
javax.xml.transform.dom.DOMSource
;
import
javax.xml.transform.stream.StreamResult
;
import
javax.xml.transform.stream.StreamSource
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
import
org.w3c.dom.Node
;
public
class
SaajEmptyNamespaceTest
{
/*
* Test that SOAP message with default namespace declaration that contains empty
* string is properly processed by SAAJ reader.
*/
@Test
public
void
testResetDefaultNamespaceSAAJ
()
throws
Exception
{
// Create SOAP message from XML string and process it with SAAJ reader
XMLStreamReader
envelope
=
XMLInputFactory
.
newFactory
().
createXMLStreamReader
(
new
StringReader
(
INPUT_SOAP_MESSAGE
));
StreamMessage
streamMessage
=
new
StreamMessage
(
SOAPVersion
.
SOAP_11
,
envelope
,
null
);
SAAJFactory
saajFact
=
new
SAAJFactory
();
SOAPMessage
soapMessage
=
saajFact
.
readAsSOAPMessage
(
SOAPVersion
.
SOAP_11
,
streamMessage
);
// Check if constructed object model meets local names and namespace expectations
SOAPElement
request
=
(
SOAPElement
)
soapMessage
.
getSOAPBody
().
getFirstChild
();
// Check top body element name
Assert
.
assertEquals
(
request
.
getLocalName
(),
"SampleServiceRequest"
);
// Check top body element namespace
Assert
.
assertEquals
(
request
.
getNamespaceURI
(),
TEST_NS
);
SOAPElement
params
=
(
SOAPElement
)
request
.
getFirstChild
();
// Check first child name
Assert
.
assertEquals
(
params
.
getLocalName
(),
"RequestParams"
);
// Check if first child namespace is null
Assert
.
assertNull
(
params
.
getNamespaceURI
());
// Check inner elements of the first child
SOAPElement
param1
=
(
SOAPElement
)
params
.
getFirstChild
();
Assert
.
assertEquals
(
param1
.
getLocalName
(),
"Param1"
);
Assert
.
assertNull
(
param1
.
getNamespaceURI
());
SOAPElement
param2
=
(
SOAPElement
)
params
.
getChildNodes
().
item
(
1
);
Assert
.
assertEquals
(
param2
.
getLocalName
(),
"Param2"
);
Assert
.
assertNull
(
param2
.
getNamespaceURI
());
// Check full content of SOAP body
Assert
.
assertEquals
(
nodeToText
(
request
),
EXPECTED_RESULT
);
}
/*
* Test that adding element with explicitly null namespace URI shall put the
* element into global namespace. Namespace declarations are not added explicitly.
*/
@Test
public
void
testAddElementToNullNsNoDeclarations
()
throws
Exception
{
// Create empty SOAP message
SOAPMessage
msg
=
createSoapMessage
();
SOAPBody
body
=
msg
.
getSOAPPart
().
getEnvelope
().
getBody
();
// Add elements
SOAPElement
parentExplicitNS
=
body
.
addChildElement
(
"content"
,
""
,
TEST_NS
);
SOAPElement
childGlobalNS
=
parentExplicitNS
.
addChildElement
(
"global-child"
,
""
,
null
);
SOAPElement
childDefaultNS
=
parentExplicitNS
.
addChildElement
(
"default-child"
);
// Check namespace URIs
Assert
.
assertNull
(
childGlobalNS
.
getNamespaceURI
());
Assert
.
assertEquals
(
childDefaultNS
.
getNamespaceURI
(),
TEST_NS
);
}
/*
* Test that adding element with explicitly empty namespace URI shall put
* the element into global namespace. Namespace declarations are not added
* explicitly.
*/
@Test
public
void
testAddElementToGlobalNsNoDeclarations
()
throws
Exception
{
// Create empty SOAP message
SOAPMessage
msg
=
createSoapMessage
();
SOAPBody
body
=
msg
.
getSOAPPart
().
getEnvelope
().
getBody
();
// Add elements
SOAPElement
parentExplicitNS
=
body
.
addChildElement
(
"content"
,
""
,
TEST_NS
);
SOAPElement
childGlobalNS
=
parentExplicitNS
.
addChildElement
(
"global-child"
,
""
,
""
);
SOAPElement
childDefaultNS
=
parentExplicitNS
.
addChildElement
(
"default-child"
);
// Check namespace URIs
Assert
.
assertNull
(
childGlobalNS
.
getNamespaceURI
());
Assert
.
assertEquals
(
childDefaultNS
.
getNamespaceURI
(),
TEST_NS
);
}
/*
* Test that adding element with explicitly empty namespace URI set via QName
* shall put the element into global namespace.
*/
@Test
public
void
testAddElementToNullNsQName
()
throws
Exception
{
// Create empty SOAP message
SOAPMessage
msg
=
createSoapMessage
();
SOAPBody
body
=
msg
.
getSOAPPart
().
getEnvelope
().
getBody
();
// Add elements
SOAPElement
parentExplicitNS
=
body
.
addChildElement
(
"content"
,
""
,
TEST_NS
);
parentExplicitNS
.
addNamespaceDeclaration
(
""
,
TEST_NS
);
SOAPElement
childGlobalNS
=
parentExplicitNS
.
addChildElement
(
new
QName
(
null
,
"global-child"
));
childGlobalNS
.
addNamespaceDeclaration
(
""
,
""
);
SOAPElement
grandChildGlobalNS
=
childGlobalNS
.
addChildElement
(
"global-grand-child"
);
SOAPElement
childDefaultNS
=
parentExplicitNS
.
addChildElement
(
"default-child"
);
// Check namespace URIs
Assert
.
assertNull
(
childGlobalNS
.
getNamespaceURI
());
Assert
.
assertNull
(
grandChildGlobalNS
.
getNamespaceURI
());
Assert
.
assertEquals
(
childDefaultNS
.
getNamespaceURI
(),
TEST_NS
);
}
/*
* Test that adding element with explicitly empty namespace URI shall put
* the element into global namespace.
*/
@Test
public
void
testAddElementToGlobalNs
()
throws
Exception
{
// Create empty SOAP message
SOAPMessage
msg
=
createSoapMessage
();
SOAPBody
body
=
msg
.
getSOAPPart
().
getEnvelope
().
getBody
();
// Add elements
SOAPElement
parentExplicitNS
=
body
.
addChildElement
(
"content"
,
""
,
TEST_NS
);
parentExplicitNS
.
addNamespaceDeclaration
(
""
,
TEST_NS
);
SOAPElement
childGlobalNS
=
parentExplicitNS
.
addChildElement
(
"global-child"
,
""
,
""
);
childGlobalNS
.
addNamespaceDeclaration
(
""
,
""
);
SOAPElement
grandChildGlobalNS
=
childGlobalNS
.
addChildElement
(
"global-grand-child"
);
SOAPElement
childDefaultNS
=
parentExplicitNS
.
addChildElement
(
"default-child"
);
// Check namespace URIs
Assert
.
assertNull
(
childGlobalNS
.
getNamespaceURI
());
Assert
.
assertNull
(
grandChildGlobalNS
.
getNamespaceURI
());
Assert
.
assertEquals
(
childDefaultNS
.
getNamespaceURI
(),
TEST_NS
);
}
/*
* Test that adding element with explicitly null namespace URI shall put
* the element into global namespace.
*/
@Test
public
void
testAddElementToNullNs
()
throws
Exception
{
// Create empty SOAP message
SOAPMessage
msg
=
createSoapMessage
();
SOAPBody
body
=
msg
.
getSOAPPart
().
getEnvelope
().
getBody
();
// Add elements
SOAPElement
parentExplicitNS
=
body
.
addChildElement
(
"content"
,
""
,
TEST_NS
);
parentExplicitNS
.
addNamespaceDeclaration
(
""
,
TEST_NS
);
SOAPElement
childGlobalNS
=
parentExplicitNS
.
addChildElement
(
"global-child"
,
""
,
null
);
childGlobalNS
.
addNamespaceDeclaration
(
""
,
null
);
SOAPElement
grandChildGlobalNS
=
childGlobalNS
.
addChildElement
(
"global-grand-child"
);
SOAPElement
childDefaultNS
=
parentExplicitNS
.
addChildElement
(
"default-child"
);
// Check namespace URIs
Assert
.
assertNull
(
childGlobalNS
.
getNamespaceURI
());
Assert
.
assertNull
(
grandChildGlobalNS
.
getNamespaceURI
());
Assert
.
assertEquals
(
TEST_NS
,
childDefaultNS
.
getNamespaceURI
());
}
/*
* Test that adding element with explicitly empty namespace URI via QName
* shall put the element in global namespace.
*/
@Test
public
void
testAddElementToGlobalNsQName
()
throws
Exception
{
// Create empty SOAP message
SOAPMessage
msg
=
createSoapMessage
();
SOAPBody
body
=
msg
.
getSOAPPart
().
getEnvelope
().
getBody
();
// Add elements
SOAPElement
parentExplicitNS
=
body
.
addChildElement
(
"content"
,
""
,
TEST_NS
);
parentExplicitNS
.
addNamespaceDeclaration
(
""
,
TEST_NS
);
SOAPElement
childGlobalNS
=
parentExplicitNS
.
addChildElement
(
new
QName
(
""
,
"global-child"
));
childGlobalNS
.
addNamespaceDeclaration
(
""
,
""
);
SOAPElement
grandChildGlobalNS
=
childGlobalNS
.
addChildElement
(
"global-grand-child"
);
SOAPElement
childDefaultNS
=
parentExplicitNS
.
addChildElement
(
"default-child"
);
// Check namespace URIs
Assert
.
assertNull
(
childGlobalNS
.
getNamespaceURI
());
Assert
.
assertNull
(
grandChildGlobalNS
.
getNamespaceURI
());
Assert
.
assertEquals
(
childDefaultNS
.
getNamespaceURI
(),
TEST_NS
);
}
// Convert DOM node to text representation
private
String
nodeToText
(
Node
node
)
throws
TransformerException
{
Transformer
trans
=
TransformerFactory
.
newInstance
().
newTransformer
();
trans
.
setOutputProperty
(
OutputKeys
.
OMIT_XML_DECLARATION
,
"yes"
);
StringWriter
writer
=
new
StringWriter
();
StreamResult
result
=
new
StreamResult
(
writer
);
trans
.
transform
(
new
DOMSource
(
node
),
result
);
String
bodyContent
=
writer
.
toString
();
System
.
out
.
println
(
"SOAP body content read by SAAJ:"
+
bodyContent
);
return
bodyContent
;
}
// Create SOAP message with empty body
private
static
SOAPMessage
createSoapMessage
()
throws
SOAPException
,
UnsupportedEncodingException
{
String
xml
=
"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+
"<SOAP-ENV:Body/></SOAP-ENV:Envelope>"
;
MessageFactory
mFactory
=
MessageFactory
.
newInstance
();
SOAPMessage
msg
=
mFactory
.
createMessage
();
msg
.
getSOAPPart
().
setContent
(
new
StreamSource
(
new
ByteArrayInputStream
(
xml
.
getBytes
(
"utf-8"
))));
return
msg
;
}
// Namespace value used in tests
private
static
String
TEST_NS
=
"http://example.org/test"
;
// Content of SOAP message passed to SAAJ factory
private
static
String
INPUT_SOAP_MESSAGE
=
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+
"<s:Body>"
+
"<SampleServiceRequest xmlns=\"http://example.org/test\""
+
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
+
"<RequestParams xmlns=\"\">"
+
"<Param1>hogehoge</Param1>"
+
"<Param2>fugafuga</Param2>"
+
"</RequestParams>"
+
"</SampleServiceRequest>"
+
"</s:Body>"
+
"</s:Envelope>"
;
// Expected body content after SAAJ processing
private
static
String
EXPECTED_RESULT
=
"<SampleServiceRequest"
+
" xmlns=\"http://example.org/test\">"
+
"<RequestParams xmlns=\"\">"
+
"<Param1>hogehoge</Param1>"
+
"<Param2>fugafuga</Param2>"
+
"</RequestParams>"
+
"</SampleServiceRequest>"
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录