Example usage for java.awt PopupMenu add

List of usage examples for java.awt PopupMenu add

Introduction

In this page you can find the example usage for java.awt PopupMenu add.

Prototype

public MenuItem add(MenuItem mi) 

Source Link

Document

Adds the specified menu item to this menu.

Usage

From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java

/**
 * Creates the Pop-up menu for System Tray Icon
 * //from w  ww .  java  2s .c om
 * @return PopupMenu
 */
private PopupMenu createTrayPopup() {

    PopupMenu trayPopup = new PopupMenu();

    // About
    MenuItem aboutItem = new MenuItem("About");
    aboutItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            showAbout();
        }

    });
    trayPopup.add(aboutItem);

    trayPopup.addSeparator();

    // Shutdown
    MenuItem shutdownItem = new MenuItem("Shutdown");
    shutdownItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            doShutdownCluster();
        }

    });
    trayPopup.add(shutdownItem);

    return trayPopup;
}

From source file:com.puzzle.gui.MainFrame.java

public void tray() {//-----ljs
    tray = SystemTray.getSystemTray(); // ?     
    PopupMenu pop = new PopupMenu(); // ????  
    final MenuItem show = new MenuItem("?");
    final MenuItem exit = new MenuItem("?");
    pop.add(show);
    pop.add(exit);//from www .  ja v  a 2  s. co m
    show.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            showMouseClick(e);
        }
    });
    exit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            exitMouseClick(e);
        }
    });

    trayIcon = new TrayIcon(
            Toolkit.getDefaultToolkit().getImage(MainFrame.class.getResource("/images/flag.png")),
            "??V1.0", pop);//  
    trayIcon.setImageAutoSize(true);
    //?  
    trayIcon.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            trayIconMouseClick(e);
        }
    });

    try {
        tray.add(trayIcon); //   
    } catch (AWTException ex) {
        log.error(ex.getMessage(), ex);
        ex.printStackTrace();
    }

}

From source file:org.nebulaframework.ui.swing.node.NodeMainUI.java

/**
 * System Tray Icon Pop Up Menu/*from w  w w.jav  a 2  s . co  m*/
 * 
 * @return PopupMenu
 */
private PopupMenu createTrayPopup() {
    PopupMenu trayPopup = new PopupMenu();

    // About
    MenuItem aboutItem = new MenuItem("About");
    aboutItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            showAbout();
        }

    });
    trayPopup.add(aboutItem);

    trayPopup.addSeparator();

    // Shutdown Node
    MenuItem shutdownItem = new MenuItem("Shutdown");
    shutdownItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            doShutdownNode();
        }

    });
    trayPopup.add(shutdownItem);

    return trayPopup;
}

From source file:com.sec.ose.osi.ui.frm.tray.JTrayIconApp.java

private PopupMenu createPopupMenu(int state) {
    PopupMenu popupMenu = new PopupMenu("PopupMenu");

    MenuItem miLogOut = new MenuItem("LogOut");
    MenuItem miOpen = new MenuItem("Open");
    MenuItem miExit = new MenuItem("Exit");
    MenuItem miAbout = new MenuItem("About");

    miLogOut.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent e) {

            log.debug("actionPerformed() - LogOut");
            mEventHandler.handle(EventHandler.LOGOUT_MENU);
        }//from  www.  java  2  s  .  c  om

    });

    miOpen.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent e) {

            log.debug("actionPerformed() - Open");
            mEventHandler.handle(EventHandler.OPEN_MENU);
        }

    });

    miAbout.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent e) {

            log.debug("actionPerformed() - Help - SubSix");
            mEventHandler.handle(EventHandler.HELP_ABOUT);
        }

    });

    miExit.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent e) {

            log.debug("actionPerformed() - Exit");
            mEventHandler.handle(EventHandler.EXIT_MENU);
        }
    });

    switch (state) {

    case BEFORE_LOGIN_STATE:
        popupMenu.add(miOpen);
        popupMenu.addSeparator();
        popupMenu.add(miAbout);
        popupMenu.addSeparator();
        popupMenu.add(miExit);
        break;

    case AFTER_LOGIN_STATE:
        popupMenu.add(miLogOut);
        popupMenu.addSeparator();
        popupMenu.add(miOpen);
        popupMenu.addSeparator();
        popupMenu.add(miAbout);
        popupMenu.addSeparator();
        popupMenu.add(miExit);
        break;
    }

    return popupMenu;
}

