Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
069614f0
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看板
提交
069614f0
编写于
4月 30, 2015
作者:
B
bae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8073001: Java's system LnF on OS X: editable JComboBoxes are being rendered incorrectly
Reviewed-by: alexp, serb
上级
3bb17d8a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
343 addition
and
15 deletion
+343
-15
src/macosx/classes/com/apple/laf/AquaComboBoxUI.java
src/macosx/classes/com/apple/laf/AquaComboBoxUI.java
+15
-14
src/macosx/classes/com/apple/laf/AquaTextFieldBorder.java
src/macosx/classes/com/apple/laf/AquaTextFieldBorder.java
+1
-1
test/javax/swing/plaf/aqua/CustomComboBoxFocusTest.java
test/javax/swing/plaf/aqua/CustomComboBoxFocusTest.java
+327
-0
未找到文件。
src/macosx/classes/com/apple/laf/AquaComboBoxUI.java
浏览文件 @
069614f0
...
...
@@ -151,20 +151,6 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable {
editor
.
getDocument
().
addDocumentListener
(
this
);
}
@Override
public
void
focusGained
(
final
FocusEvent
e
)
{
if
(
arrowButton
!=
null
)
{
arrowButton
.
repaint
();
}
}
@Override
public
void
focusLost
(
final
FocusEvent
e
)
{
if
(
arrowButton
!=
null
)
{
arrowButton
.
repaint
();
}
}
@Override
public
void
changedUpdate
(
final
DocumentEvent
e
)
{
editorTextChanged
();
...
...
@@ -250,6 +236,16 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable {
*/
protected
FocusListener
createFocusListener
()
{
return
new
BasicComboBoxUI
.
FocusHandler
()
{
@Override
public
void
focusGained
(
FocusEvent
e
)
{
super
.
focusGained
(
e
);
if
(
arrowButton
!=
null
)
{
arrowButton
.
repaint
();
}
}
@Override
public
void
focusLost
(
final
FocusEvent
e
)
{
hasFocus
=
false
;
if
(!
e
.
isTemporary
())
{
...
...
@@ -262,6 +258,10 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable {
if
(
ac
!=
null
)
{
ac
.
firePropertyChange
(
AccessibleContext
.
ACCESSIBLE_STATE_PROPERTY
,
AccessibleState
.
FOCUSED
,
null
);
}
if
(
arrowButton
!=
null
)
{
arrowButton
.
repaint
();
}
}
};
}
...
...
@@ -429,6 +429,7 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable {
if
(
editor
!=
null
)
{
final
Rectangle
editorRect
=
rectangleForCurrentValue
();
editorRect
.
width
+=
4
;
editorRect
.
height
+=
1
;
editor
.
setBounds
(
editorRect
);
}
}
...
...
src/macosx/classes/com/apple/laf/AquaTextFieldBorder.java
浏览文件 @
069614f0
...
...
@@ -124,7 +124,7 @@ public class AquaTextFieldBorder extends AquaBorder {
public
Insets
getBorderInsets
(
final
Component
c
)
{
if
(!(
c
instanceof
JTextComponent
)
||
c
.
isOpaque
())
return
new
InsetsUIResource
(
3
,
7
,
3
,
7
);
return
new
InsetsUIResource
(
6
,
7
,
6
,
7
);
return
new
InsetsUIResource
(
5
,
5
,
5
,
5
);
}
protected
static
State
getStateFor
(
final
JTextComponent
jc
)
{
...
...
test/javax/swing/plaf/aqua/CustomComboBoxFocusTest.java
0 → 100644
浏览文件 @
069614f0
/*
* Copyright (c) 2015, 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 8073001
@summary Test verifies that combo box with custom editor renders
focus ring around arrow button correctly.
@run main CustomComboBoxFocusTest
*/
import
java.awt.AWTException
;
import
java.awt.Component
;
import
java.awt.GridLayout
;
import
java.awt.Point
;
import
java.awt.Rectangle
;
import
java.awt.Robot
;
import
java.awt.event.ActionListener
;
import
java.awt.event.FocusEvent
;
import
java.awt.event.FocusListener
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.IOException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.concurrent.CountDownLatch
;
import
javax.imageio.ImageIO
;
import
javax.swing.ComboBoxEditor
;
import
javax.swing.JComboBox
;
import
javax.swing.JFrame
;
import
javax.swing.JLabel
;
import
javax.swing.JPanel
;
import
javax.swing.JTextField
;
import
javax.swing.SwingUtilities
;
public
class
CustomComboBoxFocusTest
{
private
static
CustomComboBoxFocusTest
test
=
null
;
public
static
void
main
(
String
[]
args
)
{
try
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
test
=
new
CustomComboBoxFocusTest
();
}
});
}
catch
(
InterruptedException
|
InvocationTargetException
e
)
{
throw
new
RuntimeException
(
"Test failed."
,
e
);
}
SwingUtilities
.
invokeLater
(
test
.
init
);
try
{
System
.
out
.
println
(
"Wait for screenshots..."
);
test
.
testDone
.
await
();
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
"Test failed."
,
e
);
}
System
.
out
.
println
(
"Compare screenshots..."
);
if
(!
test
.
match
())
{
throw
new
RuntimeException
(
"Test failed."
);
}
System
.
out
.
println
(
"Test passed."
);
}
private
final
JComboBox
<
String
>
ref
=
new
JComboBox
<
String
>()
{
public
String
toString
()
{
return
"reference"
;
}
};
private
final
JComboBox
<
String
>
custom
=
new
JComboBox
<
String
>()
{
public
String
toString
()
{
return
"custom"
;
}
};
private
final
JFrame
frame
;
private
CountDownLatch
testDone
=
new
CountDownLatch
(
1
);
private
Robot
robot
;
public
CustomComboBoxFocusTest
()
{
frame
=
new
JFrame
(
System
.
getProperty
(
"java.version"
));
try
{
robot
=
new
Robot
(
frame
.
getGraphicsConfiguration
().
getDevice
());
}
catch
(
AWTException
e
)
{
throw
new
RuntimeException
(
"Test failed."
,
e
);
}
}
private
boolean
match
()
{
final
BufferedImage
a
=
captureRef
.
img
;
final
BufferedImage
b
=
captureCustom
.
img
;
final
int
w
=
Math
.
min
(
a
.
getWidth
(),
b
.
getWidth
());
final
int
h
=
Math
.
min
(
a
.
getHeight
(),
b
.
getHeight
());
for
(
int
y
=
0
;
y
<
h
;
y
++)
{
for
(
int
x
=
0
;
x
<
w
;
x
++)
{
if
(
a
.
getRGB
(
x
,
y
)
!=
b
.
getRGB
(
x
,
y
))
{
return
false
;
}
}
}
return
true
;
}
private
JComboBox
<
String
>
getReference
()
{
return
ref
;
}
private
JComboBox
<
String
>
getCustom
()
{
return
custom
;
}
private
JFrame
getFrame
()
{
return
frame
;
}
private
static
abstract
class
Step
implements
Runnable
{
final
public
void
run
()
{
doStep
();
final
Step
next
=
nextStep
();
if
(
next
!=
null
)
{
SwingUtilities
.
invokeLater
(
next
);
}
}
public
abstract
void
doStep
();
public
abstract
Step
nextStep
();
}
private
final
Step
init
=
new
Step
()
{
public
void
doStep
()
{
final
JFrame
f
=
getFrame
();
final
JPanel
p
=
new
JPanel
(
new
GridLayout
(
4
,
1
,
20
,
20
));
JComboBox
<
String
>
r
=
getReference
();
r
.
setEditable
(
true
);
r
.
addItem
(
"One"
);
JComboBox
<
String
>
c
=
getCustom
();
c
.
setEditable
(
true
);
c
.
addItem
(
"One"
);
final
ComboBoxEditor
e
=
new
ComboBoxEditor
()
{
private
JTextField
text
=
new
JTextField
();
@Override
public
Component
getEditorComponent
()
{
return
this
.
text
;
}
@Override
public
void
setItem
(
Object
o
)
{
text
.
setText
(
o
==
null
?
""
:
o
.
toString
());
}
@Override
public
Object
getItem
()
{
return
text
.
getText
();
}
@Override
public
void
selectAll
()
{
text
.
selectAll
();
}
@Override
public
void
addActionListener
(
ActionListener
actionListener
)
{
text
.
addActionListener
(
actionListener
);
}
@Override
public
void
removeActionListener
(
ActionListener
actionListener
)
{
text
.
removeActionListener
(
actionListener
);
}
};
c
.
setEditor
(
e
);
p
.
add
(
new
JLabel
(
"Reference"
));
p
.
add
(
r
);
p
.
add
(
c
);
p
.
add
(
new
JLabel
(
"Custom"
));
f
.
add
(
p
);
f
.
pack
();
f
.
setVisible
(
true
);
}
public
Step
nextStep
()
{
return
focusRef
;
}
};
private
class
FocusStep
extends
Step
{
private
final
JComboBox
<
String
>
target
;
private
final
Step
focusHandler
;
private
final
Step
next
;
public
FocusStep
(
JComboBox
<
String
>
t
,
Step
h
,
Step
n
)
{
target
=
t
;
focusHandler
=
h
;
next
=
n
;
}
public
void
doStep
()
{
System
.
out
.
println
(
"Request focus on "
+
target
);
final
Component
c
=
target
.
getEditor
().
getEditorComponent
();
c
.
addFocusListener
(
new
FocusListener
()
{
@Override
public
void
focusGained
(
FocusEvent
e
)
{
SwingUtilities
.
invokeLater
(
focusHandler
);
}
@Override
public
void
focusLost
(
FocusEvent
e
)
{
}
});
c
.
requestFocus
();
}
public
Step
nextStep
()
{
return
next
;
}
}
private
class
CaptureStep
extends
Step
{
private
final
JComboBox
<
String
>
target
;
private
BufferedImage
img
;
private
String
fname
;
private
final
Step
next
;
private
final
int
timeout
=
2000
;
public
CaptureStep
(
JComboBox
<
String
>
t
,
String
name
,
Step
n
)
{
target
=
t
;
next
=
n
;
fname
=
name
;
}
public
void
doStep
()
{
try
{
Thread
.
sleep
(
timeout
);
}
catch
(
InterruptedException
e
)
{
}
System
.
out
.
println
(
"Capture sceeenshot of "
+
target
);
Rectangle
bounds
=
target
.
getBounds
();
Point
p
=
target
.
getLocationOnScreen
();
System
.
out
.
println
(
"Target bounds: "
+
bounds
);
System
.
out
.
println
(
"Target location: "
+
p
);
bounds
.
x
=
p
.
x
;
bounds
.
y
=
p
.
y
;
img
=
robot
.
createScreenCapture
(
bounds
);
try
{
ImageIO
.
write
(
img
,
"PNG"
,
new
File
(
fname
+
".png"
));
}
catch
(
IOException
ioe
)
{
ioe
.
printStackTrace
();
}
}
public
Step
nextStep
()
{
return
next
;
}
}
private
final
Step
done
=
new
Step
()
{
public
void
doStep
()
{
JFrame
f
=
getFrame
();
if
(
f
!=
null
)
{
f
.
dispose
();
}
System
.
out
.
println
(
"Done"
);
testDone
.
countDown
();
}
public
Step
nextStep
()
{
return
null
;
}
};
private
final
CaptureStep
captureCustom
=
new
CaptureStep
(
getCustom
(),
"cb_custom"
,
done
);
private
final
FocusStep
focusCustom
=
new
FocusStep
(
getCustom
(),
captureCustom
,
null
);
private
final
CaptureStep
captureRef
=
new
CaptureStep
(
getReference
(),
"cb_ref"
,
focusCustom
);
private
final
FocusStep
focusRef
=
new
FocusStep
(
getReference
(),
captureRef
,
null
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录