當前位置: 首頁>>代碼示例>>Java>>正文


Java JCheckBoxMenuItem.addActionListener方法代碼示例

本文整理匯總了Java中javax.swing.JCheckBoxMenuItem.addActionListener方法的典型用法代碼示例。如果您正苦於以下問題:Java JCheckBoxMenuItem.addActionListener方法的具體用法?Java JCheckBoxMenuItem.addActionListener怎麽用?Java JCheckBoxMenuItem.addActionListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JCheckBoxMenuItem的用法示例。


在下文中一共展示了JCheckBoxMenuItem.addActionListener方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getJCheckBoxMenuItem

import javax.swing.JCheckBoxMenuItem; //導入方法依賴的package包/類
/**
 * Return the jcheckboxmenuitem to get added for a menubar
 * @param c Component Location
 * @return JCheckBoxMenuItem
 */
public JCheckBoxMenuItem getJCheckBoxMenuItem(Component c) {
    JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem("Show Console");
    cbmi.addActionListener(new ActionListener() {
        
        @Override
        public void actionPerformed(ActionEvent e) {
            if(cbmi.isSelected()) {
                reShowConsole(c);
            } else {
                hideConsole();
            }
        }
        
    });
    menucheckboxitems.add(cbmi);
    return cbmi;
}
 
開發者ID:Panzer1119,項目名稱:JAddOn,代碼行數:23,代碼來源:JLogger.java

示例2: initMenu

import javax.swing.JCheckBoxMenuItem; //導入方法依賴的package包/類
void initMenu() {
	addLoc = new JMenuItem("Add Place");
	menu.add( addLoc );
	addLoc.addActionListener( this );
	loadLoc = new JMenuItem("Load Places");
	menu.add( loadLoc );
	loadLoc.addActionListener( this );
	editLoc = new JMenuItem("Edit Places");
	menu.add( editLoc );
	editLoc.addActionListener( this );
	editLoc.setEnabled(false);
	showLoc = new JCheckBoxMenuItem("Show Places", false);
	menu.add( showLoc );
	showLoc.addActionListener( this );
//	showLoc.setEnabled(false);
	menu.addSeparator();
	list = new JCheckBox("add to list", true);
	save = new JCheckBox("save to file", false);
	newSave = new JCheckBox("save to new file", false);
	addPresetLocations();
//	addMyLocations();
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:23,代碼來源:MapLocations.java

示例3: addMenuItemListener

import javax.swing.JCheckBoxMenuItem; //導入方法依賴的package包/類
private void addMenuItemListener(final JCheckBoxMenuItem menuItem) {
    final boolean[] internalChange = new boolean[1];
    menuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {
            if (internalChange[0]) return;
            final int column = Integer.parseInt(e.getActionCommand());
            if (column == 5 && !fieldsListTableModel.isRealColumnVisible(column)) {
                BrowserUtils.performTask(new Runnable() {
                    public void run() {
                        final int retainedSizesState = fieldsBrowserController.getInstancesControllerHandler().
                                getHeapFragmentWalker().computeRetainedSizes(false, true);
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                if (retainedSizesState != HeapFragmentWalker.RETAINED_SIZES_COMPUTED) {
                                    internalChange[0] = true;
                                    menuItem.setSelected(!menuItem.isSelected());
                                    internalChange[0] = false;
                                } else {
                                    fieldsListTableModel.setRealColumnVisibility(column,
                                            !fieldsListTableModel.isRealColumnVisible(column));
                                    fieldsListTable.createDefaultColumnsFromModel();
                                    fieldsListTable.updateTreeTableHeader();
                                    setColumnsData();
                                }
                            }
                        });
                    }
                });
            } else {
                fieldsListTableModel.setRealColumnVisibility(column,
                        !fieldsListTableModel.isRealColumnVisible(column));
                fieldsListTable.createDefaultColumnsFromModel();
                fieldsListTable.updateTreeTableHeader();
                setColumnsData();
            }
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:39,代碼來源:FieldsBrowserControllerUI.java

示例4: addMenuItemListener

