學習

          努力

          常用鏈接

          統計

          [Java代碼]身份證號碼校驗與信息提取 - Java 代碼

          最新評論

          2008年5月29日 #

          簡單的界面換膚術

          1:可以直接在程序中調用下面三個中的一個:
          import javax.swing.*;
          UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel") ;
          UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel") ;
          UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel") ;
          2:或采用菜單來變換:
          import javax.swing.*;
          JMenuBar mb = new JMenuBar();
          JMenu file = new JMenu("Look & Feel", true);
          ButtonGroup buttonGroup = new ButtonGroup();
          final UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels();
          for (int i = 0; i < info.length; i++) {
          JRadioButtonMenuItem item = new
          JRadioButtonMenuItem(info[i].getName(), i == 0);
          final String className = info[i].getClassName();
          item.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
          try { UIManager.setLookAndFeel(className); }
          catch (Exception e) { System.out.println(e); }
          SwingUtilities.updateComponentTreeUI(TouchyFeely.this); }
          });
          buttonGroup.add(item);
          file.add(item);
          }
          mb.add(file);
          setJMenuBar(mb);
          }
          

           

          1:可以直接在程序中調用下面三個中的一個: import javax.swing.*; UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel") ; UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel") ; UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel") ; 2:或采用菜單來變換: import javax.swing.*; JMenuBar mb = new JMenuBar(); JMenu file = new JMenu("Look & Feel", true); ButtonGroup buttonGroup = new ButtonGroup(); final UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels(); for (int i = 0; i < info.length; i++) { JRadioButtonMenuItem item = new JRadioButtonMenuItem(info[i].getName(), i == 0); final String className = info[i].getClassName(); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { try { UIManager.setLookAndFeel(className); } catch (Exception e) { System.out.println(e); } SwingUtilities.updateComponentTreeUI(TouchyFeely.this); } }); buttonGroup.add(item); file.add(item); } mb.add(file); setJMenuBar(mb); }

          posted @ 2008-05-29 17:40 楊 閱讀(296) | 評論 (1)編輯 收藏

          僅列出標題  
          主站蜘蛛池模板: 安岳县| 延川县| 深州市| 东港市| 张掖市| 民勤县| 临清市| 肇庆市| 正定县| 静乐县| 弋阳县| 新干县| 宕昌县| 保山市| 杂多县| 井陉县| 达日县| 德保县| 西华县| 灌南县| 通榆县| 巨鹿县| 阿图什市| 通道| 双柏县| 孟津县| 台东市| 胶州市| 梁平县| 涞水县| 靖江市| 西林县| 乌什县| 民权县| 塔城市| 张掖市| 若羌县| 斗六市| 呼图壁县| 松桃| 陇川县|