From source file:net.sourceforge.entrainer.gui.EntrainerFX.java

private PopupMenu getTrayIconPopup() {
    PopupMenu pop = new PopupMenu("EntrainerFX");

    MenuItem start = new MenuItem("Start EntrainerFX");
    start.addActionListener(new ActionListener() {

        @Override/*from   ww w .  j  av a  2  s.  c  om*/
        public void actionPerformed(ActionEvent arg0) {
            fireReceiverChangeEvent(true, START_ENTRAINMENT);
            playPressed();
        }
    });

    pop.add(start);

    MenuItem stop = new MenuItem("Stop EntrainerFX");
    stop.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            fireReceiverChangeEvent(false, START_ENTRAINMENT);
            stopPressed();
        }
    });

    pop.add(stop);

    MenuItem exit = new MenuItem("Exit");
    exit.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            exitPressed();
        }
    });

    pop.add(exit);

    return pop;
}

From source file:org.languagetool.gui.Main.java

private PopupMenu makePopupMenu() {
    PopupMenu popup = new PopupMenu();
    ActionListener rmbListener = new TrayActionRMBListener();
    // Enable or disable embedded HTTP server:
    enableHttpServerItem = new CheckboxMenuItem(Tools.getLabel(messages.getString("tray_menu_enable_server")));
    enableHttpServerItem.setState(httpServer != null && httpServer.isRunning());
    enableHttpServerItem.addItemListener(new TrayActionItemListener());
    popup.add(enableHttpServerItem);
    // Check clipboard text:
    MenuItem checkClipboardItem = new MenuItem(Tools.getLabel(messages.getString("guiMenuCheckClipboard")));
    checkClipboardItem.addActionListener(rmbListener);
    popup.add(checkClipboardItem);//  w w  w  . jav  a2 s  . com
    // Open main window:
    MenuItem restoreItem = new MenuItem(Tools.getLabel(messages.getString("guiMenuShowMainWindow")));
    restoreItem.addActionListener(rmbListener);
    popup.add(restoreItem);
    // Exit:
    MenuItem exitItem = new MenuItem(Tools.getLabel(messages.getString("guiMenuQuit")));
    exitItem.addActionListener(rmbListener);
    popup.add(exitItem);
    return popup;
}

From source file:org.shelloid.vpt.agent.App.java

private void setupSystemTray() {
    if (SystemTray.isSupported()) {
        try {//from   w w  w. j a  va  2s . c om
            final ConfigForm configForm = new ConfigForm(false);
            final PopupMenu popup = new PopupMenu();
            final TrayIcon trayIcon = new TrayIcon(createImage("/images/logo.jpg"), "Shelloid VPT Agent");
            tray = SystemTray.getSystemTray();
            MenuItem authenticateItem = new MenuItem("Configure Authentication");
            MenuItem aboutItem = new MenuItem("About Shelloid VPT Agent");
            MenuItem exitItem = new MenuItem("Exit");
            trayIcon.setPopupMenu(popup);
            tray.add(trayIcon);
            authenticateItem.addActionListener(new AbstractAction() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    configForm.setVisible(true);
                }
            });
            aboutItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    JOptionPane.showMessageDialog(null,
                            "Shelloid VPT Agent.\nVersion : " + getVersion()
                                    + "\n\n(c) 2014 Shelloid LLC. \nhttps://www.shelloid.com",
                            "Shelloid VPT Client", JOptionPane.INFORMATION_MESSAGE);
                }
            });
            exitItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    if (JOptionPane.showConfirmDialog(null, "Are you sure to exit Shelloid VPT Agent?",
                            "Shelloid VPT Agent", JOptionPane.YES_NO_OPTION,
                            JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
                        shuttingDown = true;
                        closeAllConnections();
                        System.exit(0);
                    }
                }
            });
            popup.add(authenticateItem);
            popup.add(aboutItem);
            popup.addSeparator();
            popup.add(exitItem);
        } catch (Exception ex) {
            Platform.shelloidLogger.warn("System Tray Error: ", ex);
        }
    } else {
        System.out.println("System tray is not supported");
    }
}

