Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
88bd89b6
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看板
提交
88bd89b6
编写于
3月 11, 2014
作者:
D
dmarkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8032872: [macosx] Cannot select from JComboBox in a JWindow
Reviewed-by: pchelko, ant
上级
7ea73c94
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
189 addition
and
5 deletion
+189
-5
src/macosx/classes/sun/lwawt/LWWindowPeer.java
src/macosx/classes/sun/lwawt/LWWindowPeer.java
+20
-4
test/java/awt/Mouse/MouseComboBoxTest/MouseComboBoxTest.java
test/java/awt/Mouse/MouseComboBoxTest/MouseComboBoxTest.java
+138
-0
test/java/awt/Window/Grab/GrabTest.java
test/java/awt/Window/Grab/GrabTest.java
+31
-1
未找到文件。
src/macosx/classes/sun/lwawt/LWWindowPeer.java
浏览文件 @
88bd89b6
/*
* Copyright (c) 2011, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 201
4
, 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
...
...
@@ -684,7 +684,7 @@ public class LWWindowPeer
public
void
notifyNCMouseDown
()
{
// Ungrab except for a click on a Dialog with the grabbing owner
if
(
grabbingWindow
!=
null
&&
grabbingWindow
!=
getOwnerFrameDialog
(
this
))
!
grabbingWindow
.
isOneOfOwnersOf
(
this
))
{
grabbingWindow
.
ungrab
();
}
...
...
@@ -779,7 +779,7 @@ public class LWWindowPeer
// Ungrab only if this window is not an owned window of the grabbing one.
if
(!
isGrabbing
()
&&
grabbingWindow
!=
null
&&
grabbingWindow
!=
getOwnerFrameDialog
(
this
))
!
grabbingWindow
.
isOneOfOwnersOf
(
this
))
{
grabbingWindow
.
ungrab
();
}
...
...
@@ -1232,6 +1232,17 @@ public class LWWindowPeer
changeFocusedWindow
(
activate
,
null
);
}
private
boolean
isOneOfOwnersOf
(
LWWindowPeer
peer
)
{
Window
owner
=
(
peer
!=
null
?
peer
.
getTarget
().
getOwner
()
:
null
);
while
(
owner
!=
null
)
{
if
((
LWWindowPeer
)
owner
.
getPeer
()
==
this
)
{
return
true
;
}
owner
=
owner
.
getOwner
();
}
return
false
;
}
/*
* Changes focused window on java level.
*/
...
...
@@ -1263,7 +1274,7 @@ public class LWWindowPeer
// - when the opposite (gaining focus) window is an owned/owner window.
// - for a simple window in any case.
if
(!
becomesFocused
&&
(
isGrabbing
()
||
getOwnerFrameDialog
(
grabbingWindow
)
==
this
))
(
isGrabbing
()
||
this
.
isOneOfOwnersOf
(
grabbingWindow
)
))
{
if
(
focusLog
.
isLoggable
(
PlatformLogger
.
Level
.
FINE
))
{
focusLog
.
fine
(
"ungrabbing on "
+
grabbingWindow
);
...
...
@@ -1282,6 +1293,11 @@ public class LWWindowPeer
postEvent
(
windowEvent
);
}
/*
* Retrieves the owner of the peer.
* Note: this method returns the owner which can be activated, (i.e. the instance
* of Frame or Dialog may be returned).
*/
static
LWWindowPeer
getOwnerFrameDialog
(
LWWindowPeer
peer
)
{
Window
owner
=
(
peer
!=
null
?
peer
.
getTarget
().
getOwner
()
:
null
);
while
(
owner
!=
null
&&
!(
owner
instanceof
Frame
||
owner
instanceof
Dialog
))
{
...
...
test/java/awt/Mouse/MouseComboBoxTest/MouseComboBoxTest.java
0 → 100644
浏览文件 @
88bd89b6
/*
* 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
* @bug 8032872
* @summary Tests JComboBox selection via the mouse
* @author Dmitry Markov
*/
import
sun.awt.SunToolkit
;
import
javax.swing.*
;
import
javax.swing.plaf.basic.BasicComboPopup
;
import
javax.swing.plaf.basic.ComboPopup
;
import
javax.swing.plaf.metal.MetalComboBoxUI
;
import
javax.swing.plaf.metal.MetalLookAndFeel
;
import
java.awt.*
;
import
java.awt.event.InputEvent
;
import
java.awt.event.KeyEvent
;
public
class
MouseComboBoxTest
{
private
static
final
String
[]
items
=
{
"One"
,
"Two"
,
"Three"
,
"Four"
,
"Five"
};
private
static
SunToolkit
toolkit
=
null
;
private
static
Robot
robot
=
null
;
private
static
JFrame
frame
=
null
;
private
static
JComboBox
comboBox
=
null
;
private
static
MyComboBoxUI
comboBoxUI
=
null
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
toolkit
=
(
SunToolkit
)
Toolkit
.
getDefaultToolkit
();
robot
=
new
Robot
();
robot
.
setAutoDelay
(
50
);
UIManager
.
setLookAndFeel
(
new
MetalLookAndFeel
());
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
createAndShowGUI
();
}
});
toolkit
.
realSync
();
for
(
int
i
=
0
;
i
<
items
.
length
;
i
++)
{
// Open popup
robot
.
keyPress
(
KeyEvent
.
VK_DOWN
);
robot
.
keyRelease
(
KeyEvent
.
VK_DOWN
);
toolkit
.
realSync
();
Point
point
=
getItemPointToClick
(
i
);
robot
.
mouseMove
(
point
.
x
,
point
.
y
);
robot
.
mousePress
(
InputEvent
.
BUTTON1_DOWN_MASK
);
robot
.
mouseRelease
(
InputEvent
.
BUTTON1_DOWN_MASK
);
toolkit
.
realSync
();
if
(
i
!=
getSelectedIndex
())
{
throw
new
RuntimeException
(
"Test Failed! Incorrect value of selected index = "
+
getSelectedIndex
()
+
", expected value = "
+
i
);
}
}
}
private
static
Point
getItemPointToClick
(
final
int
item
)
throws
Exception
{
final
Point
[]
result
=
new
Point
[
1
];
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
BasicComboPopup
popup
=
(
BasicComboPopup
)
comboBoxUI
.
getComboPopup
();
Point
point
=
popup
.
getLocationOnScreen
();
Dimension
size
=
popup
.
getSize
();
int
step
=
size
.
height
/
items
.
length
;
point
.
x
+=
size
.
width
/
2
;
point
.
y
+=
step
/
2
+
step
*
item
;
result
[
0
]
=
point
;
}
});
return
result
[
0
];
}
private
static
int
getSelectedIndex
()
throws
Exception
{
final
int
[]
result
=
new
int
[
1
];
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
result
[
0
]
=
comboBox
.
getSelectedIndex
();
}
});
return
result
[
0
];
}
private
static
void
createAndShowGUI
()
{
frame
=
new
JFrame
(
"MouseComboBoxTest"
);
comboBox
=
new
JComboBox
(
items
);
comboBox
.
setEditable
(
true
);
comboBoxUI
=
new
MyComboBoxUI
();
comboBox
.
setUI
(
comboBoxUI
);
frame
.
pack
();
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
frame
.
setVisible
(
true
);
JWindow
window
=
new
JWindow
(
frame
);
window
.
add
(
comboBox
);
window
.
pack
();
window
.
setVisible
(
true
);
}
private
static
class
MyComboBoxUI
extends
MetalComboBoxUI
{
public
ComboPopup
getComboPopup
()
{
return
popup
;
}
}
}
test/java/awt/Window/Grab/GrabTest.java
浏览文件 @
88bd89b6
/*
* Copyright (c) 2012, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 201
4
, 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
...
...
@@ -38,7 +38,10 @@ import test.java.awt.regtesthelpers.Util;
public
class
GrabTest
{
private
static
Frame
f
;
private
static
Frame
f1
;
private
static
Frame
frame
;
private
static
Window
w
;
private
static
Window
window1
;
private
static
Window
window2
;
private
static
Button
b
;
private
static
Robot
robot
;
...
...
@@ -96,6 +99,15 @@ public class GrabTest {
f
.
setVisible
(
true
);
w
.
setVisible
(
true
);
frame
=
new
Frame
();
window1
=
new
Window
(
frame
);
window1
.
setBounds
(
0
,
0
,
100
,
100
);
window1
.
setBackground
(
Color
.
blue
);
window2
=
new
Window
(
window1
);
window2
.
setBounds
(
0
,
0
,
50
,
50
);
window2
.
setBackground
(
Color
.
green
);
tk
=
(
sun
.
awt
.
SunToolkit
)
Toolkit
.
getDefaultToolkit
();
try
{
...
...
@@ -194,6 +206,24 @@ public class GrabTest {
passed
=
false
;
System
.
err
.
println
(
"Failure: [7] Window disposal didn't cause ungrab"
);
}
ungrabbed
=
false
;
// 8. Check that mouse click on subwindow does not cause ungrab
frame
.
setVisible
(
true
);
window1
.
setVisible
(
true
);
window2
.
setVisible
(
true
);
Util
.
waitForIdle
(
robot
);
tk
.
grab
(
window1
);
Util
.
clickOnComp
(
window2
,
robot
);
Util
.
waitForIdle
(
robot
);
if
(
ungrabbed
)
{
passed
=
false
;
System
.
err
.
println
(
"Failure: [8] Press on the subwindow caused ungrab"
);
}
if
(
passed
)
{
System
.
out
.
println
(
"Test passed."
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录