Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
be1145fc
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看板
提交
be1145fc
编写于
12月 28, 2012
作者:
L
lana
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
fb441757
852ba89d
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
465 addition
and
57 deletion
+465
-57
src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java
src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java
+3
-1
src/share/classes/java/beans/DefaultPersistenceDelegate.java
src/share/classes/java/beans/DefaultPersistenceDelegate.java
+5
-4
src/share/classes/java/beans/EventSetDescriptor.java
src/share/classes/java/beans/EventSetDescriptor.java
+7
-3
src/share/classes/java/beans/MethodDescriptor.java
src/share/classes/java/beans/MethodDescriptor.java
+7
-3
src/share/classes/java/beans/Statement.java
src/share/classes/java/beans/Statement.java
+3
-3
src/solaris/classes/sun/awt/X11/XBaseWindow.java
src/solaris/classes/sun/awt/X11/XBaseWindow.java
+3
-6
src/solaris/classes/sun/awt/X11/XConstants.java
src/solaris/classes/sun/awt/X11/XConstants.java
+3
-28
src/solaris/classes/sun/awt/X11/XToolkit.java
src/solaris/classes/sun/awt/X11/XToolkit.java
+4
-0
src/solaris/classes/sun/awt/X11/XWindow.java
src/solaris/classes/sun/awt/X11/XWindow.java
+7
-7
src/solaris/classes/sun/awt/X11/XWindowPeer.java
src/solaris/classes/sun/awt/X11/XWindowPeer.java
+2
-2
src/solaris/classes/sun/awt/X11/XlibUtil.java
src/solaris/classes/sun/awt/X11/XlibUtil.java
+10
-0
test/java/beans/Introspector/Test8005065.java
test/java/beans/Introspector/Test8005065.java
+131
-0
test/javax/swing/AncestorNotifier/7193219/bug7193219.java
test/javax/swing/AncestorNotifier/7193219/bug7193219.java
+2
-0
test/javax/swing/JFrame/4962534/bug4962534.html
test/javax/swing/JFrame/4962534/bug4962534.html
+43
-0
test/javax/swing/JFrame/4962534/bug4962534.java
test/javax/swing/JFrame/4962534/bug4962534.java
+235
-0
未找到文件。
src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java
浏览文件 @
be1145fc
...
...
@@ -119,7 +119,9 @@ public class CEmbeddedFrame extends EmbeddedFrame {
public
void
handleWindowFocusEvent
(
boolean
parentWindowActive
)
{
this
.
parentWindowActive
=
parentWindowActive
;
if
(
focused
)
{
// ignore focus "lost" native request as it may mistakenly
// deactivate active window (see 8001161)
if
(
focused
&&
parentWindowActive
)
{
responder
.
handleWindowFocusEvent
(
parentWindowActive
,
null
);
}
}
...
...
src/share/classes/java/beans/DefaultPersistenceDelegate.java
浏览文件 @
be1145fc
/*
* Copyright (c) 2000, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 201
2
, 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
...
...
@@ -58,7 +58,8 @@ import sun.reflect.misc.*;
*/
public
class
DefaultPersistenceDelegate
extends
PersistenceDelegate
{
private
String
[]
constructor
;
private
static
final
String
[]
EMPTY
=
{};
private
final
String
[]
constructor
;
private
Boolean
definesEquals
;
/**
...
...
@@ -67,7 +68,7 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate {
* @see #DefaultPersistenceDelegate(java.lang.String[])
*/
public
DefaultPersistenceDelegate
()
{
this
(
new
String
[
0
])
;
this
.
constructor
=
EMPTY
;
}
/**
...
...
@@ -92,7 +93,7 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate {
* @see #instantiate
*/
public
DefaultPersistenceDelegate
(
String
[]
constructorPropertyNames
)
{
this
.
constructor
=
constructorPropertyNames
;
this
.
constructor
=
(
constructorPropertyNames
==
null
)
?
EMPTY
:
constructorPropertyNames
.
clone
()
;
}
private
static
boolean
definesEquals
(
Class
<?>
type
)
{
...
...
src/share/classes/java/beans/EventSetDescriptor.java
浏览文件 @
be1145fc
/*
* Copyright (c) 1996, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 201
2
, 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
...
...
@@ -277,7 +277,9 @@ public class EventSetDescriptor extends FeatureDescriptor {
Method
removeListenerMethod
)
throws
IntrospectionException
{
setName
(
eventSetName
);
this
.
listenerMethodDescriptors
=
listenerMethodDescriptors
;
this
.
listenerMethodDescriptors
=
(
listenerMethodDescriptors
!=
null
)
?
listenerMethodDescriptors
.
clone
()
:
null
;
setAddListenerMethod
(
addListenerMethod
);
setRemoveListenerMethod
(
removeListenerMethod
);
setListenerType
(
listenerType
);
...
...
@@ -347,7 +349,9 @@ public class EventSetDescriptor extends FeatureDescriptor {
* events are fired.
*/
public
synchronized
MethodDescriptor
[]
getListenerMethodDescriptors
()
{
return
listenerMethodDescriptors
;
return
(
this
.
listenerMethodDescriptors
!=
null
)
?
this
.
listenerMethodDescriptors
.
clone
()
:
null
;
}
/**
...
...
src/share/classes/java/beans/MethodDescriptor.java
浏览文件 @
be1145fc
/*
* Copyright (c) 1996, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 201
2
, 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
...
...
@@ -70,7 +70,9 @@ public class MethodDescriptor extends FeatureDescriptor {
ParameterDescriptor
parameterDescriptors
[])
{
setName
(
method
.
getName
());
setMethod
(
method
);
this
.
parameterDescriptors
=
parameterDescriptors
;
this
.
parameterDescriptors
=
(
parameterDescriptors
!=
null
)
?
parameterDescriptors
.
clone
()
:
null
;
}
/**
...
...
@@ -161,7 +163,9 @@ public class MethodDescriptor extends FeatureDescriptor {
* a null array if the parameter names aren't known.
*/
public
ParameterDescriptor
[]
getParameterDescriptors
()
{
return
parameterDescriptors
;
return
(
this
.
parameterDescriptors
!=
null
)
?
this
.
parameterDescriptors
.
clone
()
:
null
;
}
/*
...
...
src/share/classes/java/beans/Statement.java
浏览文件 @
be1145fc
/*
* Copyright (c) 2000, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 201
2
, 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
...
...
@@ -92,7 +92,7 @@ public class Statement {
public
Statement
(
Object
target
,
String
methodName
,
Object
[]
arguments
)
{
this
.
target
=
target
;
this
.
methodName
=
methodName
;
this
.
arguments
=
(
arguments
==
null
)
?
emptyArray
:
arguments
;
this
.
arguments
=
(
arguments
==
null
)
?
emptyArray
:
arguments
.
clone
()
;
}
/**
...
...
@@ -128,7 +128,7 @@ public class Statement {
* @return the array of arguments
*/
public
Object
[]
getArguments
()
{
return
arguments
;
return
this
.
arguments
.
clone
()
;
}
/**
...
...
src/solaris/classes/sun/awt/X11/XBaseWindow.java
浏览文件 @
be1145fc
...
...
@@ -994,10 +994,7 @@ public class XBaseWindow {
return
;
}
int
buttonState
=
0
;
final
int
buttonsNumber
=
((
SunToolkit
)(
Toolkit
.
getDefaultToolkit
())).
getNumberOfButtons
();
for
(
int
i
=
0
;
i
<
buttonsNumber
;
i
++){
buttonState
|=
(
xbe
.
get_state
()
&
XConstants
.
buttonsMask
[
i
]);
}
buttonState
=
xbe
.
get_state
()
&
XConstants
.
ALL_BUTTONS_MASK
;
switch
(
xev
.
get_type
())
{
case
XConstants
.
ButtonPress
:
if
(
buttonState
==
0
)
{
...
...
@@ -1034,12 +1031,12 @@ public class XBaseWindow {
* Checks ButtonRelease released all Mouse buttons
*/
static
boolean
isFullRelease
(
int
buttonState
,
int
button
)
{
final
int
buttonsNumber
=
((
SunToolkit
)(
Toolkit
.
getDefaultToolkit
())).
getNumberOfButtons
();
final
int
buttonsNumber
=
XToolkit
.
getNumberOfButtonsForMask
();
if
(
button
<
0
||
button
>
buttonsNumber
)
{
return
buttonState
==
0
;
}
else
{
return
buttonState
==
X
Constants
.
buttonsMask
[
button
-
1
]
;
return
buttonState
==
X
libUtil
.
getButtonMask
(
button
)
;
}
}
...
...
src/solaris/classes/sun/awt/X11/XConstants.java
浏览文件 @
be1145fc
...
...
@@ -130,6 +130,9 @@ final public class XConstants {
public
static
final
long
ColormapChangeMask
=
(
1L
<<
23
)
;
public
static
final
long
OwnerGrabButtonMask
=
(
1L
<<
24
)
;
public
static
final
int
MAX_BUTTONS
=
5
;
public
static
final
int
ALL_BUTTONS_MASK
=
(
int
)
(
Button1MotionMask
|
Button2MotionMask
|
Button3MotionMask
|
Button4MotionMask
|
Button5MotionMask
);
/* Event names. Used in "type" field in XEvent structures. Not to be
confused with event masks above. They start from 2 because 0 and 1
are reserved in the protocol for errors and replies. */
...
...
@@ -194,34 +197,6 @@ final public class XConstants {
public
static
final
int
Mod4MapIndex
=
6
;
public
static
final
int
Mod5MapIndex
=
7
;
/* button masks. Used in same manner as Key masks above. Not to be confused
with button names below. */
public
static
final
int
[]
buttonsMask
=
new
int
[]{
1
<<
8
,
1
<<
9
,
1
<<
10
,
1
<<
11
,
1
<<
12
,
1
<<
13
,
1
<<
14
,
1
<<
15
,
1
<<
16
,
1
<<
17
,
1
<<
18
,
1
<<
19
,
1
<<
20
,
1
<<
21
,
1
<<
22
,
1
<<
23
,
1
<<
24
,
1
<<
25
,
1
<<
26
,
1
<<
27
,
1
<<
28
,
1
<<
29
,
1
<<
30
,
1
<<
31
};
public
static
final
int
AnyModifier
=
(
1
<<
15
)
;
/* used in GrabButton, GrabKey */
...
...
src/solaris/classes/sun/awt/X11/XToolkit.java
浏览文件 @
be1145fc
...
...
@@ -1543,6 +1543,10 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
}
static
int
getNumberOfButtonsForMask
()
{
return
Math
.
min
(
XConstants
.
MAX_BUTTONS
,
((
SunToolkit
)
(
Toolkit
.
getDefaultToolkit
())).
getNumberOfButtons
());
}
private
final
static
String
prefix
=
"DnD.Cursor."
;
private
final
static
String
postfix
=
".32x32"
;
private
static
final
String
dndPrefix
=
"DnD."
;
...
...
src/solaris/classes/sun/awt/X11/XWindow.java
浏览文件 @
be1145fc
...
...
@@ -596,12 +596,12 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
/* this is an attempt to refactor button IDs in : MouseEvent, InputEvent, XlibWrapper and XWindow.*/
//reflects a button number similar to MouseEvent.BUTTON1, 2, 3 etc.
for
(
int
i
=
0
;
i
<
XConstants
.
buttons
Mask
.
length
;
i
++){
for
(
int
i
=
0
;
i
<
XConstants
.
buttons
.
length
;
i
++){
//modifier should be added if :
// 1) current button is now still in PRESSED state (means that user just pressed mouse but not released yet) or
// 2) if Xsystem reports that "state" represents that button was just released. This only happens on RELEASE with 1,2,3 buttons.
// ONLY one of these conditions should be TRUE to add that modifier.
if
(((
state
&
X
Constants
.
buttonsMask
[
i
]
)
!=
0
)
!=
(
button
==
XConstants
.
buttons
[
i
])){
if
(((
state
&
X
libUtil
.
getButtonMask
(
i
+
1
)
)
!=
0
)
!=
(
button
==
XConstants
.
buttons
[
i
])){
//exclude wheel buttons from adding their numbers as modifiers
if
(!
wheel_mouse
)
{
modifiers
|=
InputEvent
.
getMaskForButton
(
i
+
1
);
...
...
@@ -689,7 +689,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
if
(
type
==
XConstants
.
ButtonPress
)
{
//Allow this mouse button to generate CLICK event on next ButtonRelease
mouseButtonClickAllowed
|=
X
Constants
.
buttonsMask
[
lbutton
]
;
mouseButtonClickAllowed
|=
X
libUtil
.
getButtonMask
(
lbutton
)
;
XWindow
lastWindow
=
(
lastWindowRef
!=
null
)
?
((
XWindow
)
lastWindowRef
.
get
()):(
null
);
/*
multiclick checking
...
...
@@ -747,7 +747,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
postEventToEventQueue
(
me
);
if
((
type
==
XConstants
.
ButtonRelease
)
&&
((
mouseButtonClickAllowed
&
X
Constants
.
buttonsMask
[
lbutton
]
)
!=
0
)
)
// No up-button in the drag-state
((
mouseButtonClickAllowed
&
X
libUtil
.
getButtonMask
(
lbutton
)
)
!=
0
)
)
// No up-button in the drag-state
{
postEventToEventQueue
(
me
=
new
MouseEvent
((
Component
)
getEventSource
(),
MouseEvent
.
MOUSE_CLICKED
,
...
...
@@ -777,7 +777,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
/* Update the state variable AFTER the CLICKED event post. */
if
(
type
==
XConstants
.
ButtonRelease
)
{
/* Exclude this mouse button from allowed list.*/
mouseButtonClickAllowed
&=
~
XConstants
.
buttonsMask
[
lbutton
]
;
mouseButtonClickAllowed
&=
~
XlibUtil
.
getButtonMask
(
lbutton
)
;
}
}
...
...
@@ -793,12 +793,12 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
//this doesn't work for extra buttons because Xsystem is sending state==0 for every extra button event.
// we can't correct it in MouseEvent class as we done it with modifiers, because exact type (DRAG|MOVE)
// should be passed from XWindow.
final
int
buttonsNumber
=
((
SunToolkit
)(
Toolkit
.
getDefaultToolkit
())).
getNumberOfButtons
();
final
int
buttonsNumber
=
XToolkit
.
getNumberOfButtonsForMask
();
for
(
int
i
=
0
;
i
<
buttonsNumber
;
i
++){
// TODO : here is the bug in WM: extra buttons doesn't have state!=0 as they should.
if
((
i
!=
4
)
&&
(
i
!=
5
))
{
mouseKeyState
=
mouseKeyState
|
(
xme
.
get_state
()
&
X
Constants
.
buttonsMask
[
i
]
);
mouseKeyState
=
mouseKeyState
|
(
xme
.
get_state
()
&
X
libUtil
.
getButtonMask
(
i
+
1
)
);
}
}
...
...
src/solaris/classes/sun/awt/X11/XWindowPeer.java
浏览文件 @
be1145fc
...
...
@@ -2070,12 +2070,12 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
}
if
(
isGrabbed
())
{
boolean
dragging
=
false
;
final
int
buttonsNumber
=
((
SunToolkit
)(
Toolkit
.
getDefaultToolkit
())).
getNumberOfButtons
();
final
int
buttonsNumber
=
XToolkit
.
getNumberOfButtonsForMask
();
for
(
int
i
=
0
;
i
<
buttonsNumber
;
i
++){
// here is the bug in WM: extra buttons doesn't have state!=0 as they should.
if
((
i
!=
4
)
&&
(
i
!=
5
)){
dragging
=
dragging
||
((
xme
.
get_state
()
&
X
Constants
.
buttonsMask
[
i
]
)
!=
0
);
dragging
=
dragging
||
((
xme
.
get_state
()
&
X
libUtil
.
getButtonMask
(
i
+
1
)
)
!=
0
);
}
}
// When window is grabbed, all events are dispatched to
...
...
src/solaris/classes/sun/awt/X11/XlibUtil.java
浏览文件 @
be1145fc
...
...
@@ -396,4 +396,14 @@ public class XlibUtil
return
isShapingSupported
.
booleanValue
();
}
static
int
getButtonMask
(
int
button
)
{
// Button indices start with 1. The first bit in the button mask is the 8th.
// The state mask does not support button indicies > 5, so we need to
// cut there.
if
(
button
<=
0
||
button
>
XConstants
.
MAX_BUTTONS
)
{
return
0
;
}
else
{
return
1
<<
(
7
+
button
);
}
}
}
test/java/beans/Introspector/Test8005065.java
0 → 100644
浏览文件 @
be1145fc
/*
* Copyright (c) 2012, 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 8005065
* @summary Tests that all arrays in JavaBeans are guarded
* @author Sergey Malenkov
*/
import
java.beans.DefaultPersistenceDelegate
;
import
java.beans.Encoder
;
import
java.beans.EventSetDescriptor
;
import
java.beans.ExceptionListener
;
import
java.beans.Expression
;
import
java.beans.Statement
;
import
java.beans.MethodDescriptor
;
import
java.beans.ParameterDescriptor
;
public
class
Test8005065
{
public
static
void
main
(
String
[]
args
)
{
testDefaultPersistenceDelegate
();
testEventSetDescriptor
();
testMethodDescriptor
();
testStatement
();
}
private
static
void
testDefaultPersistenceDelegate
()
{
Encoder
encoder
=
new
Encoder
();
String
[]
array
=
{
"array"
};
MyDPD
dpd
=
new
MyDPD
(
array
);
dpd
.
instantiate
(
dpd
,
encoder
);
array
[
0
]
=
null
;
dpd
.
instantiate
(
dpd
,
encoder
);
}
private
static
void
testEventSetDescriptor
()
{
try
{
MethodDescriptor
[]
array
=
{
new
MethodDescriptor
(
MyDPD
.
class
.
getMethod
(
"getArray"
))
};
EventSetDescriptor
descriptor
=
new
EventSetDescriptor
(
null
,
null
,
array
,
null
,
null
);
test
(
descriptor
.
getListenerMethodDescriptors
());
array
[
0
]
=
null
;
test
(
descriptor
.
getListenerMethodDescriptors
());
descriptor
.
getListenerMethodDescriptors
()[
0
]
=
null
;
test
(
descriptor
.
getListenerMethodDescriptors
());
}
catch
(
Exception
exception
)
{
throw
new
Error
(
"unexpected error"
,
exception
);
}
}
private
static
void
testMethodDescriptor
()
{
try
{
ParameterDescriptor
[]
array
=
{
new
ParameterDescriptor
()
};
MethodDescriptor
descriptor
=
new
MethodDescriptor
(
MyDPD
.
class
.
getMethod
(
"getArray"
),
array
);
test
(
descriptor
.
getParameterDescriptors
());
array
[
0
]
=
null
;
test
(
descriptor
.
getParameterDescriptors
());
descriptor
.
getParameterDescriptors
()[
0
]
=
null
;
test
(
descriptor
.
getParameterDescriptors
());
}
catch
(
Exception
exception
)
{
throw
new
Error
(
"unexpected error"
,
exception
);
}
}
private
static
void
testStatement
()
{
Object
[]
array
=
{
new
Object
()
};
Statement
statement
=
new
Statement
(
null
,
null
,
array
);
test
(
statement
.
getArguments
());
array
[
0
]
=
null
;
test
(
statement
.
getArguments
());
statement
.
getArguments
()[
0
]
=
null
;
test
(
statement
.
getArguments
());
}
private
static
<
T
>
void
test
(
T
[]
array
)
{
if
(
array
.
length
!=
1
)
{
throw
new
Error
(
"unexpected array length"
);
}
if
(
array
[
0
]
==
null
)
{
throw
new
Error
(
"unexpected array content"
);
}
}
public
static
class
MyDPD
extends
DefaultPersistenceDelegate
implements
ExceptionListener
{
private
final
String
[]
array
;
public
MyDPD
(
String
[]
array
)
{
super
(
array
);
this
.
array
=
array
;
}
public
Expression
instantiate
(
Object
instance
,
Encoder
encoder
)
{
encoder
.
setExceptionListener
(
this
);
return
super
.
instantiate
(
instance
,
encoder
);
}
public
String
[]
getArray
()
{
return
this
.
array
;
}
public
void
exceptionThrown
(
Exception
exception
)
{
throw
new
Error
(
"unexpected error"
,
exception
);
}
}
}
test/javax/swing/AncestorNotifier/7193219/bug7193219.java
浏览文件 @
be1145fc
...
...
@@ -30,6 +30,7 @@
import
java.io.*
;
import
javax.swing.*
;
import
javax.swing.plaf.metal.*
;
public
class
bug7193219
{
private
static
byte
[]
serializeGUI
()
{
...
...
@@ -73,6 +74,7 @@ public class bug7193219 {
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
UIManager
.
setLookAndFeel
(
new
MetalLookAndFeel
());
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
test/javax/swing/JFrame/4962534/bug4962534.html
0 → 100644
浏览文件 @
be1145fc
<html>
<!--
Copyright (c) 2012, 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 4962534
@summary JFrame dances very badly
@author dav@sparc.spb.su area=
@run applet bug4962534.html
-->
<head>
<title>
</title>
</head>
<body>
<h1>
bug4962534
<br>
Bug ID: 4962534
</h1>
<p>
This is an AUTOMATIC test, simply wait for completion
</p>
<APPLET
CODE=
"bug4962534.class"
WIDTH=
200
HEIGHT=
200
></APPLET>
</body>
</html>
test/javax/swing/JFrame/4962534/bug4962534.java
0 → 100644
浏览文件 @
be1145fc
/*
* Copyright (c) 2012, 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 4962534 7104594
@summary JFrame dances very badly
@author dav@sparc.spb.su area=
@run applet bug4962534.html
*/
import
java.applet.Applet
;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.util.Random
;
import
javax.swing.*
;
import
sun.awt.SunToolkit
;
public
class
bug4962534
extends
Applet
{
Robot
robot
;
volatile
Point
framePosition
;
volatile
Point
newFrameLocation
;
JFrame
frame
;
Rectangle
gcBounds
;
Component
titleComponent
;
JLayeredPane
lPane
;
volatile
boolean
titleFound
=
false
;
SunToolkit
toolkit
=
(
SunToolkit
)
Toolkit
.
getDefaultToolkit
();
public
static
Object
LOCK
=
new
Object
();
@Override
public
void
init
()
{
try
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
createAndShowGUI
();
}
});
}
catch
(
Exception
ex
)
{
throw
new
RuntimeException
(
"Init failed. "
+
ex
.
getMessage
());
}
}
//End init()
@Override
public
void
start
()
{
validate
();
try
{
setJLayeredPaneEDT
();
setTitleComponentEDT
();
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
throw
new
RuntimeException
(
"Test failed. "
+
ex
.
getMessage
());
}
if
(!
titleFound
)
{
throw
new
RuntimeException
(
"Test Failed. Unable to determine title's size."
);
}
Random
r
=
new
Random
();
for
(
int
iteration
=
0
;
iteration
<
10
;
iteration
++)
{
try
{
setFramePosEDT
();
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
throw
new
RuntimeException
(
"Test failed."
);
}
try
{
robot
=
new
Robot
();
robot
.
setAutoDelay
(
70
);
toolkit
.
realSync
();
robot
.
mouseMove
(
framePosition
.
x
+
getJFrameWidthEDT
()
/
2
,
framePosition
.
y
+
titleComponent
.
getHeight
()
/
2
);
robot
.
mousePress
(
InputEvent
.
BUTTON1_MASK
);
toolkit
.
realSync
();
gcBounds
=
GraphicsEnvironment
.
getLocalGraphicsEnvironment
().
getScreenDevices
()[
0
].
getConfigurations
()[
0
].
getBounds
();
robot
.
mouseMove
(
framePosition
.
x
+
getJFrameWidthEDT
()
/
2
,
framePosition
.
y
+
titleComponent
.
getHeight
()
/
2
);
toolkit
.
realSync
();
int
multier
=
gcBounds
.
height
/
2
-
10
;
//we will not go out the borders
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
robot
.
mouseMove
(
gcBounds
.
width
/
2
-
(
int
)
(
r
.
nextDouble
()
*
multier
),
gcBounds
.
height
/
2
-
(
int
)
(
r
.
nextDouble
()
*
multier
));
}
robot
.
mouseRelease
(
InputEvent
.
BUTTON1_MASK
);
toolkit
.
realSync
();
}
catch
(
AWTException
e
)
{
throw
new
RuntimeException
(
"Test Failed. AWTException thrown."
+
e
.
getMessage
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"Test Failed."
);
}
System
.
out
.
println
(
"Mouse lies in "
+
MouseInfo
.
getPointerInfo
().
getLocation
());
boolean
frameIsOutOfScreen
=
false
;
try
{
setNewFrameLocationEDT
();
System
.
out
.
println
(
"Now Frame lies in "
+
newFrameLocation
);
frameIsOutOfScreen
=
checkFrameIsOutOfScreenEDT
();
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
throw
new
RuntimeException
(
"Test Failed."
);
}
if
(
frameIsOutOfScreen
)
{
throw
new
RuntimeException
(
"Test failed. JFrame is out of screen."
);
}
}
//for iteration
System
.
out
.
println
(
"Test passed."
);
}
// start()
private
void
createAndShowGUI
()
{
try
{
UIManager
.
setLookAndFeel
(
"javax.swing.plaf.metal.MetalLookAndFeel"
);
}
catch
(
Exception
ex
)
{
throw
new
RuntimeException
(
ex
.
getMessage
());
}
JFrame
.
setDefaultLookAndFeelDecorated
(
true
);
frame
=
new
JFrame
(
"JFrame Dance Test"
);
frame
.
pack
();
frame
.
setSize
(
450
,
260
);
frame
.
setVisible
(
true
);
}
private
void
setJLayeredPaneEDT
()
throws
Exception
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
lPane
=
frame
.
getLayeredPane
();
System
.
out
.
println
(
"JFrame's LayeredPane "
+
lPane
);
}
});
}
private
void
setTitleComponentEDT
()
throws
Exception
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
for
(
int
j
=
0
;
j
<
lPane
.
getComponentsInLayer
(
JLayeredPane
.
FRAME_CONTENT_LAYER
.
intValue
()).
length
;
j
++)
{
titleComponent
=
lPane
.
getComponentsInLayer
(
JLayeredPane
.
FRAME_CONTENT_LAYER
.
intValue
())[
j
];
if
(
titleComponent
.
getClass
().
getName
().
equals
(
"javax.swing.plaf.metal.MetalTitlePane"
))
{
titleFound
=
true
;
break
;
}
}
}
});
}
private
void
setFramePosEDT
()
throws
Exception
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
framePosition
=
frame
.
getLocationOnScreen
();
}
});
}
private
boolean
checkFrameIsOutOfScreenEDT
()
throws
Exception
{
final
boolean
[]
result
=
new
boolean
[
1
];
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
newFrameLocation
.
x
>
gcBounds
.
width
||
newFrameLocation
.
x
<
0
||
newFrameLocation
.
y
>
gcBounds
.
height
||
newFrameLocation
.
y
<
0
)
{
result
[
0
]
=
true
;
}
}
});
return
result
[
0
];
}
private
void
setNewFrameLocationEDT
()
throws
Exception
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
newFrameLocation
=
new
Point
(
frame
.
getLocationOnScreen
().
x
+
frame
.
getWidth
()
/
2
,
frame
.
getLocationOnScreen
().
y
+
titleComponent
.
getHeight
()
/
2
);
}
});
}
private
int
getJFrameWidthEDT
()
throws
Exception
{
final
int
[]
result
=
new
int
[
1
];
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
result
[
0
]
=
frame
.
getWidth
();
}
});
return
result
[
0
];
}
}
// class
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录