From source file:javazoom.jlgui.player.amp.Player.java

/**
 * Loads a skin from a SkinLoader./*w  w  w  .j  a  va  2 s .co  m*/
 */
protected void loadSkin(SkinLoader skl) throws Exception {
    skl.loadImages();
    imMain = skl.getImage(theMain);
    imButtons = skl.getImage(theButtons);
    imTitleBar = skl.getImage(theTitleBar);
    imText = skl.getImage(theText);
    imMode = skl.getImage(theMode);
    imNumbers = skl.getImage(theNumbers);
    // add by John Yang
    if (imNumbers == null) {
        log.info("Try load nums_ex.bmp !");
        imNumbers = skl.getImage(theNumEx);
    }
    imVolume = skl.getImage(theVolume);
    imBalance = skl.getImage(theBalance);
    imIcons = skl.getImage(theIcons);
    imPosBar = skl.getImage(thePosBar);
    imEPSRButtons = skl.getImage(theEPSRButtons);

    // Computes volume slider height :
    int vh = (imVolume.getHeight(null) - 422);
    if (vh > 0) {
        releasedVolumePanel0[3] = vh;
        pressedVolumePanel0[3] = vh;
        releasedVolumePanel1[3] = vh;
        pressedVolumePanel1[3] = vh;
    }
    // Computes balance slider height :
    if (imBalance == null)
        imBalance = imVolume;
    int bh = (imBalance.getHeight(null) - 422);
    if (bh > 0) {
        releasedBalancePanel0[3] = bh;
        pressedBalancePanel0[3] = bh;
        releasedBalancePanel1[3] = bh;
        pressedBalancePanel1[3] = bh;
    }

    // Compute posbar height.
    int ph = imPosBar.getHeight(null);
    if (ph > 0) {
        releasedPosPanel[3] = ph;
        pressedPosPanel[3] = ph;
    }

    WinHeight = imMain.getHeight(this); // 275
    WinWidth = imMain.getWidth(this); // 116
    setSize(WinWidth, WinHeight);
    setLocation(OrigineX, OrigineY);
    //setBackground(Color.black);
    show();

    offScreenImage = createImage(WinWidth, WinHeight);
    offScreenGraphics = offScreenImage.getGraphics();
    // E.B Fix for JDK 1.4 slow down problem.
    hide();
    // End Fix.
    offScreenGraphics.drawImage(imMain, 0, 0, this);

    // M.S : Remove all components when loading a new skin.
    if (acPrevious != null)
        remove(acPrevious);
    if (acPlay != null)
        remove(acPlay);
    if (acPause != null)
        remove(acPause);
    if (acStop != null)
        remove(acStop);
    if (acNext != null)
        remove(acNext);
    if (acEject != null)
        remove(acEject);
    if (acTitleBar != null)
        remove(acTitleBar);
    if (acExit != null)
        remove(acExit);
    if (acMinimize != null)
        remove(acMinimize);
    if (acVolume != null)
        remove((Component) acVolume);
    if (acBalance != null)
        remove((Component) acBalance);
    if (acPosBar != null)
        remove(acPosBar);
    if (acPlaylist != null)
        remove(acPlaylist);
    if (acRepeat != null)
        remove(acRepeat);
    if (acShuffle != null)
        remove(acShuffle);
    if (acEqualizer != null)
        remove(acEqualizer);
    if (fileList != null)
        fileList.dispose();
    if (equalizer != null)
        equalizer.dispose();
    System.gc();

    /*-- Buttons --*/
    readPanel(releasedImage, releasedPanel, pressedImage, pressedPanel, imButtons);
    setButtonsPanel();

    /*-- Volume/Balance --*/
    if (skinVersion.equals("1")) {
        readPanel(releasedVolumeImage, releasedVolumePanel0, pressedVolumeImage, pressedVolumePanel0, imVolume);
        readPanel(releasedBalanceImage, releasedBalancePanel0, pressedBalanceImage, pressedBalancePanel0,
                imBalance);
    } else {
        readPanel(releasedVolumeImage, releasedVolumePanel1, pressedVolumeImage, pressedVolumePanel1, imVolume);
        readPanel(releasedBalanceImage, releasedBalancePanel1, pressedBalanceImage, pressedBalancePanel1,
                imBalance);
    }
    setVolumeBalancePanel(vh, bh);

    /*-- Title Bar --*/
    readPanel(releasedTitleIm, releasedTitlePanel, pressedTitleIm, pressedTitlePanel, imTitleBar);
    setTitleBarPanel();

    /*-- Exit --*/
    readPanel(releasedExitIm, releasedExitPanel, pressedExitIm, pressedExitPanel, imTitleBar);
    setExitPanel();

    /*-- Minimize --*/
    readPanel(releasedMinimizeIm, releasedMinimizePanel, pressedMinimizeIm, pressedMinimizePanel, imTitleBar);
    setMinimizePanel();

    /*-- Mode --*/
    readPanel(activeModeImage, activeModePanel, passiveModeImage, passiveModePanel, imMode);
    offScreenGraphics.drawImage(passiveModeImage[0], stereoLocation[0], stereoLocation[1], this);
    offScreenGraphics.drawImage(passiveModeImage[1], monoLocation[0], monoLocation[1], this);

    /*-- Text --*/
    sampleRateClearImage = (new Taftb(fontIndex, imText, fontWidth, fontHeight, 0, sampleRateClearText))
            .getBanner();
    bitsRateClearImage = (new Taftb(fontIndex, imText, fontWidth, fontHeight, 0, bitsRateClearText))
            .getBanner();
    clearImage = (new Taftb(fontIndex, imText, fontWidth, fontHeight, 0, clearText)).getBanner(0, 0, 155, 6);
    titleImage = (new Taftb(fontIndex, imText, fontWidth, fontHeight, 0, titleText)).getBanner(0, 0, 155, 6);
    offScreenGraphics.drawImage(titleImage, titleLocation[0], titleLocation[1], this);

    /*-- Numbers --*/
    for (int h = 0; h < numberIndex.length(); h++) {
        timeImage[h] = (new Taftb(numberIndex, imNumbers, numberWidth, numberHeight, 0,
                "" + numberIndex.charAt(h))).getBanner();
    }

    /*--  Icons --*/
    readPanel(iconsImage, iconsPanel, null, null, imIcons);
    offScreenGraphics.drawImage(iconsImage[2], iconsLocation[0], iconsLocation[1], this);

    /*-- Pos Bar --*/
    readPanel(releasedPosIm, releasedPosPanel, pressedPosIm, pressedPosPanel, imPosBar);
    setPosBarPanel();

    /*-- Equalizer/Playlist/Shuffle/Repeat  --*/
    readPanel(releasedEPSRImage, releasedEPSRPanel, pressedEPSRImage, pressedEPSRPanel, imEPSRButtons);
    setEPSRButtonsPanel();

    // Popup menu on TitleBar
    PopupMenu mainpopup = new PopupMenu("Setup");
    Font fnt = new Font("Dialog", Font.PLAIN, 11);
    mainpopup.setFont(fnt);
    MenuItem mi = new MenuItem(TITLETEXT + "- JavaZOOM");
    //mi.setEnabled(false);
    mi.addActionListener(this);
    mainpopup.add(mi);
    mainpopup.addSeparator();
    mi = new MenuItem("Preferences");
    // TODO
    mi.setEnabled(false);
    mi.addActionListener(this);
    mainpopup.add(mi);
    mi = new MenuItem("Load Skin");
    //mi.setEnabled(false);
    mi.addActionListener(this);
    mainpopup.add(mi);
    //mainpopup.addSeparator();
    mi = new MenuItem("Exit");
    mi.addActionListener(this);
    mainpopup.add(mi);
    acTitleBar.setPopup(mainpopup);

    /* -- create MP3File List Window --*/
    if (showPlaylist != null)
        config.setPlaylistEnabled(true);
    fileList = new MP3Files(topFrame, this, playlist, skl, OrigineX, OrigineY + WinHeight,
            config.isPlaylistEnabled());

    /* -- create Equalizer Window --*/
    if (showEqualizer != null)
        config.setEqualizerEnabled(true);
    int factor = 1;
    if (config.isPlaylistEnabled())
        factor = 2;
    equalizer = new Equalizer(topFrame, this, skl, OrigineX, OrigineY + WinHeight * factor,
            config.isEqualizerEnabled());
    show();
}

