Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
40300171
D
dragonwell11
项目概览
openanolis
/
dragonwell11
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell11
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
40300171
编写于
2月 04, 2020
作者:
S
serb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8225126: Test SetBoundsPaintTest.html faild on Windows when desktop is scaled
Reviewed-by: jdv
上级
b865ad05
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
129 addition
and
58 deletion
+129
-58
src/java.desktop/windows/classes/sun/awt/windows/WChoicePeer.java
....desktop/windows/classes/sun/awt/windows/WChoicePeer.java
+9
-11
src/java.desktop/windows/native/libawt/windows/awt_Choice.cpp
...java.desktop/windows/native/libawt/windows/awt_Choice.cpp
+9
-11
test/jdk/java/awt/Choice/RemoveAllShrinkTest/RemoveAllShrinkTest.java
...a/awt/Choice/RemoveAllShrinkTest/RemoveAllShrinkTest.java
+46
-36
test/jdk/java/awt/Choice/SetBoundsPaintTest/SetBoundsPaintTest.java
...ava/awt/Choice/SetBoundsPaintTest/SetBoundsPaintTest.java
+65
-0
未找到文件。
src/java.desktop/windows/classes/sun/awt/windows/WChoicePeer.java
浏览文件 @
40300171
/*
* Copyright (c) 1996, 20
18
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 20
20
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -22,14 +22,19 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package
sun.awt.windows
;
import
java.awt.*
;
import
java.awt.peer.*
;
import
java.awt.Choice
;
import
java.awt.Component
;
import
java.awt.Dimension
;
import
java.awt.FontMetrics
;
import
java.awt.Window
;
import
java.awt.event.ItemEvent
;
import
java.awt.event.WindowAdapter
;
import
java.awt.event.WindowEvent
;
import
java.awt.event.WindowListener
;
import
java.awt.
event.WindowAdapt
er
;
import
java.awt.
peer.ChoicePe
er
;
import
sun.awt.AWTAccessor
;
import
sun.awt.SunToolkit
;
...
...
@@ -154,12 +159,5 @@ final class WChoicePeer extends WComponentPeer implements ChoicePeer {
});
}
int
getDropDownHeight
()
{
Choice
c
=
(
Choice
)
target
;
FontMetrics
fm
=
getFontMetrics
(
c
.
getFont
());
int
maxItems
=
Math
.
min
(
c
.
getItemCount
(),
8
);
return
fm
.
getHeight
()
*
maxItems
;
}
native
void
closeList
();
}
src/java.desktop/windows/native/libawt/windows/awt_Choice.cpp
浏览文件 @
40300171
/*
* Copyright (c) 1996, 20
18
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 20
20
, 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
...
...
@@ -177,8 +177,8 @@ AwtChoice* AwtChoice::Create(jobject peer, jobject parent) {
* Fix: Set the Choice to its actual size in the component.
*/
::
GetClientRect
(
c
->
GetHWnd
(),
&
rc
);
env
->
SetIntField
(
target
,
AwtComponent
::
widthID
,
(
jint
)
rc
.
right
);
env
->
SetIntField
(
target
,
AwtComponent
::
heightID
,
(
jint
)
rc
.
bottom
);
env
->
SetIntField
(
target
,
AwtComponent
::
widthID
,
c
->
ScaleDownX
(
rc
.
right
)
);
env
->
SetIntField
(
target
,
AwtComponent
::
heightID
,
c
->
ScaleDownY
(
rc
.
bottom
)
);
if
(
IS_WINXP
)
{
::
SendMessage
(
c
->
GetHWnd
(),
CB_SETMINVISIBLE
,
(
WPARAM
)
MINIMUM_NUMBER_OF_VISIBLE_ITEMS
,
0
);
...
...
@@ -228,13 +228,11 @@ int AwtChoice::GetTotalHeight()
{
int
dropHeight
=
GetDropDownHeight
();
int
fieldHeight
=
GetFieldHeight
();
int
totalHeight
;
// border on drop-down portion is always non-3d (so don't use SM_CYEDGE)
int
borderHeight
=
::
GetSystemMetrics
(
SM_CYBORDER
);
int
borderHeight
=
ScaleDownY
(
::
GetSystemMetrics
(
SM_CYBORDER
)
);
// total height = drop down height + field height + top+bottom drop down border lines
totalHeight
=
dropHeight
+
fieldHeight
+
borderHeight
*
2
;
return
totalHeight
;
return
dropHeight
+
fieldHeight
+
borderHeight
*
2
;
}
// Recalculate and set the drop-down height for the Choice.
...
...
@@ -244,7 +242,7 @@ void AwtChoice::ResetDropDownHeight()
::
GetWindowRect
(
GetHWnd
(),
&
rcWindow
);
// resize the drop down to accommodate added/removed items
int
totalHeight
=
GetTotalHeight
(
);
int
totalHeight
=
ScaleUpY
(
GetTotalHeight
()
);
::
SetWindowPos
(
GetHWnd
(),
NULL
,
0
,
0
,
rcWindow
.
right
-
rcWindow
.
left
,
totalHeight
,
SWP_NOACTIVATE
|
SWP_NOMOVE
|
SWP_NOZORDER
);
...
...
@@ -305,11 +303,11 @@ void AwtChoice::Reshape(int x, int y, int w, int h)
BOOL
bReshape
=
true
;
if
(
awtParent
!=
NULL
)
{
::
GetWindowRect
(
GetHWnd
(),
&
rc
);
int
oldW
=
rc
.
right
-
rc
.
left
;
int
oldW
=
ScaleDownX
(
rc
.
right
-
rc
.
left
)
;
RECT
parentRc
;
::
GetWindowRect
(
awtParent
->
GetHWnd
(),
&
parentRc
);
int
oldX
=
rc
.
left
-
parentRc
.
left
;
int
oldY
=
rc
.
top
-
parentRc
.
top
;
int
oldX
=
ScaleDownX
(
rc
.
left
-
parentRc
.
left
)
;
int
oldY
=
ScaleDownY
(
rc
.
top
-
parentRc
.
top
)
;
bReshape
=
(
x
!=
oldX
||
y
!=
oldY
||
w
!=
oldW
);
}
...
...
test/jdk/java/awt/Choice/RemoveAllShrinkTest/RemoveAllShrinkTest.java
浏览文件 @
40300171
/*
* Copyright (c) 2014, 20
16
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 20
20
, 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
...
...
@@ -24,62 +24,72 @@
/*
@test
@key headful
@bug 4851798 8041896
@bug 4851798 8041896
8225126
@summary Tests Choice List shrinks after removeAll
@run main RemoveAllShrinkTest
*/
import
java.awt.*
;
import
java.awt.event.*
;
import
java.awt.BorderLayout
;
import
java.awt.Choice
;
import
java.awt.Color
;
import
java.awt.Frame
;
import
java.awt.Panel
;
import
java.awt.Point
;
import
java.awt.Robot
;
import
java.awt.event.InputEvent
;
public
class
RemoveAllShrinkTest
{
public
static
void
main
(
String
[]
args
)
{
Frame
f
=
new
Frame
();
Choice
choice
=
new
Choice
();
try
{
Choice
choice
=
new
Choice
();
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
choice
.
addItem
(
"Item "
+
i
);
}
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
choice
.
addItem
(
"Item "
+
i
);
}
f
.
add
(
choice
,
BorderLayout
.
NORTH
);
Panel
panel
=
new
Panel
();
panel
.
setBackground
(
Color
.
RED
);
f
.
add
(
panel
);
f
.
add
(
choice
,
BorderLayout
.
NORTH
);
Panel
panel
=
new
Panel
();
panel
.
setBackground
(
Color
.
RED
);
f
.
add
(
panel
);
f
.
setSize
(
200
,
200
);
f
.
setVisible
(
true
);
f
.
toFront
();
f
.
setSize
(
200
,
200
);
f
.
setLocationRelativeTo
(
null
);
f
.
setVisible
(
true
);
f
.
toFront
();
choice
.
removeAll
();
choice
.
removeAll
();
try
{
Robot
robot
=
new
Robot
();
robot
.
setAutoWaitForIdle
(
true
);
robot
.
setAutoDelay
(
50
);
try
{
Robot
robot
=
new
Robot
();
robot
.
setAutoWaitForIdle
(
true
);
robot
.
setAutoDelay
(
50
);
robot
.
waitForIdle
();
Thread
.
sleep
(
200
);
robot
.
waitForIdle
();
Thread
.
sleep
(
200
);
Point
pt
=
choice
.
getLocationOnScreen
();
robot
.
mouseMove
(
pt
.
x
+
choice
.
getWidth
()
-
choice
.
getHeight
()
/
2
,
pt
.
y
+
choice
.
getHeight
()
/
2
);
robot
.
mousePress
(
InputEvent
.
BUTTON1_MASK
);
robot
.
mouseRelease
(
InputEvent
.
BUTTON1_MASK
);
Point
pt
=
choice
.
getLocationOnScreen
();
robot
.
mouseMove
(
pt
.
x
+
choice
.
getWidth
()
-
choice
.
getHeight
()
/
2
,
pt
.
y
+
choice
.
getHeight
()
/
2
);
robot
.
mousePress
(
InputEvent
.
BUTTON1_MASK
);
robot
.
mouseRelease
(
InputEvent
.
BUTTON1_MASK
);
Thread
.
sleep
(
400
);
Thread
.
sleep
(
400
);
Point
pt1
=
panel
.
getLocationOnScreen
();
Point
pt1
=
panel
.
getLocationOnScreen
();
Color
color
=
robot
.
getPixelColor
(
pt1
.
x
+
panel
.
getWidth
()
/
2
,
pt1
.
y
+
panel
.
getHeight
()
/
2
);
Color
color
=
robot
.
getPixelColor
(
pt1
.
x
+
panel
.
getWidth
()
/
2
,
pt1
.
y
+
panel
.
getHeight
()
/
2
);
if
(!
color
.
equals
(
Color
.
RED
))
{
throw
new
RuntimeException
(
"RemoveAllShrinkTest failed. "
+
color
);
if
(!
color
.
equals
(
Color
.
RED
))
{
throw
new
RuntimeException
(
"RemoveAllShrinkTest failed. "
+
color
);
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"The test was not completed.\n\n"
+
e
);
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"The test was not completed.\n\n"
+
e
);
}
finally
{
f
.
dispose
(
);
}
}
}
...
...
test/jdk/java/awt/Choice/SetBoundsPaintTest/SetBoundsPaintTest.java
0 → 100644
浏览文件 @
40300171
/*
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.awt.Choice
;
import
java.awt.Frame
;
import
java.awt.Graphics
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.TimeUnit
;
/**
* @test
* @bug 4790927 4783342 4930678 8225126
* @key headful
* @summary Tests Choice doesn't flash
*/
public
final
class
SetBoundsPaintTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
CountDownLatch
go
=
new
CountDownLatch
(
10
);
Choice
choice
=
new
Choice
();
choice
.
addItem
(
"first"
);
choice
.
addItem
(
"second"
);
Frame
frame
=
new
Frame
()
{
@Override
public
void
paint
(
Graphics
g
)
{
g
.
fillRect
(
0
,
0
,
200
,
200
);
choice
.
setBounds
(
50
,
50
,
180
,
30
);
go
.
countDown
();
}
};
try
{
frame
.
setLayout
(
null
);
frame
.
add
(
choice
);
frame
.
setSize
(
300
,
300
);
frame
.
setLocationRelativeTo
(
null
);
frame
.
setVisible
(
true
);
if
(
go
.
await
(
5
,
TimeUnit
.
SECONDS
))
{
throw
new
RuntimeException
(
"recursive setBounds paint"
);
}
}
finally
{
frame
.
dispose
();
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录