类java.awt.PopupMenu源码实例Demo

下面列出了怎么用java.awt.PopupMenu的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: dragonwell8_jdk   文件: WTrayIconPeer.java
@Override
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
            @Override
            public void run() {
                PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
                if (popup != newPopup) {
                    if (popup != null) {
                        popupParent.remove(popup);
                    }
                    if (newPopup != null) {
                        popupParent.add(newPopup);
                    }
                    popup = newPopup;
                }
                if (popup != null) {
                    ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y));
                }
            }
        });
}
 
源代码2 项目: TencentKona-8   文件: WTrayIconPeer.java
@Override
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
            @Override
            public void run() {
                PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
                if (popup != newPopup) {
                    if (popup != null) {
                        popupParent.remove(popup);
                    }
                    if (newPopup != null) {
                        popupParent.add(newPopup);
                    }
                    popup = newPopup;
                }
                if (popup != null) {
                    ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y));
                }
            }
        });
}
 
源代码3 项目: jdk8u60   文件: WTrayIconPeer.java
@Override
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
            @Override
            public void run() {
                PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
                if (popup != newPopup) {
                    if (popup != null) {
                        popupParent.remove(popup);
                    }
                    if (newPopup != null) {
                        popupParent.add(newPopup);
                    }
                    popup = newPopup;
                }
                if (popup != null) {
                    ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y));
                }
            }
        });
}
 
源代码4 项目: openjdk-jdk8u   文件: WTrayIconPeer.java
@Override
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
            @Override
            public void run() {
                PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
                if (popup != newPopup) {
                    if (popup != null) {
                        popupParent.remove(popup);
                    }
                    if (newPopup != null) {
                        popupParent.add(newPopup);
                    }
                    popup = newPopup;
                }
                if (popup != null) {
                    ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y));
                }
            }
        });
}
 
源代码5 项目: proxyee-down   文件: DownApplication.java
public void loadPopupMenu() {
  //添加右键菜单
  PopupMenu popupMenu = new PopupMenu();
  MenuItem showItem = new MenuItem(I18nUtil.getMessage("gui.tray.show"));
  showItem.addActionListener(event -> Platform.runLater(() -> loadUri("", true)));
  MenuItem setItem = new MenuItem(I18nUtil.getMessage("gui.tray.set"));
  setItem.addActionListener(event -> loadUri("/#/setting", true));
  MenuItem aboutItem = new MenuItem(I18nUtil.getMessage("gui.tray.about"));
  aboutItem.addActionListener(event -> loadUri("/#/about", true));
  MenuItem supportItem = new MenuItem(I18nUtil.getMessage("gui.tray.support"));
  supportItem.addActionListener(event -> loadUri("/#/support", true));
  MenuItem closeItem = new MenuItem(I18nUtil.getMessage("gui.tray.exit"));
  closeItem.addActionListener(event -> {
    Platform.exit();
    System.exit(0);
  });
  popupMenu.add(showItem);
  popupMenu.addSeparator();
  popupMenu.add(setItem);
  popupMenu.add(aboutItem);
  popupMenu.add(supportItem);
  popupMenu.addSeparator();
  popupMenu.add(closeItem);
  trayIcon.setPopupMenu(popupMenu);
}
 
源代码6 项目: ETL_Unicorn   文件: ThisCanvas.java
public ThisCanvas(Thread threadApplet, LinkList first, NodeShow nodeView
		, PopupMenu nodeMenu, JTextPane rightBotJTextPane){
	this.setLayout(null);
	this.addMouseListener(this);
	this.addMouseMotionListener(this);
	this.start();
	this.setOpaque(false);
	this.threadApplet= threadApplet;
	this.first= first;
	this.nodeView= nodeView;
	this.nodeMenu= nodeMenu;
	this.rightBotJTextPane= rightBotJTextPane;
	chooseCheck= new ChooseCheckVPS();
	dynamicLineUpdater= new DynamicLineUpdaterVPS();
	drawArrow= new DrawArrowVPS();
	checkRange= new CheckRangeVPS();
}
 
源代码7 项目: openjdk-jdk8u-backup   文件: WTrayIconPeer.java
@Override
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
            @Override
            public void run() {
                PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
                if (popup != newPopup) {
                    if (popup != null) {
                        popupParent.remove(popup);
                    }
                    if (newPopup != null) {
                        popupParent.add(newPopup);
                    }
                    popup = newPopup;
                }
                if (popup != null) {
                    ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y));
                }
            }
        });
}
 
