java.awt.MenuItem.addActionListener()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(347)

本文整理了Java中java.awt.MenuItem.addActionListener()方法的一些代码示例,展示了MenuItem.addActionListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.addActionListener()方法的具体详情如下:
包路径:java.awt.MenuItem
类名称:MenuItem
方法名:addActionListener

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

private MenuBar createMenuBar() {
  MenuBar ret=new MenuBar();
  Menu file=new Menu("File");
  MenuItem quitm=new MenuItem("Quit");
  ret.setFont(def_font2);
  ret.add(file);
  file.addSeparator();
  file.add(quitm);
  quitm.addActionListener(e -> System.exit(1));
  return ret;
}

代码示例来源:origin: igniterealtime/Openfire

quitMenuItem.addActionListener(actionListener);
browserMenuItem.addActionListener(actionListener);
stopMenuItem.addActionListener(actionListener);
startMenuItem.addActionListener(actionListener);
showMenuItem.addActionListener(actionListener);

代码示例来源:origin: RipMeApp/ripme

PopupMenu trayMenu = new PopupMenu();
trayMenuMain = new MenuItem("Hide");
trayMenuMain.addActionListener(arg0 -> toggleTrayClick());
MenuItem trayMenuAbout = new MenuItem("About " + mainFrame.getTitle());
trayMenuAbout.addActionListener(arg0 -> {
  StringBuilder about = new StringBuilder();
  about.append("<html><h1>")
trayMenuExit.addActionListener(arg0 -> System.exit(0));
trayMenuAutorip = new CheckboxMenuItem("Clipboard Autorip");
trayMenuAutorip.addItemListener(arg0 -> {

代码示例来源:origin: stackoverflow.com

defaultItem.addActionListener(listener);
popup.add(defaultItem);

代码示例来源:origin: stackoverflow.com

PopupMenu popup=new PopupMenu();
MenuItem defaultItem=new MenuItem("Exit");
defaultItem.addActionListener(exitListener);
popup.add(defaultItem);
defaultItem=new MenuItem("Open");
defaultItem.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
    setVisible(true);

代码示例来源:origin: com.h2database/h2

MenuItem itemConsole = new MenuItem("H2 Console");
itemConsole.setActionCommand("console");
itemConsole.addActionListener(this);
itemConsole.setFont(font);
menuConsole.add(itemConsole);
MenuItem itemStatus = new MenuItem("Status");
itemStatus.setActionCommand("status");
itemStatus.addActionListener(this);
itemStatus.setFont(font);
menuConsole.add(itemStatus);
itemExit.setFont(font);
itemExit.setActionCommand("exit");
itemExit.addActionListener(this);
menuConsole.add(itemExit);

代码示例来源:origin: stackoverflow.com

showItem.addActionListener(showListener);
popup.add(showItem);
closeItem.addActionListener(closeListener);
popup.add(closeItem);

代码示例来源:origin: Nilhcem/FakeSMTP

/**
 * The popup menu used by the icon in the system tray.
 *
 * @param mainFrame MainFrame class.
 */
public TrayPopup(final MainFrame mainFrame) {
  // Create a popup menu components
  MenuItem aboutItem = new MenuItem(i18n.get("menubar.about"));
  aboutItem.addActionListener(new AboutActionListener(null));
  MenuItem exitItem = new MenuItem(i18n.get("menubar.exit"));
  exitItem.addActionListener(new ExitActionListener(mainFrame));
  popup.add(aboutItem);
  popup.addSeparator();
  popup.add(exitItem);
}

代码示例来源:origin: i2p/i2p.i2p

public PopupMenu getMainMenu() {
  PopupMenu popup = new PopupMenu();
  MenuItem startItem = new MenuItem(_t("Start I2P"));
  startItem.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent arg0) {
      new SwingWorker<Object, Object>() {
        @Override
        protected Object doInBackground() throws Exception {
          RouterManager.start();
          return null;
        }
        
        @Override
        protected void done() {
          trayIcon.displayMessage(_t("Starting"), _t("I2P is starting!"), TrayIcon.MessageType.INFO);
          //Hide the tray icon.
          //We cannot stop the desktopgui program entirely,
          //since that risks killing the I2P process as well.
          tray.remove(trayIcon);
        }
      }.execute();
    }
  });
  popup.add(startItem);
  return popup;
}

代码示例来源:origin: stackoverflow.com

action.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent e) {
close.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent e) {

代码示例来源:origin: stackoverflow.com

item.addActionListener(menuActionListener);
popup.add(item);
ActionListener actionListener = new ActionListener() {

代码示例来源:origin: stackoverflow.com

final TrayIcon trayIcon = new TrayIcon(image, "The Tip Text", popup);
MenuItem item = new MenuItem("Error");
item.addActionListener(new ShowMessageListener(trayIcon, "Error Title", "Error", TrayIcon.MessageType.ERROR));
popup.add(item);
item = new MenuItem("Warning");
item.addActionListener(new ShowMessageListener(trayIcon, "Warning Title", "Warning", TrayIcon.MessageType.WARNING));
popup.add(item);
item = new MenuItem("Info");
item.addActionListener(new ShowMessageListener(trayIcon, "Info Title", "Info", TrayIcon.MessageType.INFO));
popup.add(item);
item = new MenuItem("None");
item.addActionListener(new ShowMessageListener(trayIcon, "None Title", "None", TrayIcon.MessageType.NONE));
popup.add(item);
item = new MenuItem("Close");
item.addActionListener(new ActionListener() {

代码示例来源:origin: magefree/mage

MenuItem exitItem = new MenuItem("Exit");
imagesItem.addActionListener(e -> MageFrame.getInstance().downloadImages());
iconsItem.addActionListener(e -> MageFrame.getInstance().downloadAdditionalResources());
stopBlinkItem.addActionListener(e -> stopBlink());
preferencesItem.addActionListener(e -> MageFrame.getInstance().btnPreferencesActionPerformed(null));
aboutItem.addActionListener(e -> MageFrame.getInstance().btnAboutActionPerformed(null));
exitItem.addActionListener(e -> MageFrame.getInstance().exitApp());

代码示例来源:origin: org.scijava/scijava-ui-awt

private void linkAction(final ShadowMenu shadow, final MenuItem menuItem) {
  menuItem.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(final ActionEvent e) {
      shadow.run();
    }
  });
}

代码示例来源:origin: i2p/i2p.i2p

if (CONSOLE_ENABLED) {
  browserLauncher = new MenuItem(_t("Launch I2P Browser"));
  browserLauncher.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent arg0) {
configSubmenu.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent arg0) {
if (_context.hasWrapper()) {
  restartItem = new MenuItem(_t("Restart I2P"));
  restartItem.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent arg0) {
stopItem.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent arg0) {
if (_context.hasWrapper()) {
  restartItem2 = new MenuItem(_t("Restart I2P Immediately"));
  restartItem2.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent arg0) {
stopItem2.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent arg0) {

代码示例来源:origin: stackoverflow.com

MenuItem help = new MenuItem("Help");
help.addActionListener(selectedListener);//HERE
//
MenuItem exit = new MenuItem("Exit");
//
takeSS.addActionListener(selectedListener);
hotKey.addActionListener(selectedListener);
version.addActionListener(selectedListener);
changeLog.addActionListener(selectedListener);
help.addActionListener(selectedListener);// AND HERE
exit.addActionListener(selectedListener);

代码示例来源:origin: net.imagej/ij

void addPopupItem(String s) {
  MenuItem mi=new MenuItem(s);
  mi.addActionListener(this);
  pm.add(mi);
}

代码示例来源:origin: net.imagej/ij

void addPopupItem(String s) {
  MenuItem mi=new MenuItem(s);
  mi.addActionListener(this);
  pm.add(mi);
}

代码示例来源:origin: net.imagej/ij

MenuItem addPopupItem(PopupMenu popupMenu, String s, boolean isCheckboxItem) {
  MenuItem mi = null;
  if (isCheckboxItem) {
    mi = new CheckboxMenuItem(s);
    ((CheckboxMenuItem)mi).addItemListener(this);
  } else {
    mi = new MenuItem(s);
    mi.addActionListener(this);
  }
  popupMenu.add(mi);
  return mi;
}

代码示例来源:origin: mucommander/mucommander

/**
 * Creates and adds a menu item that triggers the MuAction denoted by the given Class. The menu item's label
 * is set to the value returned by {@link MuAction#getLabel()}.
 */
private void addMenuItem(Menu menu, String muActionId) {
  MuAction action = ActionManager.getActionInstance(muActionId, WindowManager.getCurrentMainFrame());
  MenuItem menuItem = new MenuItem(action.getLabel());
  menuItem.addActionListener(new AWTActionProxy(action));
  menu.add(menuItem);
}

相关文章