import javax.swing.JCheckBoxMenuItem; //導入方法依賴的package包/類
private void addMenuItemListener(final JCheckBoxMenuItem menuItem) {
    final boolean[] internalChange = new boolean[1];
    menuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {
            if (internalChange[0]) return;
            final int column = Integer.parseInt(e.getActionCommand());
            if (column == 5 && !fieldsListTableModel.isRealColumnVisible(column)) {
                BrowserUtils.performTask(new Runnable() {
                    public void run() {
                        final int retainedSizesState = referencesBrowserController.getReferencesControllerHandler().
                                getHeapFragmentWalker().computeRetainedSizes(false, true);
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                if (retainedSizesState != HeapFragmentWalker.RETAINED_SIZES_COMPUTED) {
                                    internalChange[0] = true;
                                    menuItem.setSelected(!menuItem.isSelected());
                                    internalChange[0] = false;
                                } else {
                                    fieldsListTableModel.setRealColumnVisibility(column,
                                            !fieldsListTableModel.isRealColumnVisible(column));
                                    fieldsListTable.createDefaultColumnsFromModel();
                                    fieldsListTable.updateTreeTableHeader();
                                    setColumnsData();
                                }
                            }
                        });
                    }
                });
            } else {
                fieldsListTableModel.setRealColumnVisibility(column,
                        !fieldsListTableModel.isRealColumnVisible(column));
                fieldsListTable.createDefaultColumnsFromModel();
                fieldsListTable.updateTreeTableHeader();
                setColumnsData();
            }
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:39,代碼來源:ReferencesBrowserControllerUI.java

示例5: addMenuItemListener

import javax.swing.JCheckBoxMenuItem; //導入方法依賴的package包/類
private void addMenuItemListener(final JCheckBoxMenuItem menuItem) {
    final boolean[] internalChange = new boolean[1];
    menuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                if (e.getActionCommand().equals("Filter")) { // NOI18N
                    filterComponent.getComponent().setVisible(!filterComponent.getComponent().isVisible());

                    return;
                }
                if (internalChange[0]) return;
                final int column = Integer.parseInt(e.getActionCommand());
                if (column == 4 && !classesListTableModel.isRealColumnVisible(column)) {
                    BrowserUtils.performTask(new Runnable() {
                        public void run() {
                            final int retainedSizesState = classesListController.getClassesController().
                                    getHeapFragmentWalker().computeRetainedSizes(true, true);
                            SwingUtilities.invokeLater(new Runnable() {
                                public void run() {
                                    if (retainedSizesState != HeapFragmentWalker.RETAINED_SIZES_COMPUTED) {
                                        internalChange[0] = true;
                                        menuItem.setSelected(!menuItem.isSelected());
                                        internalChange[0] = false;
                                    } else {
                                        initData();
                                        setColumnVisibility(4,true);
                                    }
                                }
                            });
                        }
                    });
                } else {
                    setColumnVisibility(column, !classesListTableModel.isRealColumnVisible(column));
                }
            }
        });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:37,代碼來源:ClassesListControllerUI.java

示例6: addMenuItemListener

import javax.swing.JCheckBoxMenuItem; //導入方法依賴的package包/類
private void addMenuItemListener(final JCheckBoxMenuItem menuItem) {
    final boolean[] internalChange = new boolean[1];
    menuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {
            if (internalChange[0]) return;
            final int column = Integer.parseInt(e.getActionCommand());
            if (column == 3 && !instancesListTableModel.isRealColumnVisible(column)) {
                BrowserUtils.performTask(new Runnable() {
                    public void run() {
                        final int retainedSizesState = instancesListController.getInstancesController().
                                getHeapFragmentWalker().computeRetainedSizes(false, true);
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                if (retainedSizesState != HeapFragmentWalker.RETAINED_SIZES_COMPUTED) {
                                    internalChange[0] = true;
                                    menuItem.setSelected(!menuItem.isSelected());
                                    internalChange[0] = false;
                                } else {
                                    toggleColumnVisibility(column, true);
                                }
                            }
                        });
                    }
                });
            } else {
                toggleColumnVisibility(column, true);
            }

        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:InstancesListControllerUI.java

示例7: createCheckItem

import javax.swing.JCheckBoxMenuItem; //導入方法依賴的package包/類
private JCheckBoxMenuItem createCheckItem(Container c,String txt, 
		boolean selected) {
	JCheckBoxMenuItem i = new JCheckBoxMenuItem(txt);
	i.setSelected(selected);
	i.addActionListener(this);
	c.add(i);
	return i;
}
 
開發者ID:mdonnyk,項目名稱:the-one-mdonnyk,代碼行數:9,代碼來源:SimMenuBar.java

示例8: fill

