Swing编程帮助,美化包的使用以及系统托盘

美化包的使用: 
import org.jvnet.substance.skin.SubstanceGreenMagicLookAndFeel; 
方法: 
private void setLAF() 
    { 
       try 
       { 
            UIManager.setLookAndFeel(new 
                      SubstanceFieldOfWheatLookAndFeel()); 
            JDialog.setDefaultLookAndFeelDecorated(true); 
       } 
       catch (UnsupportedLookAndFeelException ex) 
       { 
            JOptionPane.showMessageDialog(this, "对不起!不支持"); 
       } 
    } 

系统托盘方法: 
   public void minHide() 
      { 
       systemTray = SystemTray.getSystemTray();// 获得系统托盘的实例 
        ImageIcon ii = new ImageIcon("src/images/001.png"); 
       this.setIconImage(ii.getImage()); 
       iconHide = new ImageIcon("src/images/001.png").getImage(); 
       
       PopupMenu pop = new PopupMenu();// 构造一个右键弹出式菜单 
        MenuItem show = new MenuItem("显示窗口"); 
       MenuItem exit = new MenuItem("退出"); 
       MenuItem author = new MenuItem("Author"); 
       pop.add(show); 
       pop.add(exit); 
       pop.add(author); 

       trayIcon = new TrayIcon(iconHide, "开心农场", pop); 
       trayIcon.addMouseListener(new MouseAdapter() 
       { 
            public void mouseClicked(MouseEvent e) 
            { 
                if (e.getButton() == MouseEvent.BUTTON1) 
                { 
                    if (e.getClickCount() >= 2)// 双击托盘窗口再现 
                       { 
                        systemTray.remove(trayIcon); 
                        setVisible(true); 
                    } 
                } 
            } 

        });

相关工具包下载:  http://txidol.iteye.com/admin/blogs/774614

你可能感兴趣的:(java,swing)