public abstract class BasicLookAndFeel extends LookAndFeel implements Serializable
每个BasicLookAndFeel提供的ComponentUIs推导其行为从缺省值表。除非另有说明,每个在这个文件包设置默认他们使用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, uninstallBorderpublic 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.