From source file:javazoom.jlgui.player.amp.PlayerApplet.java

/**
 * Loads a skin from a SkinLoader.//w  w  w  .j  a va  2  s .com
 */
protected void loadSkin(SkinLoader skl) throws Exception {
    skl.loadImages();
    imMain = skl.getImage(theMain);
    imButtons = skl.getImage(theButtons);
    imTitleBar = skl.getImage(theTitleBar);
    imText = skl.getImage(theText);
    imMode = skl.getImage(theMode);
    imNumbers = skl.getImage(theNumbers);
    // add by John Yang
    if (imNumbers == null) {
        log.info("Try load nums_ex.bmp !");
        imNumbers = skl.getImage(theNumEx);
    }
    imVolume = skl.getImage(theVolume);
    imBalance = skl.getImage(theBalance);
    imIcons = skl.getImage(theIcons);
    imPosBar = skl.getImage(thePosBar);
    imEPSRButtons = skl.getImage(theEPSRButtons);

    // Computes volume slider height :
    int vh = (imVolume.getHeight(null) - 422);
    if (vh > 0) {
        releasedVolumePanel0[3] = vh;
        pressedVolumePanel0[3] = vh;
        releasedVolumePanel1[3] = vh;
        pressedVolumePanel1[3] = vh;
    }
    // Computes balance slider height :
    if (imBalance == null)
        imBalance = imVolume;
    int bh = (imBalance.getHeight(null) - 422);
    if (bh > 0) {
        releasedBalancePanel0[3] = bh;
        pressedBalancePanel0[3] = bh;
        releasedBalancePanel1[3] = bh;
        pressedBalancePanel1[3] = bh;
    }

    // Compute posbar height.
    int ph = imPosBar.getHeight(null);
    if (ph > 0) {
        releasedPosPanel[3] = ph;
        pressedPosPanel[3] = ph;
    }

    WinHeight = imMain.getHeight(this); // 275
    WinWidth = imMain.getWidth(this); // 116
    setSize(WinWidth, WinHeight);
    setLocation(OrigineX, OrigineY);
    //setBackground(Color.black);
    show();

    offScreenImage = createImage(WinWidth, WinHeight);
    offScreenGraphics = offScreenImage.getGraphics();
    // E.B Fix for JDK 1.4 slow down problem.
    hide();
    // End Fix.
    offScreenGraphics.drawImage(imMain, 0, 0, this);

    // M.S : Remove all components when loading a new skin.
    if (acPrevious != null)
        remove(acPrevious);
    if (acPlay != null)
        remove(acPlay);
    if (acPause != null)
        remove(acPause);
    if (acStop != null)
        remove(acStop);
    if (acNext != null)
        remove(acNext);
    if (acEject != null)
        remove(acEject);
    if (acTitleBar != null)
        remove(acTitleBar);
    if (acExit != null)
        remove(acExit);
    if (acMinimize != null)
        remove(acMinimize);
    if (acVolume != null)
        remove((Component) acVolume);
    if (acBalance != null)
        remove((Component) acBalance);
    if (acPosBar != null)
        remove(acPosBar);
    if (acPlaylist != null)
        remove(acPlaylist);
    if (acRepeat != null)
        remove(acRepeat);
    if (acShuffle != null)
        remove(acShuffle);
    if (acEqualizer != null)
        remove(acEqualizer);
    if (fileList != null)
        remove(fileList);
    if (equalizer != null)
        remove(equalizer);
    System.gc();

    /*-- Buttons --*/
    readPanel(releasedImage, releasedPanel, pressedImage, pressedPanel, imButtons);
    setButtonsPanel();

    /*-- Volume/Balance --*/
    if (skinVersion.equals("1")) {
        readPanel(releasedVolumeImage, releasedVolumePanel0, pressedVolumeImage, pressedVolumePanel0, imVolume);
        readPanel(releasedBalanceImage, releasedBalancePanel0, pressedBalanceImage, pressedBalancePanel0,
                imBalance);
    } else {
        readPanel(releasedVolumeImage, releasedVolumePanel1, pressedVolumeImage, pressedVolumePanel1, imVolume);
        readPanel(releasedBalanceImage, releasedBalancePanel1, pressedBalanceImage, pressedBalancePanel1,
                imBalance);
    }
    setVolumeBalancePanel(vh, bh);

    /*-- Title Bar --*/
    readPanel(releasedTitleIm, releasedTitlePanel, pressedTitleIm, pressedTitlePanel, imTitleBar);
    setTitleBarPanel();

    /*-- Exit --*/
    readPanel(releasedExitIm, releasedExitPanel, pressedExitIm, pressedExitPanel, imTitleBar);
    setExitPanel();

    /*-- Minimize --*/
    readPanel(releasedMinimizeIm, releasedMinimizePanel, pressedMinimizeIm, pressedMinimizePanel, imTitleBar);
    setMinimizePanel();

    /*-- Mode --*/
    readPanel(activeModeImage, activeModePanel, passiveModeImage, passiveModePanel, imMode);
    offScreenGraphics.drawImage(passiveModeImage[0], stereoLocation[0], stereoLocation[1], this);
    offScreenGraphics.drawImage(passiveModeImage[1], monoLocation[0], monoLocation[1], this);

    /*-- Text --*/
    sampleRateClearImage = (new Taftb(fontIndex, imText, fontWidth, fontHeight, 0, sampleRateClearText))
            .getBanner();
    bitsRateClearImage = (new Taftb(fontIndex, imText, fontWidth, fontHeight, 0, bitsRateClearText))
            .getBanner();
    clearImage = (new Taftb(fontIndex, imText, fontWidth, fontHeight, 0, clearText)).getBanner(0, 0, 155, 6);
    titleImage = (new Taftb(fontIndex, imText, fontWidth, fontHeight, 0, titleText)).getBanner(0, 0, 155, 6);
    offScreenGraphics.drawImage(titleImage, titleLocation[0], titleLocation[1], this);

    /*-- Numbers --*/
    for (int h = 0; h < numberIndex.length(); h++) {
        timeImage[h] = (new Taftb(numberIndex, imNumbers, numberWidth, numberHeight, 0,
                "" + numberIndex.charAt(h))).getBanner();
    }

    /*--  Icons --*/
    readPanel(iconsImage, iconsPanel, null, null, imIcons);
    offScreenGraphics.drawImage(iconsImage[2], iconsLocation[0], iconsLocation[1], this);

    /*-- Pos Bar --*/
    readPanel(releasedPosIm, releasedPosPanel, pressedPosIm, pressedPosPanel, imPosBar);
    setPosBarPanel();

    /*-- Equalizer/Playlist/Shuffle/Repeat  --*/
    readPanel(releasedEPSRImage, releasedEPSRPanel, pressedEPSRImage, pressedEPSRPanel, imEPSRButtons);
    setEPSRButtonsPanel();

    // Popup menu on TitleBar
    PopupMenu mainpopup = new PopupMenu("Setup");
    Font fnt = new Font("Dialog", Font.PLAIN, 11);
    mainpopup.setFont(fnt);
    MenuItem mi = new MenuItem(TITLETEXT + "- JavaZOOM");
    mi.setEnabled(false);
    mi.addActionListener(this);
    mainpopup.add(mi);
    mainpopup.addSeparator();
    mi = new MenuItem("Preferences");
    mi.setEnabled(false);
    mi.addActionListener(this);
    mainpopup.add(mi);
    mi = new MenuItem("Skins");
    mi.setEnabled(false);
    mi.addActionListener(this);
    mainpopup.add(mi);
    mainpopup.addSeparator();
    mi = new MenuItem("Exit");
    mi.setEnabled(false);
    mi.addActionListener(this);
    mainpopup.add(mi);
    acTitleBar.setPopup(mainpopup);

    /* -- create MP3File List Window --*/
    if (showPlaylist != null)
        config.setPlaylistEnabled(true);
    fileList = new MP3FilesApplet(topFrame, this, playlist, skl, OrigineX, OrigineY + WinHeight,
            config.isPlaylistEnabled());
    add(fileList);

    /* -- create Equalizer Window --*/
    if (showEqualizer != null)
        config.setEqualizerEnabled(true);
    int factor = 1;
    if (config.isPlaylistEnabled())
        factor = 2;
    equalizer = new EqualizerApplet(topFrame, this, skl, OrigineX, OrigineY + WinHeight * factor,
            config.isEqualizerEnabled());
    add(equalizer);
    show();
}