import javax.swing.JCheckBoxMenuItem; //導入方法依賴的package包/類
private void fill() {
	removeAll();
	DockableState[] dockables = dockingContext.getDesktopList().get(0).getDockables();
	List<DockableState> sorted = new LinkedList<>();
	sorted.addAll(Arrays.asList(dockables));
	Collections.sort(sorted, new Comparator<DockableState>() {

		@Override
		public int compare(DockableState o1, DockableState o2) {
			return o1.getDockable().getDockKey().getName().compareTo(o2.getDockable().getDockKey().getName());
		}
	});
	for (final DockableState state : sorted) {
		if (state.getDockable() instanceof DummyDockable) {
			continue;
		}
		DockKey dockKey = state.getDockable().getDockKey();
		boolean cont = false;
		for (String prefix : HIDE_IN_DOCKABLE_MENU_PREFIX_REGISTRY) {
			if (dockKey.getKey().startsWith(prefix)) {
				cont = true;
				break;
			}
		}
		if (cont) {
			continue;
		}
		String description = null;
		if (dockKey instanceof ResourceDockKey) {
			description = ((ResourceDockKey) dockKey).getShortDescription();
		}
		description = description != null ? description : "";
		String text = dockKey.getName();
		if (SystemInfoUtilities.getOperatingSystem() != OperatingSystem.OSX) {
			// OS X cannot use html in menus so only do it for other OS
			text = "<html><p style='margin-left:5'><b>" + dockKey.getName() + "</b><br/>" + description + "</p></html>";
		}
		JCheckBoxMenuItem item = new JCheckBoxMenuItem(text, dockKey.getIcon());

		item.setSelected(!state.isClosed());
		item.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				if (state.isClosed()) {
					dockingContext.getDesktopList().get(0).addDockable(state.getDockable());
				} else {
					dockingContext.getDesktopList().get(0).close(state.getDockable());
				}
			}

		});

		// special handling for results overview dockable in Results perspective
		// this dockable is not allowed to be closed so we disable this item while in said
		// perspective
		if (RapidMinerGUI.getMainFrame().getPerspectiveController().getModel().getSelectedPerspective().getName()
				.equals(PerspectiveModel.RESULT)
				&& ResultDisplay.RESULT_DOCK_KEY.equals(state.getDockable().getDockKey().getKey())) {
			item.setEnabled(false);
		}

		add(item);
	}

}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:67,代碼來源:DockableMenu.java

示例9: Menus

import javax.swing.JCheckBoxMenuItem; //導入方法依賴的package包/類
public Menus()
{
	items = new HashMap <String,JMenuItem>();
    Messenger.register(MT.SERIES_CHANGED, this);
	Messenger.register(MT.EVENT_CHANGED, this);

	/* File Menu */
	JMenu file = new JMenu("File");
	add(file);

	file.add(new OpenSeriesAction());
	file.add(new QuitAction());

	/* Edit Menu */
	edit = new JMenu("Edit");
	add(edit);
	edit.add(new EventSendAction("Quick Entry", MT.QUICKID_SEARCH, KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK)));
    edit.add(new EventSendAction("Filter Table", MT.OPEN_FILTER, KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK)));
	edit.add(new EventSendAction("Manual Barcode Entry", MT.OPEN_BARCODE_ENTRY, KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK)));

	/* Event Menu */
	event = new JMenu("Event Options");
	add(event);	

	/* Runs Submenu */
	runGrouping = new ButtonGroup();
	JMenu runs = new JMenu("Set Runs");
	event.add(runs);
	for (int ii = 2; ii <= 20; ii++)
	{
		JRadioButtonMenuItem m = new JRadioButtonMenuItem(ii + " Runs");
		m.addActionListener(this);
		runGrouping.add(m);
		runs.add(m);
	}

	paidInfoMode = new JCheckBoxMenuItem("Highlight Unpaid Entries", Prefs.usePaidFlag());
	paidInfoMode.addActionListener(this);
	event.add(paidInfoMode);

	reorderMode = new JCheckBoxMenuItem("Constant Staging Mode", Prefs.useReorderingTable());
	reorderMode.addActionListener(this);
	event.add(reorderMode);
	
	event.add(new BarcodeScannerOptionsAction());


	/* Results Menu */
	results = new JMenu("Reports");
	add(results);

	JMenu audit = new JMenu("Current Group Audit");
	audit.add(createItem("In Run Order", null));
	audit.add(createItem("Order By First Name", null));
	audit.add(createItem("Order By Last Name", null));
	
	results.add(createItem("Multiple Group Results", null));
	results.add(audit);
	results.add(createItem("Results Page", null));
	results.add(createItem("Admin Page", null));
}
 
開發者ID:drytoastman,項目名稱:scorekeeperfrontend,代碼行數:62,代碼來源:Menus.java


注:本文中的javax.swing.JCheckBoxMenuItem.addActionListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。