Example usage for java.awt PopupMenu addSeparator

List of usage examples for java.awt PopupMenu addSeparator

Introduction

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

Prototype

public void addSeparator() 

Source Link

Document

Adds a separator line, or a hypen, to the menu at the current position.

Usage

From source file:com.jsystem.j2autoit.AutoItAgent.java

private static void createAndShowGUI() {
    //Check the SystemTray support
    if (!SystemTray.isSupported()) {
        Log.error("SystemTray is not supported\n");
        return;//from   ww w. j  a v  a2 s  .c  o  m
    }
    final PopupMenu popup = new PopupMenu();
    final TrayIcon trayIcon = new TrayIcon(createImage("images/jsystem_ico.gif", "tray icon"));
    final SystemTray tray = SystemTray.getSystemTray();

    // Create a popup menu components
    final MenuItem aboutItem = new MenuItem("About");
    final MenuItem startAgentItem = new MenuItem("Start J2AutoIt Agent");
    final MenuItem stopAgentItem = new MenuItem("Stop J2AutoIt Agent");
    final MenuItem exitItem = new MenuItem("Exit");
    final MenuItem changePortItem = new MenuItem("Setting J2AutoIt Port");
    final MenuItem deleteTemporaryFilesItem = new MenuItem("Delete J2AutoIt Script");
    final MenuItem temporaryHistoryFilesItem = new MenuItem("History Size");
    final MenuItem displayLogFile = new MenuItem("Log");
    final MenuItem forceShutDownTimeOutItem = new MenuItem("Force ShutDown TimeOut");
    final MenuItem writeConfigurationToFile = new MenuItem("Save Configuration To File");
    final CheckboxMenuItem debugModeItem = new CheckboxMenuItem("Debug Mode", isDebug);
    final CheckboxMenuItem forceAutoItShutDownItem = new CheckboxMenuItem("Force AutoIt Script ShutDown",
            isForceAutoItShutDown);
    final CheckboxMenuItem autoDeleteHistoryItem = new CheckboxMenuItem("Auto Delete History",
            isAutoDeleteFiles);
    final CheckboxMenuItem useAutoScreenShot = new CheckboxMenuItem("Auto Screenshot", isUseScreenShot);

    //Add components to popup menu
    popup.add(aboutItem);
    popup.add(writeConfigurationToFile);
    popup.addSeparator();
    popup.add(forceAutoItShutDownItem);
    popup.add(forceShutDownTimeOutItem);
    popup.addSeparator();
    popup.add(debugModeItem);
    popup.add(displayLogFile);
    popup.add(useAutoScreenShot);
    popup.addSeparator();
    popup.add(autoDeleteHistoryItem);
    popup.add(deleteTemporaryFilesItem);
    popup.add(temporaryHistoryFilesItem);
    popup.addSeparator();
    popup.add(changePortItem);
    popup.addSeparator();
    popup.add(startAgentItem);
    popup.add(stopAgentItem);
    popup.addSeparator();
    popup.add(exitItem);

    trayIcon.setToolTip("J2AutoIt Agent");
    trayIcon.setImageAutoSize(true);
    trayIcon.setPopupMenu(popup);
    final DisplayLogFile displayLog = new DisplayLogFile();
    try {
        tray.add(trayIcon);
    } catch (AWTException e) {
        Log.error("TrayIcon could not be added.\n");
        return;
    }

    trayIcon.addMouseListener(new MouseListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }

        @Override
        public void mousePressed(MouseEvent e) {
            startAgentItem.setEnabled(!serverState);
            stopAgentItem.setEnabled(serverState);
            deleteTemporaryFilesItem.setEnabled(isDebug && HistoryFile.containEntries());
            autoDeleteHistoryItem.setEnabled(isDebug);
            temporaryHistoryFilesItem.setEnabled(isDebug && isAutoDeleteFiles);
            displayLogFile.setEnabled(isDebug);
            forceShutDownTimeOutItem.setEnabled(isForceAutoItShutDown);
        }

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

    writeConfigurationToFile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            AutoItProperties.DEBUG_MODE_KEY.setValue(isDebug.toString());
            AutoItProperties.AUTO_DELETE_TEMPORARY_SCRIPT_FILE_KEY.setValue(isAutoDeleteFiles.toString());
            AutoItProperties.AUTO_IT_SCRIPT_HISTORY_SIZE_KEY.setValue(DEFAULT_HistorySize.toString());
            AutoItProperties.FORCE_AUTO_IT_PROCESS_SHUTDOWN_KEY.setValue(isForceAutoItShutDown.toString());
            AutoItProperties.AGENT_PORT_KEY.setValue(webServicePort.toString());
            AutoItProperties.SERVER_UP_ON_INIT_KEY.setValue(serverState.toString());
            if (!AutoItProperties.savePropertiesFileSafely()) {
                Log.error("Fail to save properties file");
            }
        }
    });

    debugModeItem.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            isDebug = (e.getStateChange() == ItemEvent.SELECTED);
            deleteTemporaryFilesItem.setEnabled(isDebug && HistoryFile.containEntries());
            Log.infoLog("Keeping the temp file is " + (isDebug ? "en" : "dis") + "able\n");
            trayIcon.displayMessage((isDebug ? "Debug" : "Normal") + " Mode",
                    "The system will " + (isDebug ? "not " : "") + "delete \nthe temporary autoIt scripts."
                            + (isDebug ? "\nSee log file for more info." : ""),
                    MessageType.INFO);
        }
    });

    useAutoScreenShot.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            isUseScreenShot = (e.getStateChange() == ItemEvent.SELECTED);
            Log.infoLog("Auto screenshot is " + (isUseScreenShot ? "" : "in") + "active\n");
        }
    });

    forceAutoItShutDownItem.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            isForceAutoItShutDown = (e.getStateChange() == ItemEvent.SELECTED);
            Log.infoLog((isForceAutoItShutDown ? "Force" : "Soft") + " AutoIt Script ShutDown\n");
            trayIcon.displayMessage("AutoIt Script Termination",
                    (isForceAutoItShutDown ? "Hard shutdown" : "Soft shutdown"), MessageType.INFO);
        }
    });

    autoDeleteHistoryItem.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            isAutoDeleteFiles = (e.getStateChange() == ItemEvent.SELECTED);
            Log.infoLog((isAutoDeleteFiles ? "Auto" : "Manual") + " AutoIt Script Deletion\n");
            trayIcon.displayMessage("AutoIt Script Deletion", (isAutoDeleteFiles ? "Auto" : "Manual") + " Mode",
                    MessageType.INFO);
            if (isAutoDeleteFiles) {
                HistoryFile.init();
            } else {
                HistoryFile.close();
            }
        }
    });

    forceShutDownTimeOutItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            String timeOutAsString = JOptionPane.showInputDialog(
                    "Please Insert Force ShutDown TimeOut (in seconds)",
                    String.valueOf(shutDownTimeOut / 1000));
            try {
                shutDownTimeOut = 1000 * Long.parseLong(timeOutAsString);
            } catch (Exception e2) {
            }
            Log.infoLog("Setting the force shutdown time out to : " + (shutDownTimeOut / 1000) + " seconds.\n");
        }
    });

    displayLogFile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            try {
                displayLog.reBuild(Log.getCurrentLogs());
                displayLog.actionPerformed(actionEvent);
            } catch (Exception e2) {
            }
        }
    });

    temporaryHistoryFilesItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            String historySize = JOptionPane.showInputDialog("Please Insert History AutoIt Script Files",
                    String.valueOf(HistoryFile.getHistory_Size()));
            try {
                int temp = Integer.parseInt(historySize);
                if (temp > 0) {
                    if (HistoryFile.getHistory_Size() != temp) {
                        HistoryFile.setHistory_Size(temp);
                        Log.infoLog("The history files size is " + historySize + NEW_LINE);
                    }
                } else {
                    Log.warning("Illegal History Size: " + historySize + NEW_LINE);
                }
            } catch (Exception exception) {
                Log.throwableLog(exception.getMessage(), exception);
            }
        }
    });

    deleteTemporaryFilesItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            HistoryFile.forceDeleteAll();
        }
    });

    startAgentItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            runWebServer();
        }
    });

    stopAgentItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            shutDownWebServer();
        }
    });

    aboutItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            JOptionPane.showMessageDialog(null, "J2AutoIt Agent By JSystem And Aqua Software");
        }
    });

    changePortItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            String portAsString = JOptionPane.showInputDialog("Please Insert new Port",
                    String.valueOf(webServicePort));
            if (portAsString != null) {
                try {
                    int temp = Integer.parseInt(portAsString);
                    if (temp > 1000) {
                        if (temp != webServicePort) {
                            webServicePort = temp;
                            shutDownWebServer();
                            startAutoItWebServer(webServicePort);
                            runWebServer();
                        }
                    } else {
                        Log.warning("Port number should be greater then 1000\n");
                    }
                } catch (Exception exception) {
                    Log.error("Illegal port number\n");
                    return;
                }
            }
        }
    });

    exitItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            tray.remove(trayIcon);
            shutDownWebServer();
            Log.info("Exiting from J2AutoIt Agent\n");
            System.exit(0);
        }
    });
}

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