源代码8 项目: openjdk-jdk9   文件: WTrayIconPeer.java
@Override
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, () -> {
        PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
        if (popup != newPopup) {
            if (popup != null) {
                popupParent.remove(popup);
            }
            if (newPopup != null) {
                popupParent.add(newPopup);
            }
            popup = newPopup;
        }
        if (popup != null) {
            WPopupMenuPeer peer = AWTAccessor.getMenuComponentAccessor()
                                             .getPeer(popup);
            peer.show(popupParent, new Point(x, y));
        }
    });
}
 
源代码9 项目: openjdk-jdk9   文件: UpdatePopupMenu.java
private PopupMenu createPopupMenu(final TrayIcon trayIcon,
        final int menuCount) {

    final PopupMenu trayIconPopupMenu = new PopupMenu();

    for (int i = 1; i <= menuCount; ++i) {
        final MenuItem popupMenuItem = new MenuItem("MenuItem_" + i);

        popupMenuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent ae) {
                trayIcon.setPopupMenu(createPopupMenu(trayIcon,
                        menuCount + 1));
            }
        });

        trayIconPopupMenu.add(popupMenuItem);
    }

    return trayIconPopupMenu;
}
 
源代码10 项目: jdk8u-jdk   文件: WTrayIconPeer.java
@Override
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
            @Override
            public void run() {
                PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
                if (popup != newPopup) {
                    if (popup != null) {
                        popupParent.remove(popup);
                    }
                    if (newPopup != null) {
                        popupParent.add(newPopup);
                    }
                    popup = newPopup;
                }
                if (popup != null) {
                    ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y));
                }
            }
        });
}
 
源代码11 项目: hottub   文件: WTrayIconPeer.java
@Override
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
            @Override
            public void run() {
                PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
                if (popup != newPopup) {
                    if (popup != null) {
                        popupParent.remove(popup);
                    }
                    if (newPopup != null) {
                        popupParent.add(newPopup);
                    }
                    popup = newPopup;
                }
                if (popup != null) {
                    ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y));
                }
            }
        });
}
 
源代码12 项目: openjdk-8-source   文件: WTrayIconPeer.java
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
            public void run() {
                PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
                if (popup != newPopup) {
                    if (popup != null) {
                        popupParent.remove(popup);
                    }
                    if (newPopup != null) {
                        popupParent.add(newPopup);
                    }
                    popup = newPopup;
                }
                if (popup != null) {
                    ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y));
                }
            }
        });
}
 
源代码13 项目: openjdk-8   文件: WTrayIconPeer.java
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
            public void run() {
                PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
                if (popup != newPopup) {
                    if (popup != null) {
                        popupParent.remove(popup);
                    }
                    if (newPopup != null) {
                        popupParent.add(newPopup);
                    }
                    popup = newPopup;
                }
                if (popup != null) {
                    ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y));
                }
            }
        });
}
 
源代码14 项目: jdk8u_jdk   文件: WTrayIconPeer.java
@Override
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
            @Override
            public void run() {
                PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
                if (popup != newPopup) {
                    if (popup != null) {
                        popupParent.remove(popup);
                    }
                    if (newPopup != null) {
                        popupParent.add(newPopup);
                    }
                    popup = newPopup;
                }
                if (popup != null) {
                    ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y));
                }
            }
        });
}
 
源代码15 项目: jdk8u-jdk   文件: WTrayIconPeer.java
@Override
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
            @Override
            public void run() {
                PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
                if (popup != newPopup) {
                    if (popup != null) {
                        popupParent.remove(popup);
                    }
                    if (newPopup != null) {
                        popupParent.add(newPopup);
                    }
                    popup = newPopup;
                }
                if (popup != null) {
                    ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y));
                }
            }
        });
}
 
源代码16 项目: jdk8u-dev-jdk   文件: WTrayIconPeer.java
@Override
public synchronized void showPopupMenu(final int x, final int y) {
    if (isDisposed())
        return;

    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
            @Override
            public void run() {
                PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
                if (popup != newPopup) {
                    if (popup != null) {
                        popupParent.remove(popup);
                    }
                    if (newPopup != null) {
                        popupParent.add(newPopup);
                    }
                    popup = newPopup;
                }
                if (popup != null) {
                    ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y));
                }
            }
        });
}
 
