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

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

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

    kooyee ‘s blog

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

    【Swing】設置applet程序的界面外觀

    Posted on 2008-06-05 20:23 kooyee 閱讀(874) 評論(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調用通用的外觀,適合任何系統。
    若使用getSystemLookAndFeelClassName則根據本地的系統使用外觀, 如果要指定使用一種外觀則帶入具體的外觀的類的名字。例如,使用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 文件來設置 swing.laf 屬性. 這個文件一般位于JRE的lib文件夾下
    Swing properties文件中加入一行 swing.laf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel






    參考:

    setLookAndFeel的參數可以是:

    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自動調用默認的metal外觀。所以當使用UIManager.getSystemLookAndFeelClassName()時, 如果沒有根據本地系統調用相應的外觀,而是顯示默認的metal外觀。這個多半是由于沒有找到相應的外觀class而導致的,這就需要把更多相應的外觀class加入到應用中


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

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

    主站蜘蛛池模板: 亚洲国产系列一区二区三区| 亚洲精品国精品久久99热一| 亚洲国产高清在线精品一区| 久久精品无码精品免费专区| 亚洲中文字幕无码永久在线 | 亚洲网址在线观看| 久操视频在线免费观看| 亚洲成AV人片在线观看| 91视频精品全国免费观看| 亚洲电影免费观看| 最新黄色免费网站| 亚洲 日韩 色 图网站| 在线观看特色大片免费视频| 国产成人精品日本亚洲专区6| 久久不见久久见免费影院| 亚洲国产综合AV在线观看| 免费一看一级毛片全播放| 人妻18毛片a级毛片免费看| 亚洲熟妇无码另类久久久| 久久国产精品免费网站| 亚洲免费中文字幕| 国产成人在线观看免费网站 | 免费h黄肉动漫在线观看| 男人j进女人p免费视频| 久久精品国产亚洲麻豆| 18禁无遮挡无码国产免费网站| 亚洲人成人网毛片在线播放| 免费国产在线观看| 久久香蕉国产线看免费| 亚洲1区1区3区4区产品乱码芒果 | 无码人妻一区二区三区免费看| 亚洲成在人线中文字幕| 国产精品久久久久影院免费| 成人免费777777被爆出| 亚洲国产日韩女人aaaaaa毛片在线| 色www永久免费视频| 三年片免费观看大全国语| 亚洲国产最大av| 国产午夜亚洲精品理论片不卡| **aaaaa毛片免费| 色多多免费视频观看区一区|