/**
 * Creates the Pop-up menu for System Tray Icon
 * /*w  w  w.  jav a  2 s . c o  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
    MenuItem shutdownItem = new MenuItem("Shutdown");
    shutdownItem.addActionListener(new ActionListener() {

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

    });
    trayPopup.add(shutdownItem);

    return trayPopup;
}

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

/**
 * System Tray Icon Pop Up Menu//  w w w . j a v a2 s . c o 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 ww w . ja  v a  2s . co  m

    });

    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:org.shelloid.vpt.agent.App.java

private void setupSystemTray() {
    if (SystemTray.isSupported()) {
        try {//from ww w  . j  a  v a2  s.  co  m
            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./*from  ww  w  .j a  v  a 2 s  .c om*/
 */
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:org.exist.launcher.Launcher.java

private PopupMenu createMenu() {

    final PopupMenu popup = new PopupMenu();
    startItem = new MenuItem("Start server");
    popup.add(startItem);/*www .  j  a  v  a2 s  .c  o m*/
    startItem.addActionListener(actionEvent -> {
        if (jetty.isPresent()) {
            jetty.ifPresent(server -> {
                if (server.isStarted()) {
                    showTrayMessage("Server already started", TrayIcon.MessageType.WARNING);
                } else {
                    server.run(new String[] { jettyConfig.toAbsolutePath().toString() }, null);
                    if (server.isStarted()) {
                        showTrayMessage("eXist-db server running on port " + server.getPrimaryPort(),
                                TrayIcon.MessageType.INFO);
                    }
                }
                setServiceState();
            });
        } else if (runningAsService.isPresent()) {
            showTrayMessage("Starting the eXistdb service. Please wait...", TrayIcon.MessageType.INFO);
            if (runningAsService.get().start()) {
                showTrayMessage("eXistdb service started", TrayIcon.MessageType.INFO);
            } else {
                showTrayMessage("Starting eXistdb service failed", TrayIcon.MessageType.ERROR);
            }
            setServiceState();
        }
    });

    stopItem = new MenuItem("Stop server");
    popup.add(stopItem);
    stopItem.addActionListener(actionEvent -> {
        if (jetty.isPresent()) {
            jetty.get().shutdown();
            setServiceState();
            showTrayMessage("eXist-db stopped", TrayIcon.MessageType.INFO);
        } else if (runningAsService.isPresent()) {
            if (runningAsService.get().stop()) {
                showTrayMessage("eXistdb service stopped", TrayIcon.MessageType.INFO);
            } else {
                showTrayMessage("Stopping eXistdb service failed", TrayIcon.MessageType.ERROR);
            }
            setServiceState();
        }
    });

    popup.addSeparator();
    final MenuItem configItem = new MenuItem("System Configuration");
    popup.add(configItem);
    configItem.addActionListener(e -> EventQueue.invokeLater(() -> {
        configDialog.open(false);
        configDialog.toFront();
        configDialog.repaint();
        configDialog.requestFocus();
    }));

    if (SystemUtils.IS_OS_WINDOWS) {
        canUseServices = true;
    } else {
        isRoot((root) -> canUseServices = root);
    }

    final String requiresRootMsg;
    if (canUseServices) {
        requiresRootMsg = "";
    } else {
        requiresRootMsg = " (requires root)";
    }

    installServiceItem = new MenuItem("Install as service" + requiresRootMsg);

    popup.add(installServiceItem);
    installServiceItem.setEnabled(canUseServices);
    installServiceItem.addActionListener(e -> SwingUtilities.invokeLater(this::installAsService));

    uninstallServiceItem = new MenuItem("Uninstall service" + requiresRootMsg);
    popup.add(uninstallServiceItem);
    uninstallServiceItem.setEnabled(canUseServices);
    uninstallServiceItem.addActionListener(e -> SwingUtilities.invokeLater(this::uninstallService));

    if (SystemUtils.IS_OS_WINDOWS) {
        showServices = new MenuItem("Show services console");
        popup.add(showServices);
        showServices.addActionListener(e -> SwingUtilities.invokeLater(this::showServicesConsole));
    }
    popup.addSeparator();

    final MenuItem toolbar = new MenuItem("Show tool window");
    popup.add(toolbar);
    toolbar.addActionListener(actionEvent -> EventQueue.invokeLater(() -> {
        utilityPanel.toFront();
        utilityPanel.setVisible(true);
    }));

    MenuItem item;

    if (Desktop.isDesktopSupported()) {
        popup.addSeparator();
        final Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Desktop.Action.BROWSE)) {
            dashboardItem = new MenuItem("Open Dashboard");
            popup.add(dashboardItem);
            dashboardItem.addActionListener(actionEvent -> dashboard(desktop));
            eXideItem = new MenuItem("Open eXide");
            popup.add(eXideItem);
            eXideItem.addActionListener(actionEvent -> eXide(desktop));
            item = new MenuItem("Open Java Admin Client");
            popup.add(item);
            item.addActionListener(actionEvent -> client());
            monexItem = new MenuItem("Open Monitoring and Profiling");
            popup.add(monexItem);
            monexItem.addActionListener(actionEvent -> monex(desktop));
        }
        if (desktop.isSupported(Desktop.Action.OPEN)) {
            popup.addSeparator();
            item = new MenuItem("Open exist.log");
            popup.add(item);
            item.addActionListener(new LogActionListener());
        }

        popup.addSeparator();
        quitItem = new MenuItem("Quit (and stop server)");
        popup.add(quitItem);
        quitItem.addActionListener(actionEvent -> shutdown(false));

        setServiceState();
    }
    return popup;
}

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

/**
 * Loads a skin from a SkinLoader.//ww w . j a  v  a  2  s.  c o 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)
        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();
}