List of usage examples for java.awt PopupMenu PopupMenu
public PopupMenu(String label) throws HeadlessException
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 w w w . ja v a2s . c o 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: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 w w w . j av a 2s. c o m 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.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultTreeView.java
private PopupMenu createPopupMenu(final ViewState state) { final String ACTIONS_POP_MENU_NAME = "Actions"; final String VIEW_CONDITION_MAP = "View..."; PopupMenu actionsMenu = new PopupMenu(ACTIONS_POP_MENU_NAME); actionsMenu.add(new MenuItem(VIEW_CONDITION_MAP)); actionsMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals(VIEW_CONDITION_MAP)) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getSelectionPath() .getLastPathComponent(); ModelGraph graphToFocus = null; if (Boolean.parseBoolean(state.getFirstPropertyValue(EXPAND_PRECONDITIONS)) || Boolean.parseBoolean(state.getFirstPropertyValue(EXPAND_POSTCONDITIONS))) { // if (node.getUserObject() instanceof String && // (node.getUserObject().equals("pre-conditions") || // node.getUserObject().equals("post-conditions"))) { ModelGraph graph = state.getSelected(); if (Boolean.parseBoolean(state.getFirstPropertyValue(EXPAND_PRECONDITIONS))) { graphToFocus = graph.getPreConditions(); } else { graphToFocus = graph.getPostConditions(); }/*www . ja v a 2 s.c om*/ } else if (node.getUserObject() instanceof ModelGraph) { graphToFocus = (ModelGraph) node.getUserObject(); } DefaultTreeView.this .notifyListeners(new ViewChange.NEW_VIEW(graphToFocus, DefaultTreeView.this)); } } }); final String ORDER_SUB_POP_MENU_NAME = "Order"; final String TO_FRONT_ITEM_NAME = "Move To Front"; final String TO_BACK_ITEM_NAME = "Move To Back"; final String FORWARD_ITEM_NAME = "Move Forward"; final String BACKWARDS_ITEM_NAME = "Move Backwards"; actionsMenu.add(orderSubMenu = new PopupMenu(ORDER_SUB_POP_MENU_NAME)); orderSubMenu.add(new MenuItem(TO_FRONT_ITEM_NAME)); orderSubMenu.add(new MenuItem(TO_BACK_ITEM_NAME)); orderSubMenu.add(new MenuItem(FORWARD_ITEM_NAME)); orderSubMenu.add(new MenuItem(BACKWARDS_ITEM_NAME)); orderSubMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ModelGraph graph = state.getSelected(); ModelGraph parent = graph.getParent(); if (e.getActionCommand().equals(TO_FRONT_ITEM_NAME)) { if (parent.getChildren().remove(graph)) { parent.getChildren().add(0, graph); } } else if (e.getActionCommand().equals(TO_BACK_ITEM_NAME)) { if (parent.getChildren().remove(graph)) { parent.getChildren().add(graph); } } else if (e.getActionCommand().equals(FORWARD_ITEM_NAME)) { int index = parent.getChildren().indexOf(graph); if (index != -1) { parent.getChildren().remove(index); parent.getChildren().add(Math.max(0, index + 1), graph); } } else if (e.getActionCommand().equals(BACKWARDS_ITEM_NAME)) { int index = parent.getChildren().indexOf(graph); if (index != -1) { parent.getChildren().remove(index); parent.getChildren().add(Math.max(0, index - 1), graph); } } DefaultTreeView.this.notifyListeners(); DefaultTreeView.this.refreshView(state); } }); return actionsMenu; }
From source file:javazoom.jlgui.player.amp.Player.java
/** * Loads a skin from a SkinLoader.//from ww w. j a va2 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:jatoo.app.App.java
private PopupMenu getTrayIconPopup() { MenuItem openItem = new MenuItem(getText("popup.open") + " " + getTitle()); openItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { show();//from w w w .j a v a 2 s .c o m } }); MenuItem hideItem = new MenuItem(getText("popup.hide") + " " + getTitle()); hideItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { hide(); } }); CheckboxMenuItem hideWhenMinimizedItem = new CheckboxMenuItem(getText("popup.hide_when_minimized"), isHideWhenMinimized()); hideWhenMinimizedItem.addItemListener(new ItemListener() { public void itemStateChanged(final ItemEvent e) { setHideWhenMinimized(e.getStateChange() == ItemEvent.SELECTED); } }); MenuItem sendToBackItem = new MenuItem(getText("popup.send_to_back")); sendToBackItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { sendToBack(); } }); MenuItem closeItem = new MenuItem(getText("popup.close")); closeItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { System.exit(0); } }); // // Font font = new JMenuItem().getFont(); if (font != null) { openItem.setFont(font.deriveFont(Font.BOLD)); hideItem.setFont(font); hideWhenMinimizedItem.setFont(font); sendToBackItem.setFont(font); closeItem.setFont(font); } // // the popup PopupMenu popup = new PopupMenu(getTitle()); popup.add(openItem); popup.add(hideItem); popup.addSeparator(); popup.add(hideWhenMinimizedItem); popup.addSeparator(); popup.add(sendToBackItem); popup.addSeparator(); popup.add(closeItem); return popup; }
From source file:javazoom.jlgui.player.amp.PlayerApplet.java
/** * Loads a skin from a SkinLoader.//from w w w. jav a 2s .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(); }