學習

          努力

          常用鏈接

          統計

          [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)編輯 收藏

          主站蜘蛛池模板: 保德县| 永春县| 雷山县| 岳西县| 涡阳县| 长春市| 远安县| 穆棱市| 三穗县| 平安县| 饶阳县| 汕头市| 丹寨县| 夏河县| 长岭县| 连城县| 即墨市| 个旧市| 木兰县| 盱眙县| 武威市| 札达县| 忻城县| 武汉市| 珠海市| 宜丰县| 泰来县| 昂仁县| 涡阳县| 八宿县| 孙吴县| 丹棱县| 南京市| 乐业县| 廊坊市| 宁都县| 台山市| 宁南县| 甘德县| 吕梁市| 永丰县|