List of usage examples for java.awt MenuItem addActionListener
public synchronized void addActionListener(ActionListener l)
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);//from www .j a va 2s . c om // Check clipboard text: MenuItem checkClipboardItem = new MenuItem(Tools.getLabel(messages.getString("guiMenuCheckClipboard"))); checkClipboardItem.addActionListener(rmbListener); popup.add(checkClipboardItem); // 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:AppearanceTest.java
public Menu createMenu() { String szName = getName();/*from w w w .j a v a2 s . c o m*/ String[] itemArray = getMenuItemNames(); ActionListener listener = this; Menu menu = new Menu(szName); MenuItem menuItem = new MenuItem("Null"); menuItem.addActionListener(listener); menu.add(menuItem); menuItem = new MenuItem("Non_Null"); menuItem.addActionListener(listener); menu.add(menuItem); for (int n = 0; n < itemArray.length; n++) { menuItem = new MenuItem(itemArray[n]); menuItem.addActionListener(listener); menu.add(menuItem); } return menu; }
From source file:javazoom.jlgui.player.amp.Player.java
/** * Loads a skin from a SkinLoader.//from w w w . ja v a 2s . 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:com.jsystem.j2autoit.AutoItAgent.java
private static void createAndShowGUI() { //Check the SystemTray support if (!SystemTray.isSupported()) { Log.error("SystemTray is not supported\n"); return;// w ww. j av a2s .c om } 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:javazoom.jlgui.player.amp.PlayerApplet.java
/** * Loads a skin from a SkinLoader./* ww w .j a v a 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 w w .ja v a 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); } }
From source file:org.yccheok.jstock.gui.JStock.java
private void createSystemTrayIcon() { if (SystemTray.isSupported()) { SystemTray tray = SystemTray.getSystemTray(); final Image image = new javax.swing.ImageIcon(getClass().getResource("/images/128x128/chart.png")) .getImage();//w ww. ja v a 2 s .c o m MouseListener mouseListener = new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { JStock.this.setVisible(true); JStock.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) { JStock.this.setVisible(false); JStock.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(JStock.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(JStock.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); } }