本文整理汇总了Java中javax.swing.UIManager.getCrossPlatformLookAndFeelClassName方法的典型用法代码示例。如果您正苦于以下问题:Java UIManager.getCrossPlatformLookAndFeelClassName方法的具体用法?Java UIManager.getCrossPlatformLookAndFeelClassName怎么用?Java UIManager.getCrossPlatformLookAndFeelClassName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.UIManager
的用法示例。
在下文中一共展示了UIManager.getCrossPlatformLookAndFeelClassName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setLookAndFeel
import javax.swing.UIManager; //导入方法依赖的package包/类
/**
* This method set the Look and Feel of this Dialog.
*/
private void setLookAndFeel() {
String lnfClassname = Application.getGlobalInfo().getAppLookAndFeelClassName();
try {
if (lnfClassname == null) {
lnfClassname = UIManager.getCrossPlatformLookAndFeelClassName();
}
UIManager.setLookAndFeel(lnfClassname);
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception ex) {
System.err.println("Cannot install Look and Feel '" + lnfClassname + "' on this platform.");
ex.printStackTrace();
}
}
示例2: applyUserPreferences
import javax.swing.UIManager; //导入方法依赖的package包/类
/**
* Reads the user config data and applies the required settings.
* This must be called <b>after</b> {@link Gate#init()} but <b>before</b>
* any GUI components are created.
*/
public static void applyUserPreferences(){
//look and feel
String lnfClassName;
if(System.getProperty("swing.defaultlaf") != null) {
lnfClassName = System.getProperty("swing.defaultlaf");
} else {
lnfClassName = Gate.getUserConfig().
getString(GateConstants.LOOK_AND_FEEL);
}
if(lnfClassName == null){
//if running on Linux, default to Metal rather than GTK because GTK LnF
//doesn't play nicely with most Gnome themes
if(System.getProperty("os.name").toLowerCase().indexOf("linux") != -1){
//running on Linux
lnfClassName = UIManager.getCrossPlatformLookAndFeelClassName();
}else{
lnfClassName = UIManager.getSystemLookAndFeelClassName();
}
}
try {
UIManager.setLookAndFeel(lnfClassName);
} catch(Exception e) {
System.err.print("Could not set your preferred Look and Feel. The error was:\n" +
e.toString() + "\nReverting to using Java Look and Feel");
try {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
}catch(Exception e1) {
//we just can't catch a break here. Let's forget about look and feel.
System.err.print(
"Could not set the cross-platform Look and Feel either. The error was:\n" +
e1.toString() + "\nGiving up on Look and Feel.");
}
}
Gate.getUserConfig().put(GateConstants.LOOK_AND_FEEL, lnfClassName);
//read the user config data
OptionsMap userConfig = Gate.getUserConfig();
//text font
Font font = userConfig.getFont(GateConstants.TEXT_COMPONENTS_FONT);
if(font == null){
font = UIManager.getFont("TextPane.font");
}
if(font != null){
OptionsDialog.setTextComponentsFont(font);
}
//menus font
font = userConfig.getFont(GateConstants.MENUS_FONT);
if(font == null){
font = UIManager.getFont("Menu.font");
}
if(font != null){
OptionsDialog.setMenuComponentsFont(font);
}
//other gui font
font = userConfig.getFont(GateConstants.OTHER_COMPONENTS_FONT);
if(font == null){
font = UIManager.getFont("Button.font");
}
if(font != null){
OptionsDialog.setComponentsFont(font);
}
}