Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
950b0a98
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
3
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
950b0a98
编写于
1月 23, 2009
作者:
M
malenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
4222508: JColorChooser ignores setEnabled() function call
Reviewed-by: peterz, rupashka
上级
de0f2e09
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
105 addition
and
6 deletion
+105
-6
src/share/classes/javax/swing/colorchooser/AbstractColorChooserPanel.java
...s/javax/swing/colorchooser/AbstractColorChooserPanel.java
+14
-0
src/share/classes/javax/swing/colorchooser/ColorChooserPanel.java
...e/classes/javax/swing/colorchooser/ColorChooserPanel.java
+17
-0
src/share/classes/javax/swing/colorchooser/DefaultSwatchChooserPanel.java
...s/javax/swing/colorchooser/DefaultSwatchChooserPanel.java
+9
-6
test/javax/swing/JColorChooser/Test4222508.html
test/javax/swing/JColorChooser/Test4222508.html
+9
-0
test/javax/swing/JColorChooser/Test4222508.java
test/javax/swing/JColorChooser/Test4222508.java
+56
-0
未找到文件。
src/share/classes/javax/swing/colorchooser/AbstractColorChooserPanel.java
浏览文件 @
950b0a98
...
...
@@ -26,6 +26,8 @@
package
javax.swing.colorchooser
;
import
java.awt.*
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
javax.swing.*
;
/**
...
...
@@ -47,6 +49,15 @@ import javax.swing.*;
*/
public
abstract
class
AbstractColorChooserPanel
extends
JPanel
{
private
final
PropertyChangeListener
enabledListener
=
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
event
)
{
Object
value
=
event
.
getNewValue
();
if
(
value
instanceof
Boolean
)
{
setEnabled
((
Boolean
)
value
);
}
}
};
/**
*
*/
...
...
@@ -142,6 +153,8 @@ public abstract class AbstractColorChooserPanel extends JPanel {
throw
new
RuntimeException
(
"This chooser panel is already installed"
);
}
chooser
=
enclosingChooser
;
chooser
.
addPropertyChangeListener
(
"enabled"
,
enabledListener
);
setEnabled
(
chooser
.
isEnabled
());
buildChooser
();
updateChooser
();
}
...
...
@@ -151,6 +164,7 @@ public abstract class AbstractColorChooserPanel extends JPanel {
* If override this, be sure to call <code>super</code>.
*/
public
void
uninstallChooserPanel
(
JColorChooser
enclosingChooser
)
{
chooser
.
removePropertyChangeListener
(
"enabled"
,
enabledListener
);
chooser
=
null
;
}
...
...
src/share/classes/javax/swing/colorchooser/ColorChooserPanel.java
浏览文件 @
950b0a98
...
...
@@ -26,6 +26,8 @@
package
javax.swing.colorchooser
;
import
java.awt.Color
;
import
java.awt.Component
;
import
java.awt.Container
;
import
java.awt.GridBagConstraints
;
import
java.awt.GridBagLayout
;
import
java.beans.PropertyChangeEvent
;
...
...
@@ -56,6 +58,21 @@ final class ColorChooserPanel extends AbstractColorChooserPanel implements Prope
ValueFormatter
.
init
(
6
,
true
,
this
.
text
);
}
@Override
public
void
setEnabled
(
boolean
enabled
)
{
super
.
setEnabled
(
enabled
);
setEnabled
(
this
,
enabled
);
}
private
static
void
setEnabled
(
Container
container
,
boolean
enabled
)
{
for
(
Component
component
:
container
.
getComponents
())
{
component
.
setEnabled
(
enabled
);
if
(
component
instanceof
Container
)
{
setEnabled
((
Container
)
component
,
enabled
);
}
}
}
@Override
public
void
updateChooser
()
{
Color
color
=
getColorFromModel
();
...
...
src/share/classes/javax/swing/colorchooser/DefaultSwatchChooserPanel.java
浏览文件 @
950b0a98
...
...
@@ -170,7 +170,6 @@ class DefaultSwatchChooserPanel extends AbstractColorChooserPanel {
superHolder
.
add
(
mainHolder
,
gbc
);
gbc
.
insets
=
oldInsets
;
recentSwatchPanel
.
addMouseListener
(
recentSwatchListener
);
recentSwatchPanel
.
setInheritsPopupMenu
(
true
);
JPanel
recentHolder
=
new
JPanel
(
new
BorderLayout
()
);
recentHolder
.
setBorder
(
border
);
...
...
@@ -212,18 +211,22 @@ class DefaultSwatchChooserPanel extends AbstractColorChooserPanel {
class
RecentSwatchListener
extends
MouseAdapter
implements
Serializable
{
public
void
mousePressed
(
MouseEvent
e
)
{
if
(
isEnabled
())
{
Color
color
=
recentSwatchPanel
.
getColorForLocation
(
e
.
getX
(),
e
.
getY
());
setSelectedColor
(
color
);
}
}
}
class
MainSwatchListener
extends
MouseAdapter
implements
Serializable
{
public
void
mousePressed
(
MouseEvent
e
)
{
if
(
isEnabled
())
{
Color
color
=
swatchPanel
.
getColorForLocation
(
e
.
getX
(),
e
.
getY
());
setSelectedColor
(
color
);
recentSwatchPanel
.
setMostRecentColor
(
color
);
}
}
}
}
...
...
test/javax/swing/JColorChooser/Test4222508.html
0 → 100644
浏览文件 @
950b0a98
<html>
<body>
Use the check box above the color chooser to disable it.
You could not choose a color using by the disable color chooser.
<applet
width=
"600"
height=
"400"
code=
"Test4222508.class"
>
</applet>
</body>
</html>
test/javax/swing/JColorChooser/Test4222508.java
0 → 100644
浏览文件 @
950b0a98
/*
* Copyright 2008 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 4222508
* @summary Tests the color chooser disabling
* @author Sergey Malenkov
* @run applet/manual=yesno Test4222508.html
*/
import
java.awt.BorderLayout
;
import
java.awt.event.ItemEvent
;
import
java.awt.event.ItemListener
;
import
javax.swing.JApplet
;
import
javax.swing.JCheckBox
;
import
javax.swing.JColorChooser
;
public
final
class
Test4222508
extends
JApplet
implements
ItemListener
{
private
JCheckBox
checkbox
;
private
JColorChooser
chooser
;
@Override
public
void
init
()
{
this
.
chooser
=
new
JColorChooser
();
this
.
checkbox
=
new
JCheckBox
(
"Enable the color chooser below"
,
true
);
this
.
checkbox
.
addItemListener
(
this
);
add
(
BorderLayout
.
NORTH
,
this
.
checkbox
);
add
(
BorderLayout
.
CENTER
,
this
.
chooser
);
}
public
void
itemStateChanged
(
ItemEvent
event
)
{
this
.
chooser
.
setEnabled
(
this
.
checkbox
.
isSelected
());
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录