Java Code Examples for java.awt.MenuItem#setLabel()

The following examples show how to use java.awt.MenuItem#setLabel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Boot.java    From MakeLobbiesGreatAgain with MIT License 5 votes vote down vote up
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);
}
 
Example 2
Source File: Launcher.java    From Openfire with Apache License 2.0 5 votes vote down vote up
private void toggleVisibility(MenuItem showMenuItem) {
    // Hide/Unhide the window if the user clicked in the system tray icon or
    // selected the menu option
    if (frame.isVisible()) {
        frame.setVisible(false);
        showMenuItem.setLabel("Show");
    } else {
        frame.setVisible(true);
        frame.setState(Frame.NORMAL);
        showMenuItem.setLabel("Hide");
    }
}
 
Example 3
Source File: GUISample.java    From ETL_Unicorn with Apache License 2.0 4 votes vote down vote up
private void CreatMap() throws IOException {
	w= 1446- 130;
	h= 820- 110;
	updateRelatedLine= new UpdateRelatedLineVPS();
	getContentPane().setLayout(null);
	UIManager.put("SplitPaneUI", "org.LYG.GUI.platForm.UnicornSplitPaneUI");
	UIManager.put("ScrollBarUI", "org.LYG.GUI.platForm.UnicornScrollBarUI");
	UIManager.put("TreeUI", "org.LYG.GUI.platForm.UnicornTreeUI");
	currentNodeName= new String("");
	first= new LinkList();
	nodeInfo= new NodeInfo();
	nodeView= new NodeShow(this.tableData_old, this.text);
	nodeView.tree.setBackground(Color.white);
	nodeView.setBounds(10, 168, 137, 222);
	nodeProject= new NodeProject();
	nodeProject.setBounds(10, 38, 137, 124);	
	mainSplitPane = new UnicornJSplitPane();
	mainSplitPane.setAutoscrolls(true);
	//mainSplitPane.setEnabled(false);//
	mainSplitPane.setBounds(10, 50, w-20, h-80);
	mainSplitPane.setVisible(true);
	getContentPane().add(mainSplitPane);
	leftSplitPane= new UnicornJSplitPane();
	leftSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
	mainSplitPane.setLeftComponent(leftSplitPane);
	leftSplitPane.setLeftComponent(nodeProject);
	leftSplitPane.setRightComponent(nodeView);
	rightSplitPane= new UnicornJSplitPane();
	rightSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
	mainSplitPane.setRightComponent(rightSplitPane);
	righttopSplitPane= new UnicornJSplitPane();
	rightSplitPane.setLeftComponent(righttopSplitPane);
	rightBotJTextPane= new JTextPane();
	rightBotJTextPane.setText("����~");
	nodeMenu= new PopupMenu();
	canvas= new ThisCanvas(threadApplet, first, nodeView, nodeMenu, rightBotJTextPane);
	canvas.setPreferredSize(new Dimension(1500,1000));
	canvas.setEnabled(true);
	righttopScrollPane= new JScrollPane();
	righttopScrollPane.setViewportView(canvas);
	righttopSplitPane.setLeftComponent(righttopScrollPane);
	rightrightScrollPane= new JScrollPane();
	righttopSplitPane.setRightComponent(nodeInfo);
	rightdownScrollPane= new JScrollPane(rightBotJTextPane);
	rightSplitPane.setRightComponent(rightdownScrollPane);
	popupMenu= new PopupMenu();
	menuItem= new MenuItem();
	menuItem.setLabel("add");
	popupMenu.add(menuItem);
	configre= new MenuItem();
	configre.setLabel("����");
	run= new MenuItem();
	run.setLabel("����");
	show= new MenuItem();
	show.setLabel("��ʾ");
	dNode= new MenuItem();
	dNode.setLabel("ɾ���ý�");
	dLine= new MenuItem();
	dLine.setLabel("ɾ������");
	nodeMenu.add(configre);
	nodeMenu.add(run);
	nodeMenu.add(show);
	nodeMenu.add(dNode);
	nodeMenu.add(dLine);  
	getContentPane().add(popupMenu);
	getContentPane().add(nodeMenu);
	engineMenu= new PopupMenu();
	load= new MenuItem();
	load.setLabel(StableData.CONFIG_LOAD);
	save= new MenuItem();
	save.setLabel(StableData.CONFIG_UPDATE);
	saveAs= new MenuItem();
	saveAs.setLabel(StableData.CONFIG_SAVE);
	delete= new MenuItem();
	delete.setLabel(StableData.CONFIG_DELETE);
	boot= new MenuItem();
	boot.setLabel(StableData.CONFIG_BOOT);
	bootETL= new MenuItem();
	bootETL.setLabel(StableData.CONFIG_BOOT_ETL);
	engineMenu.add(load);
	engineMenu.add(save);
	engineMenu.add(saveAs);
	engineMenu.add(delete);
	engineMenu.add(boot);
	engineMenu.add(bootETL);
	getContentPane().add(engineMenu);
	getContentPane().setVisible(true);
}