Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
9630b10f
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看板
提交
9630b10f
编写于
12月 25, 2009
作者:
P
peterz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6860438: [Nimbus] Code to globally set slider's thumb background doesn't work as specified
Reviewed-by: rupashka
上级
8df45b05
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
293 addition
and
54 deletion
+293
-54
src/share/classes/javax/swing/MultiUIDefaults.java
src/share/classes/javax/swing/MultiUIDefaults.java
+33
-54
test/javax/swing/MultiUIDefaults/4300666/bug4300666.html
test/javax/swing/MultiUIDefaults/4300666/bug4300666.html
+28
-0
test/javax/swing/MultiUIDefaults/4300666/bug4300666.java
test/javax/swing/MultiUIDefaults/4300666/bug4300666.java
+40
-0
test/javax/swing/MultiUIDefaults/4331767/bug4331767.java
test/javax/swing/MultiUIDefaults/4331767/bug4331767.java
+94
-0
test/javax/swing/MultiUIDefaults/Test6860438.java
test/javax/swing/MultiUIDefaults/Test6860438.java
+98
-0
未找到文件。
src/share/classes/javax/swing/MultiUIDefaults.java
浏览文件 @
9630b10f
...
...
@@ -27,6 +27,7 @@ package javax.swing;
import
java.util.Enumeration
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Locale
;
import
java.util.Map.Entry
;
import
java.util.Set
;
...
...
@@ -89,11 +90,7 @@ class MultiUIDefaults extends UIDefaults
@Override
public
int
size
()
{
int
n
=
super
.
size
();
for
(
UIDefaults
table
:
tables
)
{
n
+=
(
table
!=
null
)
?
table
.
size
()
:
0
;
}
return
n
;
return
entrySet
().
size
();
}
@Override
...
...
@@ -104,40 +101,26 @@ class MultiUIDefaults extends UIDefaults
@Override
public
Enumeration
<
Object
>
keys
()
{
Enumeration
[]
enums
=
new
Enumeration
[
1
+
tables
.
length
];
enums
[
0
]
=
super
.
keys
();
for
(
int
i
=
0
;
i
<
tables
.
length
;
i
++)
{
UIDefaults
table
=
tables
[
i
];
if
(
table
!=
null
)
{
enums
[
i
+
1
]
=
table
.
keys
();
}
}
return
new
MultiUIDefaultsEnumerator
(
enums
);
return
new
MultiUIDefaultsEnumerator
(
MultiUIDefaultsEnumerator
.
Type
.
KEYS
,
entrySet
());
}
@Override
public
Enumeration
<
Object
>
elements
()
{
Enumeration
[]
enums
=
new
Enumeration
[
1
+
tables
.
length
];
enums
[
0
]
=
super
.
elements
();
for
(
int
i
=
0
;
i
<
tables
.
length
;
i
++)
{
UIDefaults
table
=
tables
[
i
];
if
(
table
!=
null
)
{
enums
[
i
+
1
]
=
table
.
elements
();
}
}
return
new
MultiUIDefaultsEnumerator
(
enums
);
return
new
MultiUIDefaultsEnumerator
(
MultiUIDefaultsEnumerator
.
Type
.
ELEMENTS
,
entrySet
());
}
@Override
public
Set
<
Entry
<
Object
,
Object
>>
entrySet
()
{
Set
<
Entry
<
Object
,
Object
>>
set
=
new
HashSet
<
Entry
<
Object
,
Object
>>();
if
(
tables
==
null
)
return
set
;
for
(
UIDefaults
table
:
tables
)
{
if
(
table
!=
null
)
{
set
.
addAll
(
table
.
entrySet
());
for
(
int
i
=
tables
.
length
-
1
;
i
>=
0
;
i
--)
{
if
(
tables
[
i
]
!=
null
)
{
set
.
addAll
(
tables
[
i
].
entrySet
());
}
}
set
.
addAll
(
super
.
entrySet
());
return
set
;
}
...
...
@@ -152,50 +135,46 @@ class MultiUIDefaults extends UIDefaults
private
static
class
MultiUIDefaultsEnumerator
implements
Enumeration
<
Object
>
{
Enumeration
[]
enums
;
int
n
=
0
;
public
static
enum
Type
{
KEYS
,
ELEMENTS
};
private
Iterator
<
Entry
<
Object
,
Object
>>
iterator
;
private
Type
type
;
MultiUIDefaultsEnumerator
(
Enumeration
[]
enums
)
{
this
.
enums
=
enums
;
MultiUIDefaultsEnumerator
(
Type
type
,
Set
<
Entry
<
Object
,
Object
>>
entries
)
{
this
.
type
=
type
;
this
.
iterator
=
entries
.
iterator
();
}
public
boolean
hasMoreElements
()
{
for
(
int
i
=
n
;
i
<
enums
.
length
;
i
++)
{
Enumeration
e
=
enums
[
i
];
if
((
e
!=
null
)
&&
(
e
.
hasMoreElements
()))
{
return
true
;
}
}
return
false
;
return
iterator
.
hasNext
();
}
public
Object
nextElement
()
{
for
(;
n
<
enums
.
length
;
n
++
)
{
Enumeration
e
=
enums
[
n
]
;
if
((
e
!=
null
)
&&
(
e
.
hasMoreElements
()))
{
return
e
.
nextElement
()
;
switch
(
type
)
{
case
KEYS:
return
iterator
.
next
().
getKey
()
;
case
ELEMENTS:
return
iterator
.
next
().
getValue
();
default
:
return
null
;
}
}
return
null
;
}
}
@Override
public
Object
remove
(
Object
key
)
{
Object
value
=
super
.
remove
(
key
);
if
(
value
!=
null
)
{
return
value
;
Object
value
=
null
;
for
(
int
i
=
tables
.
length
-
1
;
i
>=
0
;
i
--)
{
if
(
tables
[
i
]
!=
null
)
{
Object
v
=
tables
[
i
].
remove
(
key
);
if
(
v
!=
null
)
{
value
=
v
;
}
}
for
(
UIDefaults
table
:
tables
)
{
value
=
(
table
!=
null
)
?
table
.
remove
(
key
)
:
null
;
if
(
value
!=
null
)
{
return
value
;
}
Object
v
=
super
.
remove
(
key
);
if
(
v
!=
null
)
{
value
=
v
;
}
return
null
;
return
value
;
}
@Override
...
...
test/javax/swing/MultiUIDefaults/4300666/bug4300666.html
0 → 100644
浏览文件 @
9630b10f
<!--
Copyright 2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
CA 95054 USA or visit www.sun.com if you need additional information or
have any questions.
-->
<html>
<body>
<applet
code=
"bug4300666.class"
width=
200
height=
200
></applet>
</body>
</html>
test/javax/swing/MultiUIDefaults/4300666/bug4300666.java
0 → 100644
浏览文件 @
9630b10f
/*
* Copyright 2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
@bug 4300666
@summary Printing UIDefaults throws NoSuchElementExcept
@author Andrey Pikalev
@run applet bug4300666.html
*/
import
javax.swing.*
;
public
class
bug4300666
extends
JApplet
{
public
void
init
()
{
UIDefaults
d
=
UIManager
.
getDefaults
();
d
.
toString
();
}
}
test/javax/swing/MultiUIDefaults/4331767/bug4331767.java
0 → 100644
浏览文件 @
9630b10f
/*
* Copyright 2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
@bug 4331767
@summary Tests that custom implementation of UIDefaults.getUIError() is
called when an UI error occurs
@author Peter Zhelezniakov
@run main bug4331767
*/
import
javax.swing.*
;
import
javax.swing.plaf.metal.MetalLookAndFeel
;
import
java.util.Locale
;
public
class
bug4331767
{
private
static
boolean
passed
=
false
;
public
static
void
main
(
String
[]
argv
)
{
try
{
UIManager
.
setLookAndFeel
(
new
BrokenLookAndFeel
());
}
catch
(
Exception
e
)
{
throw
new
Error
(
"Failed to set BrokenLookAndFeel, cannot test"
,
e
);
}
// This should call BrokenUIDefaults.getUIError()
new
JButton
();
if
(!
passed
)
{
throw
new
RuntimeException
(
"Failed: Custom getUIError() not called"
);
}
}
static
class
BrokenUIDefaults
extends
UIDefaults
{
UIDefaults
defaults
;
public
BrokenUIDefaults
(
UIDefaults
def
)
{
defaults
=
def
;
}
public
Object
get
(
Object
key
)
{
if
(
"ButtonUI"
.
equals
(
key
))
{
System
.
err
.
println
(
"[II] Called BrokenUIDefaults.get(Object)"
);
return
"a nonexistent class"
;
}
return
defaults
.
get
(
key
);
}
public
Object
get
(
Object
key
,
Locale
l
)
{
if
(
"ButtonUI"
.
equals
(
key
))
{
System
.
err
.
println
(
"[II] Called BrokenUIDefaults.get(Object, Locale)"
);
return
"a nonexistent class"
;
}
return
defaults
.
get
(
key
,
l
);
}
protected
void
getUIError
(
String
msg
)
{
System
.
err
.
println
(
"[II] BrokenUIDefaults.getUIError() called, test passes"
);
passed
=
true
;
}
}
static
class
BrokenLookAndFeel
extends
MetalLookAndFeel
{
UIDefaults
defaults
;
public
BrokenLookAndFeel
()
{
defaults
=
new
BrokenUIDefaults
(
super
.
getDefaults
());
}
public
UIDefaults
getDefaults
()
{
return
defaults
;
}
}
}
test/javax/swing/MultiUIDefaults/Test6860438.java
0 → 100644
浏览文件 @
9630b10f
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
@bug 6860438
@summary Tests various MultiUIDefaults methods
@author Peter Zhelezniakov
@run main Test6860438
*/
import
java.util.Enumeration
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
javax.swing.UIManager
;
public
class
Test6860438
{
static
final
String
KEY
=
"Test6860438.key"
;
static
final
String
VALUE
=
"Test6860438.value"
;
void
check
(
Object
key
,
Object
value
,
boolean
present
,
int
size
)
{
check
(
UIManager
.
get
(
key
)
==
value
,
"UIManager.get()"
);
check
(
UIManager
.
getDefaults
().
size
()
==
size
,
"MultiUIDefaults.size()"
);
checkEnumeration
(
UIManager
.
getDefaults
().
keys
(),
key
,
present
,
"MultiUIDefaults.keys()"
);
checkEnumeration
(
UIManager
.
getDefaults
().
elements
(),
value
,
present
,
"MultiUIDefaults.elements()"
);
// check MultiUIDefaults.entrySet()
boolean
found
=
false
;
Set
<
Entry
<
Object
,
Object
>>
entries
=
UIManager
.
getDefaults
().
entrySet
();
for
(
Entry
<
Object
,
Object
>
e:
entries
)
{
if
(
e
.
getKey
()
==
key
)
{
check
(
e
.
getValue
()
==
value
,
"MultiUIDefaults.entrySet()"
);
found
=
true
;
}
}
check
(
found
==
present
,
"MultiUIDefaults.entrySet()"
);
}
void
checkEnumeration
(
Enumeration
<
Object
>
e
,
Object
elem
,
boolean
present
,
String
error
)
{
boolean
found
=
false
;
while
(
e
.
hasMoreElements
())
{
if
(
e
.
nextElement
()
==
elem
)
{
found
=
true
;
}
}
check
(
found
==
present
,
error
);
}
void
check
(
boolean
condition
,
String
methodName
)
{
if
(!
condition
)
{
throw
new
RuntimeException
(
methodName
+
" failed"
);
}
}
void
test
()
{
int
size
=
UIManager
.
getDefaults
().
size
();
// create a new value, size increases
UIManager
.
getLookAndFeelDefaults
().
put
(
KEY
,
VALUE
);
check
(
KEY
,
VALUE
,
true
,
size
+
1
);
// override the value, size remains the same
UIManager
.
put
(
KEY
,
VALUE
);
check
(
KEY
,
VALUE
,
true
,
size
+
1
);
// remove the value, size decreases
UIManager
.
getDefaults
().
remove
(
KEY
);
check
(
KEY
,
null
,
false
,
size
);
}
public
static
void
main
(
String
[]
args
)
{
new
Test6860438
().
test
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录