• Java:判断当前操作系统界面采用的主题是windows经典样式还是xp样式


    想起两三年前,发现写Java界面的时候,如果将当前界面的layout设为null,由于windows的不同主题界面下,标题栏的高度不一致,导致当前界面表现也不一致。

    当时就想找到一个办法先判断当前用户的主题是经典样式还是xp样式,可一直都没有找到。

    今天无意发现com.sun.java.swing.plaf.windows.StyleXP类里面的一段代码:

    /** Get the singleton instance of this class
          *
          * @return the singleton instance of this class or null if XP styles
          * are not active or if this is not Windows XP
          */
         static synchronized XPStyle getXP() {
             if (themeActive == null) {
                 Toolkit toolkit = Toolkit.getDefaultToolkit();
                 themeActive =
                     (Boolean)toolkit.getDesktopProperty("win.xpstyle.themeActive");
                 if (themeActive == null) {
                     themeActive = Boolean.FALSE;
                 }
                 if (themeActive.booleanValue()) {
                     GetPropertyAction propertyAction =
                         new GetPropertyAction("swing.noxp");
                     if (AccessController.doPrivileged(propertyAction) == null &&
                         ThemeReader.isThemed() &&
                         !(UIManager.getLookAndFeel()
                           instanceof WindowsClassicLookAndFeel)) {
    
                         xp = new XPStyle();
                     }
                 }
             }
             return xp;
         }

    原来使用 Toolkit.getDefaultToolkit().getDesktopProperty("win.xpstyle.themeActive")方法就可以返回当前的主题样式。

    2007-07-04

  • 相关阅读:
    浏览器跨域访问WebApi
    外部主机无法访问IIS发布的网站
    在VisualStudio中远程调试IIS站点
    关于跨域请求的一些解决方案
    MVC与WebApi中的异常过滤器
    委托与事件
    C#中的属性
    C#中的索引
    Equals与==的区别
    关于跨域响应头Access-Control-Allow-Headers的一些说明
  • 原文地址:https://www.cnblogs.com/personnel/p/4582895.html
Copyright © 2020-2023  润新知