一切皆可抽象

          大而無(wú)形 庖丁解牛 厚積薄發(fā) 滌慮玄覽
             ::  ::  ::  ::  :: 管理

          最近在做Java Application的項(xiàng)目,對(duì)于ui的美觀,做了一些嘗試。有幸看到了JGoodIdes的LookAndFeel包。
          效果大家可以看看如下連接
                  http://www.jgoodies.com
          經(jīng)過(guò)試驗(yàn),解決了中文亂碼問(wèn)題,下面將經(jīng)驗(yàn)和大家共分享。
          LookAndFeel如同css一樣,具體的概念大家可以參考其他文章,這里不做贅述。

          http://www.aygfsteel.com/Files/itaogo/plastic-1.1.3.zip
          1,加載附件plastic-1.1.3.jar到lib path,我用的是jbuilderX
          2,創(chuàng)建一個(gè)新類(lèi)AppFont.java
             import java.awt.*;
             import javax.swing.UIManager;
             public class AppFont()
             {
               public static void setFont(Font pFont){
                UIManager.put("Button.font", pFont);
                UIManager.put("ToggleButton.font", pFont);
                UIManager.put("RadioButton.font", pFont);
                UIManager.put("CheckBox.font", pFont);
                UIManager.put("ColorChooser.font", pFont);
                UIManager.put("ToggleButton.font", pFont);
                UIManager.put("ComboBox.font", pFont);
                UIManager.put("ComboBoxItem.font", pFont);
                UIManager.put("InternalFrame.titleFont", pFont);
                UIManager.put("Label.font", pFont);
                UIManager.put("List.font", pFont);
              UIManager.put("MenuBar.font", pFont);
              UIManager.put("Menu.font", pFont);
              UIManager.put("MenuItem.font", pFont);
              UIManager.put("RadioButtonMenuItem.font", pFont);
              UIManager.put("CheckBoxMenuItem.font", pFont);
              UIManager.put("PopupMenu.font", pFont);
              UIManager.put("OptionPane.font", pFont);
              UIManager.put("Panel.font", pFont);
              UIManager.put("ProgressBar.font", pFont);
              UIManager.put("ScrollPane.font", pFont);
              UIManager.put("Viewport", pFont);
              UIManager.put("TabbedPane.font", pFont);
              UIManager.put("TableHeader.font", pFont);
              UIManager.put("Table.font", pFont);
              UIManager.put("TextField.font", pFont);
              UIManager.put("PasswordFiled.font", pFont);
              UIManager.put("TextArea.font", pFont);
              UIManager.put("TextPane.font", pFont);
              UIManager.put("EditorPane.font", pFont);
              UIManager.put("TitledBorder.font", pFont);
              UIManager.put("ToolBar.font", pFont);
              UIManager.put("ToolTip.font", pFont);
              UIManager.put("Tree.font", pFont);
                }
             }
          3,尋找您的java application 的主程序 
           
            //引入
            import com.jgoodies.plaf.LookUtils;
            import com.jgoodies.plaf.plastic.PlasticLookAndFeel;
           
            //修改程序如下
            //Main method
             public static void main(String[] args) {
              try {
                //原來(lái)的,請(qǐng)注釋掉;jbuilder是如此寫(xiě)法。
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                //修改為
                UIManager.put("ClassLoader", LookUtils.class.getClassLoader());
                UIManager.setLookAndFeel(new PlasticLookAndFeel());
                AppFont.setFont(new java.awt.Font("宋體", 0, 12));
              }
              catch(Exception e) {
                e.printStackTrace();
              }
              new MainApp();
            }
           
           4,附件2 UISample.rar是jbuilder的一個(gè)簡(jiǎn)單效果的項(xiàng)目。下載地址 http://www.aygfsteel.com/Files/itaogo/UISample.rar

          主站蜘蛛池模板: 廉江市| 双桥区| 大安市| 来凤县| 宜都市| 绥棱县| 梓潼县| 青海省| 巨野县| 云安县| 阜城县| 吴江市| 泰顺县| 武义县| 辉南县| 准格尔旗| 双峰县| 平果县| 英德市| 石首市| 沭阳县| 永昌县| 西和县| 崇左市| 扎兰屯市| 会宁县| 绥德县| 宜丰县| 澜沧| 灵宝市| 长海县| 泸水县| 卫辉市| 峨眉山市| 乐清市| 湖南省| 申扎县| 新竹县| 扎赉特旗| 五大连池市| 宜黄县|