List of usage examples for java.awt.event ActionEvent getSource
public Object getSource()
From source file:net.java.sip.communicator.impl.osdependent.jdic.TrayMenuFactory.java
/** * Handles the <tt>ActionEvent</tt> when one of the menu items is selected. * * @param evt the event containing the menu item name */// w ww .j a v a2 s. c o m private static void actionPerformed(ActionEvent evt) { Object source = evt.getSource(); String itemName; if (source instanceof JMenuItem) { JMenuItem menuItem = (JMenuItem) source; itemName = menuItem.getName(); } else { MenuItem menuItem = (MenuItem) source; itemName = menuItem.getName(); } if (itemName.equals("settings")) { OsDependentActivator.getUIService().getConfigurationContainer().setVisible(true); } else if (itemName.equals("service.gui.QUIT")) { OsDependentActivator.getShutdownService().beginShutdown(); } else if (itemName.equals("addContact")) { ExportedWindow dialog = OsDependentActivator.getUIService() .getExportedWindow(ExportedWindow.ADD_CONTACT_WINDOW); if (dialog != null) dialog.setVisible(true); else OsDependentActivator.getUIService().getPopupDialog().showMessagePopupDialog( Resources.getString("impl.systray.FAILED_TO_OPEN_ADD_CONTACT_DIALOG")); } else if (itemName.equals("service.gui.SHOW")) { OsDependentActivator.getUIService().setVisible(true); OsDependentActivator.getUIService().bringToFront(); changeTrayMenuItem(source, "service.gui.HIDE", "service.gui.HIDE", "service.gui.icons.SEARCH_ICON_16x16"); } else if (itemName.equals("service.gui.HIDE")) { OsDependentActivator.getUIService().setVisible(false); changeTrayMenuItem(source, "service.gui.SHOW", "service.gui.SHOW", "service.gui.icons.SEARCH_ICON_16x16"); } }
From source file:edu.ku.brc.util.AttachmentUtils.java
/** * @return the actionlistener for when things need to be displayed *///w w w . ja v a 2s. co m public static ActionListener getAttachmentDisplayer() { ActionListener displayer = new ActionListener() { public void actionPerformed(ActionEvent e) { File original = getAttachmentFile(e.getSource()); String errMsg = null; if (original != null && original.exists()) { try { openFile(original); } catch (Exception ex) { UIRegistry.showLocalizedMsg("AttachmentUtils.NEV_TITLE", "AttachmentUtils.NEV_MSG"); } } else { errMsg = attachMgr.getDirectory() != null ? attachMgr.getDirectory().getAbsolutePath() : "N/A"; } if (errMsg != null) { UIRegistry.showLocalizedMsg("AttachmentUtils.ANF_TITLE", "AttachmentUtils.ANF", errMsg); } } }; return displayer; }
From source file:net.sf.firemox.stack.EventManager.java
/** * Create an instance of MEventManager by reading a file * /*w w w . j a v a2 s .co m*/ * @since 0.31 graphical representation of phases for both players */ public static void init() { MPhase.optionsMenu = new JPopupMenu(); JCheckBoxMenuItem item = new JCheckBoxMenuItem(LanguageManager.getString("breakpoint"), new javax.swing.ImageIcon(IdConst.IMAGES_DIR + "breakpoint.gif")); item.setFont(MToolKit.defaultFont); item.setToolTipText("<html>" + LanguageManager.getString("breakpoint.tooltip")); item.setMnemonic('b'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { MPhase.triggerPhase.setBreakpoint(((JCheckBoxMenuItem) evt.getSource()).isSelected()); MPhase.triggerPhase.repaint(); } }); MPhase.optionsMenu.add(item); item = new JCheckBoxMenuItem(LanguageManager.getString("skipPhase"), UIHelper.getIcon("skipall1.gif")); item.setFont(MToolKit.defaultFont); item.setToolTipText("<html>" + LanguageManager.getString("skipPhase.tooltip")); item.setMnemonic('l'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { MPhase.triggerPhase.setSkipAll(((JCheckBoxMenuItem) evt.getSource()).isSelected()); MPhase.triggerPhase.repaint(); } }); MPhase.optionsMenu.add(item); item = new JCheckBoxMenuItem(LanguageManager.getString("skipPhaseOnce"), UIHelper.getIcon("skipall2.gif")); item.setFont(MToolKit.defaultFont); item.setToolTipText("<html>" + LanguageManager.getString("skipPhaseOnce.tooltip") + "<br><br>" + MagicUIComponents.HTML_ICON_TIP + LanguageManager.getString("skipPhaseOnceTTtip")); item.setMnemonic('o'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { MPhase.triggerPhase.setSkipAllTmp(((JCheckBoxMenuItem) evt.getSource()).isSelected()); MPhase.triggerPhase.repaint(); } }); MPhase.optionsMenu.add(item); item = new JCheckBoxMenuItem(LanguageManager.getString("skipPhaseMedium"), UIHelper.getIcon("skipallm2.gif")); item.setFont(MToolKit.defaultFont); item.setToolTipText("<html>" + LanguageManager.getString("skipPhaseMedium.tooltip") + "<br>" + MagicUIComponents.HTML_ICON_WARNING + LanguageManager.getString("skipPhaseAllTTwarn")); item.setMnemonic('m'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { MPhase.triggerPhase.setSkipMedium(((JCheckBoxMenuItem) evt.getSource()).isSelected()); MPhase.triggerPhase.repaint(); } }); MPhase.optionsMenu.add(item); item = new JCheckBoxMenuItem(LanguageManager.getString("skipPhaseMediumOnce"), UIHelper.getIcon("skipallm.gif")); item.setFont(MToolKit.defaultFont); item.setToolTipText("<html>" + LanguageManager.getString("skipPhaseMediumOnce.tooltip") + "<br>" + MagicUIComponents.HTML_ICON_WARNING + LanguageManager.getString("skipPhaseAllTTwarn")); item.setMnemonic('p'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { MPhase.triggerPhase.setSkipMediumTmp(((JCheckBoxMenuItem) evt.getSource()).isSelected()); MPhase.triggerPhase.repaint(); } }); MPhase.optionsMenu.add(item); item = new JCheckBoxMenuItem(LanguageManager.getString("skipPhaseAll"), UIHelper.getIcon("skipall3.gif")); item.setFont(MToolKit.defaultFont); item.setToolTipText("<html>" + LanguageManager.getString("skipPhaseAll.tooltip") + "<br>" + MagicUIComponents.HTML_ICON_WARNING + LanguageManager.getString("skipPhaseAllTTwarn")); item.setMnemonic('u'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { MPhase.triggerPhase.setSkipAllVery(((JCheckBoxMenuItem) evt.getSource()).isSelected()); MPhase.triggerPhase.repaint(); } }); MPhase.optionsMenu.add(item); item = new JCheckBoxMenuItem(LanguageManager.getString("skipPhaseAllOnce"), UIHelper.getIcon("skipall4.gif")); item.setFont(MToolKit.defaultFont); item.setToolTipText("<html>" + LanguageManager.getString("skipPhaseAllOnce.tooltip") + "<br>" + MagicUIComponents.HTML_ICON_WARNING + LanguageManager.getString("skipPhaseAllTTwarn")); item.setMnemonic('t'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { MPhase.triggerPhase.setSkipAllVeryTmp(((JCheckBoxMenuItem) evt.getSource()).isSelected()); MPhase.triggerPhase.repaint(); } }); MPhase.optionsMenu.add(item); }
From source file:com.limegroup.gnutella.gui.GUIUtils.java
/** * Returns (possibly constructing) the ESC action. *///ww w . ja v a2 s . co m public static Action getDisposeAction() { if (ACTION_DISPOSE == null) { ACTION_DISPOSE = new AbstractAction() { /** * */ private static final long serialVersionUID = 3219036624812939826L; public void actionPerformed(ActionEvent ae) { Window parent; if (ae.getSource() instanceof Window) parent = (Window) ae.getSource(); else parent = SwingUtilities.getWindowAncestor((Component) ae.getSource()); if (parent != null) parent.dispatchEvent(new WindowEvent(parent, WindowEvent.WINDOW_CLOSING)); } }; } return ACTION_DISPOSE; }
From source file:MainClass.java
public void actionPerformed(ActionEvent e) { if (e.getSource() == button1) { clickCount++;/*from w ww .ja v a2s. co m*/ if (clickCount == 1) button1.setText("I've been clicked!"); else button1.setText("I've been clicked" + clickCount + " times!"); } }
From source file:Main.java
public void actionPerformed(ActionEvent evt) { ((Component) evt.getSource()).transferFocus(); }
From source file:Main.java
public void actionPerformed(ActionEvent evt) { ((Component) evt.getSource()).transferFocusBackward(); }
From source file:MyActionListener.java
public void actionPerformed(ActionEvent e) { JButton source = (JButton) e.getSource(); String buttonText = source.getText(); JOptionPane.showMessageDialog(null, "You clicked" + buttonText); }
From source file:ButtonListener.java
public void actionPerformed(ActionEvent e) { JButton o = (JButton) e.getSource(); String label = o.getText();/* w w w . j av a 2 s . c om*/ System.out.println(label + " button clicked"); }
From source file:Main.java
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == yes) { } else {/* w w w. ja v a 2 s . c o m*/ dialog.dispose(); } }