Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
049b650b
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看板
提交
049b650b
编写于
4月 10, 2012
作者:
R
rupashka
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7158712: Synth Property "ComboBox.popupInsets" is ignored
Reviewed-by: alexp
上级
c6f27a8e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
167 addition
and
6 deletion
+167
-6
src/share/classes/javax/swing/plaf/synth/SynthComboPopup.java
...share/classes/javax/swing/plaf/synth/SynthComboPopup.java
+26
-6
test/javax/swing/plaf/synth/7158712/bug7158712.java
test/javax/swing/plaf/synth/7158712/bug7158712.java
+112
-0
test/javax/swing/regtesthelpers/Util.java
test/javax/swing/regtesthelpers/Util.java
+29
-0
未找到文件。
src/share/classes/javax/swing/plaf/synth/SynthComboPopup.java
浏览文件 @
049b650b
...
...
@@ -26,13 +26,9 @@
package
javax.swing.plaf.synth
;
import
javax.swing.*
;
import
javax.swing.
event.*
;
import
javax.swing.plaf.basic.
*
;
import
javax.swing.
plaf.ComboBoxUI
;
import
javax.swing.plaf.basic.
BasicComboPopup
;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.beans.PropertyChangeListener
;
import
java.beans.PropertyChangeEvent
;
import
java.io.Serializable
;
/**
...
...
@@ -52,6 +48,7 @@ class SynthComboPopup extends BasicComboPopup {
*
* @see #createList
*/
@Override
protected
void
configureList
()
{
list
.
setFont
(
comboBox
.
getFont
()
);
list
.
setCellRenderer
(
comboBox
.
getRenderer
()
);
...
...
@@ -67,4 +64,27 @@ class SynthComboPopup extends BasicComboPopup {
}
installListListeners
();
}
/**
* @inheritDoc
*
* Overridden to take into account any popup insets specified in
* SynthComboBoxUI
*/
@Override
protected
Rectangle
computePopupBounds
(
int
px
,
int
py
,
int
pw
,
int
ph
)
{
ComboBoxUI
ui
=
comboBox
.
getUI
();
if
(
ui
instanceof
SynthComboBoxUI
)
{
SynthComboBoxUI
sui
=
(
SynthComboBoxUI
)
ui
;
if
(
sui
.
popupInsets
!=
null
)
{
Insets
i
=
sui
.
popupInsets
;
return
super
.
computePopupBounds
(
px
+
i
.
left
,
py
+
i
.
top
,
pw
-
i
.
left
-
i
.
right
,
ph
-
i
.
top
-
i
.
bottom
);
}
}
return
super
.
computePopupBounds
(
px
,
py
,
pw
,
ph
);
}
}
test/javax/swing/plaf/synth/7158712/bug7158712.java
0 → 100644
浏览文件 @
049b650b
/*
* 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 7158712
@summary Synth Property "ComboBox.popupInsets" is ignored
@library ../../../regtesthelpers
@author Pavel Porvatov
*/
import
javax.swing.*
;
import
javax.swing.plaf.basic.BasicComboPopup
;
import
javax.swing.plaf.synth.SynthLookAndFeel
;
import
java.awt.*
;
import
java.awt.event.InputEvent
;
import
java.io.ByteArrayInputStream
;
import
java.util.concurrent.Callable
;
public
class
bug7158712
{
private
static
final
String
SYNTH_XML
=
"<synth>"
+
" <style id=\"all\">"
+
" <font name=\"Dialog\" size=\"12\"/>"
+
" </style>"
+
" <bind style=\"all\" type=\"REGION\" key=\".*\"/>"
+
" <style id=\"arrowButton\">"
+
" <property key=\"ArrowButton.size\" type=\"integer\" value=\"18\"/>"
+
" </style>"
+
" <bind style=\"arrowButton\" type=\"region\" key=\"ArrowButton\"/>"
+
" <style id=\"comboBox\">"
+
" <property key=\"ComboBox.popupInsets\" type=\"insets\" value=\"-5 -5 5 -5\"/>"
+
" </style>"
+
" <bind style=\"comboBox\" type=\"region\" key=\"ComboBox\"/>"
+
"</synth>"
;
private
static
JComboBox
<
String
>
comboBox
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Robot
robot
=
new
Robot
();
robot
.
setAutoDelay
(
500
);
SynthLookAndFeel
laf
=
new
SynthLookAndFeel
();
laf
.
load
(
new
ByteArrayInputStream
(
SYNTH_XML
.
getBytes
(
"UTF8"
)),
bug7158712
.
class
);
UIManager
.
setLookAndFeel
(
laf
);
EventQueue
.
invokeLater
(
new
Runnable
()
{
public
void
run
()
{
comboBox
=
new
JComboBox
<>(
new
String
[]{
"Very Looooooooooooooooooooong Text Item 1"
,
"Item 2"
});
JFrame
frame
=
new
JFrame
();
frame
.
add
(
comboBox
,
BorderLayout
.
NORTH
);
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
frame
.
setSize
(
new
Dimension
(
400
,
300
));
frame
.
setLocationRelativeTo
(
null
);
frame
.
setVisible
(
true
);
}
});
Point
comboBoxLocation
=
Util
.
invokeOnEDT
(
new
Callable
<
Point
>()
{
@Override
public
Point
call
()
throws
Exception
{
return
comboBox
.
getLocationOnScreen
();
}
});
robot
.
mouseMove
(
comboBoxLocation
.
x
,
comboBoxLocation
.
y
);
robot
.
mousePress
(
InputEvent
.
BUTTON1_MASK
);
robot
.
mouseRelease
(
InputEvent
.
BUTTON1_MASK
);
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
BasicComboPopup
popup
=
(
BasicComboPopup
)
comboBox
.
getAccessibleContext
().
getAccessibleChild
(
0
);
Point
popupPoint
=
popup
.
getLocationOnScreen
();
Point
comboBoxPoint
=
comboBox
.
getLocationOnScreen
();
if
(
comboBoxPoint
.
x
-
5
!=
popupPoint
.
x
||
comboBoxPoint
.
y
+
comboBox
.
getHeight
()
-
5
!=
popupPoint
.
y
)
{
throw
new
RuntimeException
(
"Invalid popup coordinates. Popup location: "
+
popupPoint
+
", comboBox location: "
+
comboBoxPoint
);
}
System
.
out
.
println
(
"Test bug7158712 passed"
);
}
});
}
}
test/javax/swing/regtesthelpers/Util.java
浏览文件 @
049b650b
...
...
@@ -24,8 +24,10 @@
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.image.BufferedImage
;
import
java.util.ArrayList
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.concurrent.Callable
;
/**
* <p>This class contains utilities useful for regression testing.
...
...
@@ -153,4 +155,31 @@ public class Util {
robot
.
keyRelease
(
keys
[
i
]);
}
}
/**
* Invokes the <code>task</code> on the EDT thread.
*
* @return result of the <code>task</code>
*/
public
static
<
T
>
T
invokeOnEDT
(
final
Callable
<
T
>
task
)
throws
Exception
{
final
List
<
T
>
result
=
new
ArrayList
<>(
1
);
final
Exception
[]
exception
=
new
Exception
[
1
];
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
result
.
add
(
task
.
call
());
}
catch
(
Exception
e
)
{
exception
[
0
]
=
e
;
}
}
});
if
(
exception
[
0
]
!=
null
)
{
throw
exception
[
0
];
}
return
result
.
get
(
0
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录