<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    kooyee ‘s blog

    開源軟件, 眾人努力的結(jié)晶, 全人類的共同財(cái)富
    posts - 103, comments - 55, trackbacks - 0, articles - 66
       :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

    【Swing】設(shè)置applet程序的界面外觀

    Posted on 2008-06-05 20:23 kooyee 閱讀(873) 評論(0)  編輯  收藏 所屬分類: Swing/Applet

     

    自從JDK1.4版本后Swing程序就支持用戶自定義外觀,以后就不用再使用java原始的‘丑陋’外觀。下面我們就來看一下如何讓程序使用我們熟悉的XP外觀。

    第一種方法: 

    在code中加入 UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName()); 

    例如
     
    public static void main(String[] args) 

    try 

    UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName()); 
    }
     catch (Exception e) { } 
    new SwingApplication(); //Create and show the GUI. 
    }
     

    getCrossPlatformLookAndFeelClassName調(diào)用通用的外觀,適合任何系統(tǒng)。
    若使用getSystemLookAndFeelClassName則根據(jù)本地的系統(tǒng)使用外觀, 如果要指定使用一種外觀則帶入具體的外觀的類的名字。例如,使用GTK+的外觀的代碼
    UIManager.setLookAndFeel( "com.sun.java.swing.plaf.gtk.GTKLookAndFeel" ); 

     

    第二種方法: 

    在命令行中定義 swing.laf 屬性. 例如: java -Dswing.laf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel MyApp java -Dswing.laf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel MyApp

    
    

    第三種方法: 

    使用 swing.properties 文件來設(shè)置 swing.laf 屬性. 這個(gè)文件一般位于JRE的lib文件夾下
    Swing properties文件中加入一行 swing.laf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel






    參考:

    setLookAndFeel的參數(shù)可以是:

    UIManager.getCrossPlatformLookAndFeelClassName()
    Returns the look and feel that works on all platforms &151; the Java look and feel.

     

    UIManager.getSystemLookAndFeelClassName()
    Specifies the look and feel for the current platform. On Microsoft Windows platforms, this specifies the Windows look and feel. On Mac OS platforms, this specifies the Mac OS look and feel. On other Unix platforms, such as Solaris or Linux, this returns the CDE/Motif look and feel.

     

    "com.sun.java.swing.plaf.gtk.GTKLookAndFeel
    Specifies the GTK+ look and feel. Introduced in release 1.4.2. You can specify the particular theme either using a resource file otherIcon (outside of the tutorial) or the gtkthemefile command-line parameter. Here is an example: java -Dswing.gtkthemefile=customTheme/gtkrc Application
    
    

     

    "javax.swing.plaf.metal.MetalLookAndFeel
    Specifies the Java look and feel. (The codename for this look and feel was Metal.)

     

    "com.sun.java.swing.plaf.windows.WindowsLookAndFeel
    Specifies the Windows look and feel. Currently, you can use this look and feel only on Microsoft Windows systems.
    Version Note: As of release 1.4.2, WindowsLookAndFeel has been updated to mimic the Windows XP look and feel when running on the Windows XP platform.

     

    "com.sun.java.swing.plaf.motif.MotifLookAndFeel
    Specifies the CDE/Motif look and feel. This look and feel can be used on any platform.

    如果指定的class不存在,swing自動(dòng)調(diào)用默認(rèn)的metal外觀。所以當(dāng)使用UIManager.getSystemLookAndFeelClassName()時(shí), 如果沒有根據(jù)本地系統(tǒng)調(diào)用相應(yīng)的外觀,而是顯示默認(rèn)的metal外觀。這個(gè)多半是由于沒有找到相應(yīng)的外觀class而導(dǎo)致的,這就需要把更多相應(yīng)的外觀class加入到應(yīng)用中


     如果在運(yùn)行applet時(shí)提示‘安裝plugin’, 是由于jsp tag中jreversion的值設(shè)置問題(瀏覽器無法調(diào)用相應(yīng)的版本)。比如把jreversion="1.6.0" 改為jreversion="1.6" 可以解決問題。jreversion="1.6"表示為所有1.6的版本, 1.6.0是具體的一個(gè)版本。所以當(dāng)瀏覽器使用別的1.6版本的jre,會(huì)與jreversion="1.6.0"沖突。

    在Linux下使用getSystemLookAndFeelClassName時(shí), 使用了GNOME才能自動(dòng)調(diào)用GTK外觀。其他的return metal外觀。SUSE中在‘more application‘中打開的FF才能正確的調(diào)用GTK外觀(可能是SUSE的bug)。

    主站蜘蛛池模板: 国产亚洲精品美女2020久久| 亚洲美女视频一区| 精品亚洲成A人在线观看青青| 四虎最新永久免费视频| 久久久亚洲欧洲日产国码是AV| 三年在线观看免费观看完整版中文 | 国产成人免费ā片在线观看老同学| 内射无码专区久久亚洲| 人禽伦免费交视频播放| 亚洲综合激情另类专区| 中国内地毛片免费高清| 亚洲阿v天堂在线| 无码精品人妻一区二区三区免费看 | a一级爱做片免费| 亚洲色大成网站www永久一区| 9久热精品免费观看视频| 亚洲人成中文字幕在线观看| 香蕉免费看一区二区三区| 国产亚洲成av人片在线观看| 57pao一国产成视频永久免费| 亚洲成a人片在线观看中文!!!| 免费AA片少妇人AA片直播| 亚洲av无码专区青青草原| 亚洲黄片毛片在线观看| 免费国产99久久久香蕉| 噜噜噜亚洲色成人网站∨| 色播精品免费小视频| 亚洲av第一网站久章草| 亚洲黄片毛片在线观看| 色欲国产麻豆一精品一AV一免费| 亚洲午夜一区二区电影院| 国产精品色午夜免费视频| 中国性猛交xxxxx免费看| 亚洲综合国产精品| 国产在线观看www鲁啊鲁免费| 2022国内精品免费福利视频| 亚洲国产高清美女在线观看| 免费在线视频一区| 99久久精品免费视频| 色偷偷亚洲男人天堂| 久久综合图区亚洲综合图区 |