源代码17 项目: jmg   文件: StaveActionHandler.java
StaveActionHandler(Stave stave) {
theApp = stave;

      noteContextMenu = new PopupMenu();
      
      editNote = new MenuItem("Edit Note");
      editNote.addActionListener(this);
      noteContextMenu.add(editNote );       
      
      repeatNote = new MenuItem("Repeat Note");
      repeatNote.addActionListener(this);
      noteContextMenu.add(repeatNote ); 		
      
      makeRest = new MenuItem("Change to Rest");
      makeRest.addActionListener(this);
      noteContextMenu.add(makeRest);       
      
      deleteNote = new MenuItem("Delete Note");
      deleteNote.addActionListener(this);
      noteContextMenu.add(deleteNote );       
      
      theApp.add(noteContextMenu);
  }
 
源代码18 项目: ramus   文件: Manager.java
private PopupMenu createPopupMenu() {
    PopupMenu menu = new PopupMenu(getString("Server") + " "
            + Metadata.getApplicationName());
    menu.add(createStart());
    menu.add(createStop());
    menu.addSeparator();
    menu.add(createRestart());
    menu.addSeparator();
    menu.add(createPreferences());
    menu.addSeparator();
    menu.add(createExit());
    return menu;
}
 
源代码19 项目: openjdk-jdk9   文件: XTaskbarPeer.java
@Override
public synchronized void setMenu(PopupMenu m) {
    this.menu = m;

    if (menu != null && menu.getItemCount() > 0) {
        int msize = menu.getItemCount();
        MenuItem[] items = new MenuItem[msize];
        for (int i = 0; i < msize; i++) {
            items[i] = menu.getItem(i);
        }
        setNativeMenu(items);
    } else {
        setNativeMenu(null);
    }
}
 
源代码20 项目: openjdk-jdk9   文件: PopupMenuLeakTest.java
private static void addNotifyPopup() {
    PopupMenu menu = popupWeakReference.get().get();
    if (menu == null) {
        throw new RuntimeException("Failed: popup collected too early");
    }
    menu.addNotify();
}
 
源代码21 项目: openjdk-jdk9   文件: ComponentOperator.java
/**
 * Maps {@code Component.add(PopupMenu)} through queue
 */
public void add(final PopupMenu popupMenu) {
    runMapping(new MapVoidAction("add") {
        @Override
        public void map() {
            getSource().add(popupMenu);
        }
    });
}
 
源代码22 项目: MakeLobbiesGreatAgain   文件: Boot.java
public static void setupTray() throws AWTException {
	final SystemTray tray = SystemTray.getSystemTray();
	final PopupMenu popup = new PopupMenu();
	final MenuItem info = new MenuItem();
	final MenuItem exit = new MenuItem();
	final TrayIcon trayIcon = new TrayIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB), "MLGA", popup);
	try {
		InputStream is = FileUtil.localResource("icon.png");
		trayIcon.setImage(ImageIO.read(is));
		is.close();
	} catch (IOException e1) {
		e1.printStackTrace();
	}

	info.addActionListener(e -> {
		String message = "Double-Click to lock/unlock the overlay for dragging";
		JOptionPane.showMessageDialog(null, message, "Information", JOptionPane.INFORMATION_MESSAGE);
	});

	exit.addActionListener(e -> {
		running = false;
		tray.remove(trayIcon);
		ui.close();
		System.out.println("Terminated UI...");
		System.out.println("Cleaning up system resources. Could take a while...");
		handle.close();
		System.out.println("Killed handle.");
		System.exit(0);
	});
	info.setLabel("Help");
	exit.setLabel("Exit");
	popup.add(info);
	popup.add(exit);
	tray.add(trayIcon);
}
 
源代码23 项目: subsonic   文件: TrayController.java
private void createComponents() {
    startedImage = createImage("/images/subsonic-started-16.png");
    stoppedImage = createImage("/images/subsonic-stopped-16.png");

    PopupMenu menu = new PopupMenu();
    menu.add(createMenuItem(openAction));
    menu.add(createMenuItem(controlPanelAction));
    menu.addSeparator();
    menu.add(createMenuItem(hideAction));

    trayIcon = new TrayIcon(stoppedImage, "Subsonic Music Streamer", menu);
}
 
源代码24 项目: PeerWasp   文件: JTrayMenu.java
public PopupMenu create(boolean isUserLoggedIn) {
	root = new PopupMenu();

	if (isUserLoggedIn) {
		root.add(createRootFolderMenu());
		// root.add(createRecentFilesMenu()); // TODO: implement additional feature.
		root.addSeparator();
		root.add(createSettingsMenu());
		root.addSeparator();
	}
	root.add(createActivityMenu());
	root.add(createQuitMenu());

	return root;
}
 
