当前位置: 首页>>代码示例>>Java>>正文


Java UIManager.getCrossPlatformLookAndFeelClassName方法代码示例

本文整理汇总了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();
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:19,代码来源:SystemLoadDialog.java

示例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);
  }

}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:75,代码来源:Main.java


注:本文中的javax.swing.UIManager.getCrossPlatformLookAndFeelClassName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。