public abstract class BasicLookAndFeel extends LookAndFeel implements Serializable
每个的ComponentUI的前提是S BasicLookAndFeel派生默认表其行为。 除非另有说明,否则此包中的每个ComponentUI实现都将记录它们使用的一组默认值。 除非另有说明,默认值是在调用installUI时安装的,并按照LookAndFeel中概述的LookAndFeel安装默认值。
警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。 从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这种外观的音频动作的
ActionMap 。
|
UIDefaults |
getDefaults()
返回外观和默认值。
|
protected void |
initClassDefaults(UIDefaults table)
填充
table从映射
uiClassID到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与
name-color成对
systemColors 。
|
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调用。
UIManager调用getDefaults之前调用此方法。
该方法旨在对外观进行任何初始化。
子类应该在这里进行任何一次性设置,而不是在静态初始化器中进行任何一次性设置,因为可以加载外观和感觉类对象,以发现isSupportedLookAndFeel()返回false 。
public void uninitialize()
UIManager调用。
例如,当外观和感觉被改变时, UIManager.setLookAndFeel调用这个。
子类可以选择在这里释放一些资源。
protected void initClassDefaults(UIDefaults table)
table ,其映射关系从uiClassID到ui类的完全限定名称。
特定uiClassID值为"javax.swing.plaf.basic.Basic + uiClassID" 。
例如, uiClassID TreeUI的值是"javax.swing.plaf.basic.BasicTreeUI" 。
table - 添加条目的
UIDefaults实例
NullPointerException - 如果
table是
null
LookAndFeel , getDefaults()
protected void initSystemColorDefaults(UIDefaults table)
table 。
这将创建一个name-color对的数组,并调用loadSystemColors 。
该名称是一个String ,对应于SystemColor类中静态SystemColor字段之一的SystemColor 。 为每个这样的SystemColor字段创建一个名称 - 颜色对。
color对应于String所理解的十六进制Color.decode 。 例如, name-color对之一是"desktop"-"#005C5C" 。 这对应于SystemColor字段desktop ,颜色值为new Color(0x005C5C) 。
以下显示了两个name-color对:
String[] nameColorPairs = new String[] {
"desktop", "#005C5C",
"activeCaption", "#000080" };
loadSystemColors(table, nameColorPairs, isNativeLookAndFeel());
如前所述,这将使用提供的table和name-color对数组来调用loadSystemColors 。
loadSystemColors的最后一个参数表示是否应使用SystemColor中的字段值。
该方法将isNativeLookAndFeel()的值作为最后一个参数传递给loadSystemColors 。
table -
UIDefaults对象的值被添加到
NullPointerException - 如果
table是
null
SystemColor , getDefaults() , loadSystemColors(javax.swing.UIDefaults, java.lang.String[], boolean)
protected void loadSystemColors(UIDefaults table, String[] systemColors, boolean useNative)
table中使用name-color对systemColors 。
有关systemColors的格式的详细信息,请参阅systemColors 。
一个条目添加到table每个的name-color成对systemColors 。 输入键是name对的name-color 。
该条目的值对应于color对的name-color 。 条目的值以两种方式之一计算。 使用任一方法,值始终为ColorUIResource 。
如果useNative是false ,该color通过使用创建Color.decode的转换String到Color 。 如果decode无法将String转换成Color ( NumberFormatException被抛出),则使用黑色ColorUIResource 。
如果useNative是true时, color是字段中的值SystemColor具有相同名称为name所述的name-color对。 如果该字段无效,则使用黑色ColorUIResource 。
table - 添加了值的
UIDefaults对象
systemColors -
name-color对阵列,如
initSystemColorDefaults(UIDefaults)
所述
useNative - 是否从
SystemColor或
Color.decode获得颜色
NullPointerException - 如果systemColors是null ;
或systemColors不为空,而table为null ;
或者name-color对的名字之一是null ;
或useNative是false和colors对的name-color是null
ArrayIndexOutOfBoundsException - 如果
useNative是
false和
systemColors.length是奇数
initSystemColorDefaults(javax.swing.UIDefaults) , SystemColor , Color.decode(String)
protected void initComponentDefaults(UIDefaults table)
table与默认的基本外观和感觉。
table - 要添加的值为
UIDefaults
NullPointerException - 如果
table是
null
protected ActionMap getAudioActionMap()
ActionMap这种外观的音频动作的ActionMap 。
返回的ActionMap包含Actions ,其具有呈现听觉提示的能力。 这些听觉线索映射到用户和系统活动,可能对最终用户了解(例如出现对话框)有用。
在适当的时候, ComponentUI负责在Action中获得ActionMap并将其传递给playSound 。
该方法首先查找该ActionMap使用密钥的缺省值"AuditoryCues.actionMap" 。
如果值为non-null ,则返回。 如果默认值"AuditoryCues.actionMap"是null ,默认值"AuditoryCues.cueList"是non-null ,一个ActionMapUIResource创建和填充。 群体通过遍历每个的元件的完成"AuditoryCues.cueList"阵列,并调用createAudioAction()创建Action用于每个元素。 所得到的Action被放置在ActionMapUIResource ,使用数组元素作为关键。 例如,如果"AuditoryCues.cueList"数组包含单元素, "audioKey" ,所述ActionMapUIResource被创建,然后通过填充方式actionMap.put(cueList[0], createAudioAction(cueList[0])) 。
如果默认值"AuditoryCues.actionMap"为null ,默认值"AuditoryCues.cueList"为null ,则创建一个空的ActionMapUIResource 。
Actions负责播放听觉线索
ClassCastException - 如果默认值
"AuditoryCues.actionMap"不是
ActionMap ,或默认值
"AuditoryCues.cueList"不是
Object[]
createAudioAction(java.lang.Object) ,
playSound(Action)
protected Action createAudioAction(Object key)
Action用于播放声音。
如果key为non-null ,则使用默认值Action创建一个key 。 该值表示声音资源时加载actionPerformed是在调用Action 。 声音资源被加载到byte[]途经getClass().getResourceAsStream() 。
key - 识别音频动作的键
Action用于播放源,或
null如果
key是
null
playSound(Action)
protected void playSound(Action audioAction)
actionPerformed audioAction播放声音。
所述actionPerformed如果值方法被调用"AuditoryCues.playList"默认是non-null Object[]含有String条目等于的名称audioAction 。
audioAction - 知道如何呈现与正在发生的系统或用户活动相关联的音频的动作;
值为null ,被忽略
ClassCastException - 如果
audioAction是
non-null ,默认值
"AuditoryCues.playList"不是
Object[]
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.