From source file:org.yccheok.jstock.gui.MainFrame.java

private void createSystemTrayIcon() {
    if (SystemTray.isSupported()) {
        SystemTray tray = SystemTray.getSystemTray();
        final Image image;
        if (Utils.isWindows7() || Utils.isWindows8()) {
            image = new javax.swing.ImageIcon(getClass().getResource("/images/128x128/chart.png")).getImage();
        } else {//from w ww.j  a  va 2  s.co  m
            image = new javax.swing.ImageIcon(getClass().getResource("/images/16x16/chart.png")).getImage();
        }

        MouseListener mouseListener = new MouseListener() {

            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getButton() == MouseEvent.BUTTON1) {
                    MainFrame.this.setVisible(true);
                    MainFrame.this.setState(Frame.NORMAL);
                }
            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseExited(MouseEvent e) {
            }

            @Override
            public void mousePressed(MouseEvent e) {
            }

            @Override
            public void mouseReleased(MouseEvent e) {
            }
        };

        ActionListener exitListener = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                MainFrame.this.setVisible(false);
                MainFrame.this.dispose();
            }
        };

        PopupMenu popup = new PopupMenu();
        MenuItem defaultItem = new MenuItem(
                java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui").getString("MainFrame_Exit"));
        defaultItem.addActionListener(exitListener);
        popup.add(defaultItem);

        trayIcon = new TrayIcon(image, GUIBundle.getString("MainFrame_Application_Title"), popup);

        ActionListener actionListener = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
            }
        };

        trayIcon.setImageAutoSize(true);
        trayIcon.addActionListener(actionListener);
        trayIcon.addMouseListener(mouseListener);

        try {
            tray.add(trayIcon);
        } catch (AWTException e) {
            trayIcon = null;
            JOptionPane.showMessageDialog(MainFrame.this,
                    java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages")
                            .getString("warning_message_trayicon_could_not_be_added"),
                    java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages").getString(
                            "warning_title_trayicon_could_not_be_added"),
                    JOptionPane.WARNING_MESSAGE);
        }

    } else {
        //  System Tray is not supported
        trayIcon = null;
        JOptionPane.showMessageDialog(MainFrame.this,
                java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages")
                        .getString("warning_message_system_tray_is_not_supported"),
                java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/messages")
                        .getString("warning_title_system_tray_is_not_supported"),
                JOptionPane.WARNING_MESSAGE);
    }
}