Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
a99de557
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看板
提交
a99de557
编写于
10月 03, 2012
作者:
B
bagiras
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7171412: awt Choice doesn't fire ItemStateChange when selecting item after select() call
Reviewed-by: art, denis
上级
46f9a432
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
173 addition
and
9 deletion
+173
-9
src/macosx/native/sun/awt/InitIDs.m
src/macosx/native/sun/awt/InitIDs.m
+4
-1
src/share/classes/java/awt/Choice.java
src/share/classes/java/awt/Choice.java
+14
-1
src/solaris/native/sun/awt/initIDs.c
src/solaris/native/sun/awt/initIDs.c
+6
-0
src/windows/native/sun/windows/awt_Choice.cpp
src/windows/native/sun/windows/awt_Choice.cpp
+21
-6
src/windows/native/sun/windows/awt_Choice.h
src/windows/native/sun/windows/awt_Choice.h
+0
-1
test/java/awt/Choice/ItemStateChangeTest/ItemStateChangeTest.java
...a/awt/Choice/ItemStateChangeTest/ItemStateChangeTest.java
+128
-0
未找到文件。
src/macosx/native/sun/awt/InitIDs.m
浏览文件 @
a99de557
...
...
@@ -47,7 +47,10 @@ JNIEXPORT void JNICALL Java_java_awt_CheckboxMenuItem_initIDs
{
}
JNIEXPORT void JNICALL Java_java_awt_Choice_initIDs
(JNIEnv *env, jclass cls)
{
}
JNIEXPORT void JNICALL Java_java_awt_Color_initIDs
(JNIEnv *env, jclass cls)
...
...
src/share/classes/java/awt/Choice.java
浏览文件 @
a99de557
...
...
@@ -106,6 +106,15 @@ public class Choice extends Component implements ItemSelectable, Accessible {
*/
private
static
final
long
serialVersionUID
=
-
4075310674757313071L
;
static
{
/* ensure that the necessary native libraries are loaded */
Toolkit
.
loadLibraries
();
/* initialize JNI field and method ids */
if
(!
GraphicsEnvironment
.
isHeadless
())
{
initIDs
();
}
}
/**
* Creates a new choice menu. The menu initially has no items in it.
* <p>
...
...
@@ -711,6 +720,10 @@ public class Choice extends Component implements ItemSelectable, Accessible {
}
}
/**
* Initialize JNI field and method IDs
*/
private
static
native
void
initIDs
();
/////////////////
// Accessibility support
...
...
src/solaris/native/sun/awt/initIDs.c
浏览文件 @
a99de557
...
...
@@ -88,6 +88,12 @@ Java_java_awt_CheckboxMenuItem_initIDs
{
}
JNIEXPORT
void
JNICALL
Java_java_awt_Choice_initIDs
(
JNIEnv
*
env
,
jclass
clazz
)
{
}
JNIEXPORT
void
JNICALL
Java_java_awt_Dimension_initIDs
(
JNIEnv
*
env
,
jclass
clazz
)
...
...
src/windows/native/sun/windows/awt_Choice.cpp
浏览文件 @
a99de557
...
...
@@ -79,6 +79,10 @@ BOOL AwtChoice::sm_isMouseMoveInList = FALSE;
static
const
UINT
MINIMUM_NUMBER_OF_VISIBLE_ITEMS
=
8
;
namespace
{
jfieldID
selectedIndexID
;
}
/*************************************************************************
* AwtChoice class methods
*/
...
...
@@ -86,7 +90,6 @@ static const UINT MINIMUM_NUMBER_OF_VISIBLE_ITEMS = 8;
AwtChoice
::
AwtChoice
()
{
m_hList
=
NULL
;
m_listDefWindowProc
=
NULL
;
m_selectedItem
=
-
1
;
}
LPCTSTR
AwtChoice
::
GetClassName
()
{
...
...
@@ -102,7 +105,6 @@ void AwtChoice::Dispose() {
AwtChoice
*
AwtChoice
::
Create
(
jobject
peer
,
jobject
parent
)
{
JNIEnv
*
env
=
(
JNIEnv
*
)
JNU_GetEnv
(
jvm
,
JNI_VERSION_1_2
);
jobject
target
=
NULL
;
...
...
@@ -438,10 +440,14 @@ LRESULT CALLBACK AwtChoice::ListWindowProc(HWND hwnd, UINT message,
MsgRouting
AwtChoice
::
WmNotify
(
UINT
notifyCode
)
{
if
(
notifyCode
==
CBN_SELCHANGE
)
{
int
selectedItem
=
(
int
)
SendMessage
(
CB_GETCURSEL
);
if
(
selectedItem
!=
CB_ERR
&&
m_selectedItem
!=
selectedItem
){
m_selectedItem
=
selectedItem
;
DoCallback
(
"handleAction"
,
"(I)V"
,
selectedItem
);
int
selectedIndex
=
(
int
)
SendMessage
(
CB_GETCURSEL
);
JNIEnv
*
env
=
(
JNIEnv
*
)
JNU_GetEnv
(
jvm
,
JNI_VERSION_1_2
);
jobject
target
=
GetTarget
(
env
);
int
previousIndex
=
env
->
GetIntField
(
target
,
selectedIndexID
);
if
(
selectedIndex
!=
CB_ERR
&&
selectedIndex
!=
previousIndex
){
DoCallback
(
"handleAction"
,
"(I)V"
,
selectedIndex
);
}
}
else
if
(
notifyCode
==
CBN_DROPDOWN
)
{
...
...
@@ -695,6 +701,15 @@ done:
extern
"C"
{
JNIEXPORT
void
JNICALL
Java_java_awt_Choice_initIDs
(
JNIEnv
*
env
,
jclass
cls
)
{
TRY
;
selectedIndexID
=
env
->
GetFieldID
(
cls
,
"selectedIndex"
,
"I"
);
DASSERT
(
selectedIndexID
);
CATCH_BAD_ALLOC
;
}
/*
* Class: sun_awt_windows_WChoicePeer
* Method: select
...
...
src/windows/native/sun/windows/awt_Choice.h
浏览文件 @
a99de557
...
...
@@ -94,7 +94,6 @@ private:
static
BOOL
sm_isMouseMoveInList
;
HWND
m_hList
;
WNDPROC
m_listDefWindowProc
;
int
m_selectedItem
;
static
LRESULT
CALLBACK
ListWindowProc
(
HWND
hwnd
,
UINT
message
,
WPARAM
wParam
,
LPARAM
lParam
);
};
...
...
test/java/awt/Choice/ItemStateChangeTest/ItemStateChangeTest.java
0 → 100644
浏览文件 @
a99de557
/*
* 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 7171412
@summary awt Choice doesn't fire ItemStateChange when selecting item after select() call
@author Oleg Pekhovskiy: area=awt-choice
@library ../../regtesthelpers
@build Util
@run main ItemStateChangeTest
*/
import
test.java.awt.regtesthelpers.Util
;
import
java.awt.*
;
import
java.awt.event.*
;
import
sun.awt.OSInfo
;
public
class
ItemStateChangeTest
extends
Frame
{
int
events
=
0
;
public
static
void
main
(
String
args
[])
{
new
ItemStateChangeTest
();
}
public
ItemStateChangeTest
()
{
if
(
OSInfo
.
getOSType
()
!=
OSInfo
.
OSType
.
WINDOWS
)
{
return
;
}
try
{
final
Robot
robot
=
new
Robot
();
robot
.
setAutoDelay
(
20
);
Util
.
waitForIdle
(
robot
);
addWindowListener
(
new
WindowAdapter
()
{
@Override
public
void
windowClosing
(
WindowEvent
e
)
{
System
.
exit
(
0
);
}
});
final
Choice
choice
=
new
Choice
();
choice
.
add
(
"A"
);
choice
.
add
(
"B"
);
choice
.
addItemListener
(
new
ItemListener
()
{
@Override
public
void
itemStateChanged
(
ItemEvent
e
)
{
++
events
;
}
});
add
(
choice
);
setSize
(
200
,
150
);
setVisible
(
true
);
toFront
();
// choose B
int
y
=
chooseB
(
choice
,
robot
,
16
);
// reset to A
choice
.
select
(
0
);
robot
.
delay
(
20
);
Util
.
waitForIdle
(
robot
);
// choose B again
chooseB
(
choice
,
robot
,
y
);
if
(
events
==
2
)
{
System
.
out
.
println
(
"Test passed!"
);
}
else
{
throw
new
RuntimeException
(
"Test failed!"
);
}
}
catch
(
AWTException
e
)
{
throw
new
RuntimeException
(
"Test failed!"
);
}
}
final
int
chooseB
(
Choice
choice
,
Robot
robot
,
int
y
)
{
while
(
true
)
{
// show drop-down list
Util
.
clickOnComp
(
choice
,
robot
);
Util
.
waitForIdle
(
robot
);
Point
pt
=
choice
.
getLocationOnScreen
();
Dimension
size
=
choice
.
getSize
();
// try to click B item
robot
.
mouseMove
(
pt
.
x
+
size
.
width
/
2
,
pt
.
y
+
size
.
height
+
y
);
Util
.
waitForIdle
(
robot
);
robot
.
mousePress
(
InputEvent
.
BUTTON1_DOWN_MASK
);
Util
.
waitForIdle
(
robot
);
robot
.
mouseRelease
(
InputEvent
.
BUTTON1_DOWN_MASK
);
Util
.
waitForIdle
(
robot
);
if
(
choice
.
getSelectedIndex
()
==
1
)
{
break
;
}
// if it's not B, position cursor lower by 2 pixels and try again
y
+=
2
;
}
return
y
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录