源代码25 项目: img2latex-mathpix   文件: App.java
/**
 * Tray icon handler.
 */
private void trayIconHandler(InputStream iconInputStream) throws IOException, AWTException {

    // set up the system tray
    var tray = SystemTray.getSystemTray();
    var image = ImageIO.read(iconInputStream);
    // use the loaded icon as tray icon
    var trayIcon = new TrayIcon(image);

    // show the primary stage if the icon is right clicked
    trayIcon.addActionListener(event -> Platform.runLater(this::showStage));

    // add app name as a menu item
    var openItem = new MenuItem(APPLICATION_TITLE);
    // show the primary stage if the app name item is clicked
    openItem.addActionListener(event -> Platform.runLater(this::showStage));

    // add Preferences menu item
    var settingItem = new MenuItem("Preferences");
    settingItem.addActionListener(event -> Platform.runLater(() -> UIUtils.showPreferencesDialog(0)));

    // add check for updates menu item
    var updateCheckItem = new MenuItem("Check for Updates");

    // add current version info menu item
    var versionItem = new MenuItem("Version: " + PROPERTIES.getProperty("version"));

    // add click action listener
    updateCheckItem.addActionListener(event -> {
        try {
            Desktop.getDesktop().browse(new URI(IOUtils.GITHUB_RELEASES_URL));
        } catch (IOException | URISyntaxException ignored) {
        }
    });

    // add quit option as the app cannot be closed by clicking the window close button
    var exitItem = new MenuItem("Quit");

    // add action listener for cleanup
    exitItem.addActionListener(event -> {
        // remove the icon
        tray.remove(trayIcon);

        Platform.exit();
        System.exit(0);
    });

    // set up the popup menu
    final var popup = new PopupMenu();
    popup.add(openItem);
    popup.addSeparator();
    popup.add(settingItem);
    popup.addSeparator();
    popup.add(versionItem);
    popup.add(updateCheckItem);
    popup.addSeparator();
    popup.add(exitItem);
    trayIcon.setPopupMenu(popup);

    // add icon to the system
    tray.add(trayIcon);

}
 
源代码26 项目: dragonwell8_jdk   文件: CPopupMenu.java
CPopupMenu(PopupMenu target) {
    super(target);
}
 
源代码27 项目: TencentKona-8   文件: CPopupMenu.java
CPopupMenu(PopupMenu target) {
    super(target);
}
 
源代码28 项目: Path-of-Leveling   文件: POELevelFx.java
private void addTrayIcon() throws AWTException {
    final TrayIcon trayIcon = new TrayIcon(new ImageIcon(getClass().getResource("/icons/The_Explorer_card_art.png")).getImage(), "Path of Leveling");

    // Create a pop-up menu components
    final PopupMenu popup = new PopupMenu();
    final MenuItem shutdownItem = new MenuItem("Exit");
    final MenuItem settingsItem = new MenuItem("Settings");

    //Add components to pop-up menu
    popup.add(settingsItem);
    popup.add(shutdownItem);

    trayIcon.setPopupMenu(popup);
    trayIcon.setImageAutoSize(true); //So the icon auto-sizes

    SystemTray.getSystemTray().add(trayIcon);

    trayIcon.addMouseListener(new MouseAdapter() {
        @Override public void mouseClicked(java.awt.event.MouseEvent e) {
            if (e.getButton() == java.awt.event.MouseEvent.BUTTON1) { //Left click on tray icon (single click !)
                Platform.runLater(() -> {
                    //code to show things...
                });
            }
        }
    });

    shutdownItem.addActionListener(evnt -> {
        //code to exit the program
        //save stuff
        if(saveBuildsToMemory()){
            System.out.println("Successfully saved checkpoint");
        }else{
            System.out.println("Checkpoint save failed");
        }
        try {
                GlobalScreen.unregisterNativeHook();
        } catch (NativeHookException e1) {
                e1.printStackTrace();
        }
        System.exit(20);
    });

    settingsItem.addActionListener(evnt -> {
        //code to exit the program
        //save stuff
        if(controller!=null){
            controller.settings_event();
        }
    });
}
 
源代码29 项目: openjdk-jdk8u   文件: CPopupMenu.java
CPopupMenu(PopupMenu target) {
    super(target);
}
 
源代码30 项目: netbeans   文件: UtilitiesTest.java
protected PopupMenuPeer createPopupMenu(PopupMenu target) throws HeadlessException {
    throw new IllegalStateException("Method not implemented");
}
 
 类所在包
 同包方法