Results 1 to 5 of 5
  1. #1
    shapeshifter is offline Member
    Join Date
    Jul 2007
    Posts
    2
    Rep Power
    0

    Exclamation Minimize to System Tray In Windows

    Does anybody know how to make an app to have a "minimize to tray" feature?....
    I want to remove the minimized button on the task bar & put it in the system tray so that the app is not mixed with other general stuff.....
    Please Help......:)

  2. #2
    cruxblack is offline Senior Member
    Join Date
    Jul 2007
    Posts
    130
    Rep Power
    0

    Default

    Got this code from a friend, this' the translated code in english
    Java Code:
    import java.awt.HeadlessException;import java.awt.Image;
    
    import java.awt.MenuItem;
    
    import java.awt.Panel;
    
    import java.awt.PopupMenu;
    
    import java.awt.SystemTray;
    
    import java.awt.TrayIcon;
    
    import java.awt.event.ActionEvent;
    
    import java.awt.event.ActionListener;
    
    import java.awt.image.BufferedImage;
    
    import javax.swing.Icon;
    
    import javax.swing.JOptionPane;
    
    import javax.swing.plaf.metal.MetalIconFactory;
    
     
    
    public class SysTray {
    
    private static Image getImage() throws HeadlessException {
    
            Icon defaultIcon = MetalIconFactory.getTreeComputerIcon();
    
            Image img = new BufferedImage(defaultIcon.getIconWidth(),
    
                    defaultIcon.getIconHeight(),
    
                    BufferedImage.TYPE_4BYTE_ABGR);
    
            defaultIcon.paintIcon(new Panel(), img.getGraphics(), 0, 0);
    
    return img;
    
        }
    
    private static PopupMenu createPopupMenu() throws
    
                                                     HeadlessException {
    
            PopupMenu menu = new PopupMenu();
    
    MenuItem exit = new MenuItem("Exit");
    
            exit.addActionListener(new ActionListener() {
    
               public void actionPerformed(ActionEvent e) {
    
                   System.exit(0);
    
               }
    
            });
    
            menu.add(exit);
    
    return menu;
    
        }
    
    public static void main(String[] args) throws Exception {
    
            TrayIcon icon = new TrayIcon(getImage(),
    
                    "This is a Java Tray Icon", createPopupMenu());
    
            icon.addActionListener(new ActionListener() {
    
               public void actionPerformed(ActionEvent e) {
    
                   JOptionPane.showMessageDialog(null,
    
                           "Bring Java to the Desktop app");
    
               }
    
            });
    
            SystemTray.getSystemTray().add(icon);
    
            while(true) {
    
                Thread.sleep(10000);
    
                icon.displayMessage("Warning", "Click me! =)",
    
                    TrayIcon.MessageType.WARNING);
    
            }
    
        }
    
    }
    Hope this helps :D
    CruxBlack

  3. #3
    shapeshifter is offline Member
    Join Date
    Jul 2007
    Posts
    2
    Rep Power
    0

    Default

    thanx man.........appreciate it....

  4. #4
    cruxblack is offline Senior Member
    Join Date
    Jul 2007
    Posts
    130
    Rep Power
    0

    Default

    Likewise :D

  5. #5
    aldo92 is offline Member
    Join Date
    Dec 2008
    Posts
    1
    Rep Power
    0

Similar Threads

  1. [SOLVED] Baloon message on a tray icon
    By Eranga in forum AWT / Swing
    Replies: 5
    Last Post: 04-10-2008, 02:12 PM
  2. swt for windows
    By Gajesh Tripathi in forum SWT / JFace
    Replies: 2
    Last Post: 10-18-2007, 06:43 AM
  3. First windows application
    By tha_crazy in forum New To Java
    Replies: 1
    Last Post: 08-13-2007, 03:22 PM
  4. Help with windows in java
    By lenny in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 06:22 AM
  5. Replies: 1
    Last Post: 04-09-2007, 12:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •