public abstract class BasicLookAndFeel extends LookAndFeel implements Serializable
每个BasicLookAndFeel
提供的ComponentUI
s推导其行为从缺省值表。除非另有说明,每个在这个文件包设置默认他们使用ComponentUI
实现。除非另有说明,默认安装在时间installUI
被调用,并遵循了LookAndFeel
安装默认的建议。
警告:序列化该类的对象与以后的Swing版本不兼容。当前的序列化支持适用于短期贮藏或RMI运行相同Swing版本的应用程序之间。为1.4,为所有JavaBeans™长期存储的支持已被添加到java.beans
包。请看XMLEncoder
。
Constructor and Description |
---|
BasicLookAndFeel() |
Modifier and Type | Method and Description |
---|---|
protected Action |
createAudioAction(Object key)
创建并返回一个用来播放声音
Action 。
|
protected ActionMap |
getAudioActionMap()
返回一个包含此
ActionMap 看音频的行为和感觉。
|
UIDefaults |
getDefaults()
返回外观和感觉默认值。
|
protected void |
initClassDefaults(UIDefaults table)
填充
uiClassID
table 映射到UI类的完全限定名。
|
protected void |
initComponentDefaults(UIDefaults table)
填充
table 为基本看违约和感觉。
|
void |
initialize()
初始化的外观和感觉。
|
protected void |
initSystemColorDefaults(UIDefaults table)
填充颜色
table 系统。
|
protected void |
loadSystemColors(UIDefaults table, String[] systemColors, boolean useNative)
填充
table 在
systemColors 的
name-color 对。
|
protected void |
playSound(Action audioAction)
如果有必要,在调用
actionPerformed
audioAction 播放声音。
|
void |
uninitialize()
反初始化的外观和感觉。
|
getDescription, getDesktopPropertyValue, getDisabledIcon, getDisabledSelectedIcon, getID, getLayoutStyle, getName, getSupportsWindowDecorations, installBorder, installColors, installColorsAndFont, installProperty, isNativeLookAndFeel, isSupportedLookAndFeel, loadKeyBindings, makeComponentInputMap, makeIcon, makeInputMap, makeKeyBindings, provideErrorFeedback, toString, uninstallBorder
public UIDefaults getDefaults()
UIDefaults
是由调用顺序,
initClassDefaults
,
initSystemColorDefaults
和
initComponentDefaults
。
虽然这种方法是公共的,它必须由UIManager
调用当外观设置为当前的外观和感觉,initialize
后被调用。
public void initialize()
UIManager
时调用的外观和感觉是安装作为当前的外观和感觉。这个方法被调用之前调用
getDefaults
UIManager
。此方法用于执行任何初始化的外观和感觉。子类应该做他们需要的任何一次性的设置,而不是在一个静态的初始化,因为外观和感觉类的对象可以被加载就发现
isSupportedLookAndFeel()
返回
false
。
public void uninitialize()
UIManager
外观当卸载。例如,
UIManager.setLookAndFeel
调用此当外观改变。
子类可以选择在这里释放一些资源。
protected void initClassDefaults(UIDefaults table)
uiClassID
table
映射到UI类的完全限定名。对于一个特定的值
"javax.swing.plaf.basic.Basic + uiClassID"
uiClassID
。例如,对于
uiClassID
TreeUI
值
"javax.swing.plaf.basic.BasicTreeUI"
。
table
-
UIDefaults
审的项目添加到
null
table
NullPointerException
LookAndFeel
,
getDefaults()
protected void initSystemColorDefaults(UIDefaults table)
table
系统。这就产生了
name-color
对数组并调用
loadSystemColors
。
这个名字是一个String
对应的一SystemColor
类的静态SystemColor
字段名称。一个名字的颜色对是对每一个这样的SystemColor
领域创造了。
的color
对应一个六String
理解Color.decode
。例如,其中的name-color
对"desktop"-"#005C5C"
。这对应于SystemColor
场desktop
,有new Color(0x005C5C)
颜色值。
下面显示了两个的name-color
对:
namecolorpairs =新的字符串字符串[ ] [ ] {“桌面”、“# 005c5c”,“activecaption”、“# 000080”};loadsystemcolors(表,namecolorpairs,isnativelookandfeel());如前所述,这个调用的
loadSystemColors
与供应
table
和
name-color
对阵列。对
loadSystemColors
的最后一个参数指示的领域
SystemColor
价值应该用。该方法通过
isNativeLookAndFeel()
价值为
loadSystemColors
最后的争论。
table
-
UIDefaults
对象的值添加到
null
table
NullPointerException
SystemColor
,
getDefaults()
,
loadSystemColors(javax.swing.UIDefaults, java.lang.String[], boolean)
protected void loadSystemColors(UIDefaults table, String[] systemColors, boolean useNative)
table
在
systemColors
的
name-color
对。参考
initSystemColorDefaults(UIDefaults)
对
systemColors
格式细节。
一个条目被添加到table
中每个systemColors
的name-color
对。进入关键的name-color
对name
。
该项的值对应的name-color
对color
。该条目的值以两种方式计算。每种方法的价值始终是一个ColorUIResource
。
如果useNative
是false
的color
,利用Color.decode
转换成Color
创建String
。如果decode
不能转换成Color
String
(NumberFormatException
扔)然后用ColorUIResource
黑。
如果useNative
是true
,的color
是字段的值在SystemColor
具有相同名字的name-color
对name
。如果该字段是无效的,一个ColorUIResource
黑用。
table
-
UIDefaults
对象的值添加到
systemColors
-
name-color
对阵列中所描述的
initSystemColorDefaults(UIDefaults)
useNative
-颜色是否是从
SystemColor
或
Color.decode
获得
NullPointerException
-如果
systemColors
是
null
;或
systemColors
不是空的,和
table
是
null
;或一对的
name-color
名字是
null
;或
useNative
是
false
的一
name-color
对
colors
是
null
ArrayIndexOutOfBoundsException
-如果
useNative
是
false
和
systemColors.length
是奇数
initSystemColorDefaults(javax.swing.UIDefaults)
,
SystemColor
,
Color.decode(String)
protected void initComponentDefaults(UIDefaults table)
table
为基本看违约和感觉。
table
-
UIDefaults
加值
null
table
NullPointerException
protected ActionMap getAudioActionMap()
ActionMap
看音频的行为和感觉。
返回的ActionMap
包含Actions
体现提供听觉线索的能力。这些听觉线索映射到用户和系统的活动,可能是有用的最终用户知道的(如一个对话框出现)。
在适当的时候,该ComponentUI
负责获取Action
走出ActionMap
通过playSound
。
该方法首先查找ActionMap
使用关键"AuditoryCues.actionMap"
默认。
如果该值是non-null
,它返回。如果默认值是null
"AuditoryCues.actionMap"
和默认值是一个"AuditoryCues.cueList"
non-null
,ActionMapUIResource
创建并填充。人口是由在每个数组元素的"AuditoryCues.cueList"
迭代完成,调用createAudioAction()
创建每个元素的Action
。由此产生的Action
放置在ActionMapUIResource
,用数组元素是关键。例如,如果"AuditoryCues.cueList"
数组只包含一个元素,"audioKey"
,的ActionMapUIResource
创建,然后通过actionMap.put(cueList[0], createAudioAction(cueList[0]))
稠密。
如果默认值是null
"AuditoryCues.actionMap"
,默认值是null
"AuditoryCues.cueList"
,空ActionMapUIResource
创建。
Actions
负责打听觉线索
"AuditoryCues.actionMap"
ClassCastException
默认的值不是一个
ActionMap
,或默认的值不是一个
Object[]
"AuditoryCues.cueList"
createAudioAction(java.lang.Object)
,
playSound(Action)
protected Action createAudioAction(Object key)
Action
。
如果是一个Action
key
non-null
,利用关键key
默认值创建。价值确定声源的负载时,actionPerformed
在Action
调用。声源通过getClass().getResourceAsStream()
装入byte[]
。
key
的关键识别音频行动
Action
用来播放源,或
null
如果
key
是
null
playSound(Action)
protected void playSound(Action audioAction)
actionPerformed
audioAction
播放声音。的
actionPerformed
方法被调用,如果该
"AuditoryCues.playList"
默认的值是一个包含
String
输入相等的
audioAction
名称
non-null
Object[]
。
audioAction
-行动,知道如何使系统或用户活动所发生的相关音频;价值
null
,被忽略
ClassCastException
-如果
audioAction
是
non-null
和默认的值不是一个
Object[]
"AuditoryCues.playList"
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.