java.awt.TrayIcon.setPopupMenu()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(161)

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

TrayIcon.setPopupMenu介绍

暂无

代码示例

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

trayIcon.setToolTip(mainFrame.getTitle());
trayIcon.setImageAutoSize(true);
trayIcon.setPopupMenu(trayMenu);
SystemTray.getSystemTray().add(trayIcon);
trayIcon.addMouseListener(new MouseAdapter() {

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

public synchronized void languageChanged() {
  if (trayIcon != null) {
    if (!_useSwing)
      trayIcon.setPopupMenu(getMainMenu());
    // else TODO
  }
}

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

/**
 * @param mainFrame The MainFrame class used for closing actions from TrayPopup.
 */
public MainWindowListener(final MainFrame mainFrame) {
  useTray = (SystemTray.isSupported() && Boolean.parseBoolean(Configuration.INSTANCE.get("application.tray.use")));
  if (useTray) {
    final TrayPopup trayPopup = new TrayPopup(mainFrame);
    final Image iconImage = Toolkit.getDefaultToolkit().getImage(getClass().
      getResource(Configuration.INSTANCE.get("application.icon.path")));
    trayIcon = new TrayIcon(iconImage);
    trayIcon.setImageAutoSize(true);
    trayIcon.setPopupMenu(trayPopup.get());
  }
}

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

trayIcon.setPopupMenu(popup);
trayIcon.addMouseListener(new MouseAdapter() {
  @Override

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

final PopupMenu popup = new PopupMenu();
 final TrayIcon trayIcon =
     new TrayIcon(createImage("images/bulb.gif", "tray icon"));
 final SystemTray tray = SystemTray.getSystemTray();
 // Populate popup menu
 trayIcon.setPopupMenu(popup);
 try {
   tray.add(trayIcon);
 } catch (AWTException e) {
   System.out.println("TrayIcon could not be added.");
 }

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

popup.add(exitItem);
trayIcon.setPopupMenu(popup);

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

public static void main (String [] args) {
  if (!SystemTray.isSupported()) {
    System.out.println("SystemTray is not supported");
    return;
  }
  Image image = Toolkit.getDefaultToolkit().getImage("MY/PATH/TO_IMAGE");

  final PopupMenu popup = new PopupMenu();
  final TrayIcon trayIcon = new TrayIcon(image, "MY PROGRAM NAME", popup);
  final SystemTray tray = SystemTray.getSystemTray();

  MenuItem exitItem = new MenuItem("Exit");
  exitItem.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      System.exit(1);
    }
  });
  popup.add(exitItem);

  trayIcon.setPopupMenu(popup);

  try {
    tray.add(trayIcon);
  } catch (AWTException e) {
    System.out.println("TrayIcon could not be added.");
  }
}

代码示例来源:origin: scruel/ClipIt

private static void addTray(GlobalHotkeyListener hotkeyListener) throws AWTException {
  ImageIcon imageIcon = new ImageIcon(Objects.requireNonNull(TipsFrame.class.getClassLoader().getResource("ClipIt.png")));
  TrayIcon trayIcon = new TrayIcon(imageIcon.getImage());
  trayIcon.setToolTip("ClipIt");
  PopupMenu popupMenu = new PopupMenu();
  MenuItem exitMenuItem = new MenuItem("Exit");
  exitMenuItem.addActionListener(actionEvent -> hotkeyListener.destroy());
  popupMenu.add(exitMenuItem);
  trayIcon.setPopupMenu(popupMenu);
  SystemTray systemTray = SystemTray.getSystemTray();
  systemTray.add(trayIcon);
}

代码示例来源:origin: Slowpoke101/FTBLaunch

public static void setUpSystemTray () {
  trayMenu = new TrayMenu();
  SystemTray tray = SystemTray.getSystemTray();
  TrayIcon trayIcon = new TrayIcon(Toolkit.getDefaultToolkit().getImage(instance.getClass().getResource("/image/logo_ftb.png")));
  trayIcon.setPopupMenu(trayMenu);
  trayIcon.setToolTip(Constants.name);
  trayIcon.setImageAutoSize(true);
  try {
    tray.add(trayIcon);
  } catch (AWTException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: xXKeyleXx/MyPet

private static void createTraymenu(Image logoImage) {
  trayIcon = new TrayIcon(logoImage);
  MenuItem exitItem = new MenuItem("Exit");
  exitItem.addActionListener(e -> {
    close();
  });
  MenuItem reopenItem = new MenuItem("Reopen");
  reopenItem.addActionListener(e -> {
    try {
      Desktop.getDesktop().browse(new URI("http://localhost:64712"));
    } catch (URISyntaxException | IOException e2) {
      e2.printStackTrace();
    }
  });
  PopupMenu popup = new PopupMenu();
  popup.add(reopenItem);
  popup.add(exitItem);
  trayIcon.setPopupMenu(popup);
  trayIcon.setToolTip("MyPet - SkilltreeCreator");
  try {
    SystemTray.getSystemTray().add(trayIcon);
  } catch (AWTException e) {
    e.printStackTrace();
  }
  trayIcon.displayMessage("MyPet - SkilltreeCreator", "The SkilltreeCreator is running. You can exit it via the tray icon.", TrayIcon.MessageType.INFO);
}

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

addMenuItem(menu, QuitAction.Descriptor.ACTION_ID);
trayIcon.setPopupMenu(menu);

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

public TrayIconManager(Image image) {
  if (SystemTray.isSupported()) {
    tray = SystemTray.getSystemTray();
    
    popup = new PopupMenu();
    MenuItem showItem = new MenuItem("Show");
    showItem.setActionCommand("show");
    popup.add(showItem);
    MenuItem exitItem = new MenuItem("Exit");
    exitItem.setActionCommand("exit");
    popup.add(exitItem);
    trayIcon = new TrayIcon(image, "Chatty");
    trayIcon.setImageAutoSize(true);
    trayIcon.setPopupMenu(popup);
  } else {
    tray = null;
    trayIcon = null;
    popup = null;
  }
}

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

popup.add(exitItem);
trayIcon.setPopupMenu(popup);

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

popup.add(exitItem);
trayIcon.setPopupMenu(popup);

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

popup.add(exitItem);
trayIcon.setPopupMenu(popup);

代码示例来源:origin: mil.army.missioncommand/mil-sym-renderer

trayIcon.setPopupMenu(popup);
      trayIcon.displayMessage("caption", "text", TrayIcon.MessageType.ERROR);

代码示例来源:origin: trekawek/radioblock

public PlayerTrayIcon(boolean windowVisible) {
  icon = new TrayIcon(NORMAL_ICON, "Radioblock");
  startItem = new MenuItem("Start");
  startItem.setActionCommand("start");
  startItem.setEnabled(true);
  startItem.addActionListener(e -> listener.startPlayer());
  stopItem = new MenuItem("Stop");
  stopItem.setActionCommand("stop");
  stopItem.setEnabled(false);
  stopItem.addActionListener(e -> listener.stopPlayer());
  showWindowItem = new CheckboxMenuItem("Show window");
  showWindowItem.setState(windowVisible);
  showWindowItem.addItemListener(e -> listener.setWindowVisibility(showWindowItem.getState()));
  MenuItem quitItem = new MenuItem("Quit");
  quitItem.setActionCommand("quit");
  quitItem.addActionListener(e -> System.exit(0));
  final PopupMenu popup = new PopupMenu();
  popup.add(startItem);
  popup.add(stopItem);
  popup.add(showWindowItem);
  popup.add(quitItem);
  icon.setPopupMenu(popup);
  try {
    SystemTray.getSystemTray().add(icon);
  } catch (AWTException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: icza/scelight

exitMenuItem.addActionListener( Actions.EXIT );
popup.add( exitMenuItem );
trayIcon.setPopupMenu( popup );

代码示例来源:origin: SKCraft/SKMCLauncher

trayIcon.setPopupMenu(popup);

代码示例来源:origin: SKCraft/Launcher

trayIcon.setPopupMenu(popup);

相关文章