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


Java JCheckBoxMenuItem類代碼示例

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


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

示例1: getPopupMenuItem

import javax.swing.JCheckBoxMenuItem; //導入依賴的package包/類
public JMenuItem getPopupMenuItem(JTextComponent target) {
    
    item = new JCheckBoxMenuItem(NbBundle.getBundle(BaseKit.class).
            getString("line-numbers-menuitem"), isLineNumbersVisible());
    item.addItemListener( new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            actionPerformed(null,null);
        }
    });
    return item;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:ActionFactory.java

示例2: init

import javax.swing.JCheckBoxMenuItem; //導入依賴的package包/類
@Override
public void init() {
    try {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                JMenuBar bar = new JMenuBar();
                JMenu menu = new JMenu("Menu");
                JCheckBoxMenuItem checkBoxMenuItem
                        = new JCheckBoxMenuItem("JCheckBoxMenuItem");
                checkBoxMenuItem.setSelected(true);
                menu.add(checkBoxMenuItem);
                bar.add(menu);
                setJMenuBar(bar);
            }
        });
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:bug8031573.java

示例3: setShowEditorToolbar

import javax.swing.JCheckBoxMenuItem; //導入依賴的package包/類
private static boolean setShowEditorToolbar( boolean show ) {
    boolean res = true;
    Action toggleEditorToolbar = FileUtil.getConfigObject( "Editors/Actions/toggle-toolbar.instance", Action.class ); //NOI18N
    if( null != toggleEditorToolbar ) {
        if( toggleEditorToolbar instanceof Presenter.Menu ) {
            JMenuItem menuItem = ((Presenter.Menu)toggleEditorToolbar).getMenuPresenter();
            if( menuItem instanceof JCheckBoxMenuItem ) {
                JCheckBoxMenuItem checkBoxMenu = ( JCheckBoxMenuItem ) menuItem;
                res = checkBoxMenu.isSelected();
                if( checkBoxMenu.isSelected() != show ) {
                    try {
                        toggleEditorToolbar.actionPerformed( new ActionEvent( menuItem, 0, "")); //NOII18N
                    } catch( Exception ex ) {
                        //don't worry too much if it isn't working, we're just trying to be helpful here
                        Logger.getLogger( EditorOnlyDisplayer.class.getName()).log( Level.FINE, null, ex );
                    }
                }
            }
        }
    }

    return res;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:EditorOnlyDisplayer.java

示例4: maybeShowPopup

import javax.swing.JCheckBoxMenuItem; //導入依賴的package包/類
protected void maybeShowPopup (MouseEvent evt) {
    if (evt != null && !SwingUtilities.isLeftMouseButton(evt)) {
        return;
    }

    JPopupMenu pm = new JPopupMenu();
    final Set<ProviderModel.Category> evalCats =
            new LinkedHashSet<ProviderModel.Category>();
    evalCats.addAll(CommandEvaluator.getEvalCats());
    JMenuItem allCats = new AllMenuItem(evalCats);
    pm.add(allCats);

    for (ProviderModel.Category cat : ProviderModel.getInstance().getCategories()) {
        if (!CommandEvaluator.RECENT.equals(cat.getName())) {
            JCheckBoxMenuItem item = new CategoryCheckBoxMenuItem(cat,
                    evalCats);
            pm.add(item);
        }
    }

    pm.show(getInnerComponent(), 0, getInnerComponent().getHeight() - 1);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:AbstractQuickSearchComboBar.java

示例5: actionPerformed

import javax.swing.JCheckBoxMenuItem; //導入依賴的package包/類
public void actionPerformed(ActionEvent ev) {
    Object source = ev.getSource();
    // react just on submenu items, not on submenu click itself
    if (source instanceof JCheckBoxMenuItem) {
        JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem)source;
        String filterName = (String)(menuItem.getClientProperty(PROP_FILTER_NAME));
        filtersDesc.setSelected(filterName, menuItem.isSelected());
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:FiltersDescriptor.java

示例6: initialize

import javax.swing.JCheckBoxMenuItem; //導入依賴的package包/類
private void initialize() {
	mouseToolbarCheckbox = new JCheckBoxMenuItem("Mouse toolbar");
	zoomToolbarCheckbox = new JCheckBoxMenuItem("Zoom toolbar");
	simulationToolbarCheckbox = new JCheckBoxMenuItem("Simulation toolbar");
	dbToolbarCheckbox = new JCheckBoxMenuItem("Explore toolbar");
	undoToolbarCheckbox = new JCheckBoxMenuItem("Undo/Redo toolbar");
	undoToolbarCheckbox.setSelected(true);

	mouseToolbarCheckbox.addItemListener(this);
	zoomToolbarCheckbox.addItemListener(this);
	simulationToolbarCheckbox.addItemListener(this);
	dbToolbarCheckbox.addItemListener(this);
	undoToolbarCheckbox.addItemListener(this);

	this.add(mouseToolbarCheckbox);
	this.add(zoomToolbarCheckbox);
	this.add(simulationToolbarCheckbox);
	this.add(dbToolbarCheckbox);
	this.add(undoToolbarCheckbox);

}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:22,代碼來源:ViewMenu.java

示例7: getPopupMenuItem

import javax.swing.JCheckBoxMenuItem; //導入依賴的package包/類
public @Override JMenuItem getPopupMenuItem(JTextComponent target) {
    Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
    boolean toolbarVisible = prefs.getBoolean(SimpleValueNames.TOOLBAR_VISIBLE_PROP, EditorPreferencesDefaults.defaultToolbarVisible);
    
    JCheckBoxMenuItem item = new JCheckBoxMenuItem(
        NbBundle.getBundle(ToggleToolbarAction.class).getString("PROP_base_toolbarVisible"), //NOI18N
        toolbarVisible);
    
    item.addItemListener( new ItemListener() {
        public @Override void itemStateChanged(ItemEvent e) {
            actionPerformed(null,null);
        }
    });
    
    return item;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:NbEditorKit.java

示例8: createTypeMenu

import javax.swing.JCheckBoxMenuItem; //導入依賴的package包/類
/**
 * @return menu that allows to select possible column types
 */
private JMenu createTypeMenu() {
	ButtonGroup typeGroup = new ButtonGroup();
	JMenu typeChangeItem = new JMenu(CHANGE_TYPE_LABEL);
	typeChangeItem.setToolTipText(CHANGE_TYPE_TIP);
	for (final ColumnType columnType : ColumnType.values()) {
		final JCheckBoxMenuItem checkboxItem = new JCheckBoxMenuItem(
				DataImportWizardUtils.getNameForColumnType(columnType));
		if (columnType == metaData.getColumnMetaData(columnIndex).getType()) {
			checkboxItem.setSelected(true);
		}
		checkboxItem.addItemListener(new ItemListener() {

			@Override
			public void itemStateChanged(ItemEvent e) {
				if (e.getStateChange() == ItemEvent.SELECTED) {
					changeType(columnType);
				}

			}
		});
		typeGroup.add(checkboxItem);
		typeChangeItem.add(checkboxItem);
	}
	return typeChangeItem;
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:29,代碼來源:ConfigureDataTableHeader.java

示例9: 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

示例10: 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

示例11: addCheckbox

import javax.swing.JCheckBoxMenuItem; //導入依賴的package包/類
/**
 * Adds a checkbox item with a given name to the options, and returns the
 * associated (fresh) menu item.
 * @param name the name of the checkbox menu item to add
 * @return the added {@link javax.swing.JCheckBoxMenuItem}
 */
private final JCheckBoxMenuItem addCheckbox(final String name) {
    JCheckBoxMenuItem result = new JCheckBoxMenuItem(name);
    boolean selected = userPrefs.getBoolean(name, boolOptionDefaults.get(name));
    boolean enabled = isEnabled(name);
    result.setSelected(selected & enabled);
    this.itemMap.put(name, result);
    if (enabled) {
        result.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                userPrefs.putBoolean(name, e.getStateChange() == ItemEvent.SELECTED);
            }
        });
    } else {
        result.setEnabled(false);
    }
    return result;
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:25,代碼來源:Options.java

示例12: paintMenuItem

import javax.swing.JCheckBoxMenuItem; //導入依賴的package包/類
/**
 * Paints a menu item
 * @param g The graphics to use
 * @param menuItem The menu item to paint
 * @param hasCursor Whether or not the cursor is over the component
 * @param defaultTextIconGap The gap between the text and the icon
 */
private static final void paintMenuItem(Graphics2D g, JMenuItem menuItem, boolean hasCursor, int defaultTextIconGap){
	g.setColor(Main.config.customColors ? Main.config.background : Color.BLACK);
	g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
	if(menuItem instanceof JCheckBoxMenuItem && menuItem.isSelected()){
		g.drawImage(ColorManager.checkmark, 0, 0, 22, 22, 0, 0, 100, 100, menuItem);
	}else if(menuItem instanceof JMenu){
		g.drawImage(ColorManager.arrow, menuItem.getWidth() - 12, 5, menuItem.getWidth(), 17, 0, 0, 128, 128, menuItem);
	}
	g.setColor(Main.config.customColors ? Main.config.foreground : Color.CYAN);
	if(hasCursor){
		g.drawLine(0, 0, menuItem.getWidth(), 0);
		g.drawLine(0, menuItem.getHeight() - 1, menuItem.getWidth(), menuItem.getHeight() - 1);
		Composite prev = g.getComposite();
		g.setComposite(MenuItemUI.mode);
		g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
		g.setComposite(prev);
	}
	FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g);
	int mnemIndex = menuItem.getDisplayedMnemonicIndex();
	int y = (22 - fm.getHeight()) / 2;
	SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, menuItem.getText(), mnemIndex, 22 + defaultTextIconGap, y + fm.getAscent());
}
 
開發者ID:RoanH,項目名稱:KeysPerSecond,代碼行數:30,代碼來源:Menu.java

示例13: MultiUDPNetworkDVS128Camera

import javax.swing.JCheckBoxMenuItem; //導入依賴的package包/類
public MultiUDPNetworkDVS128Camera() {
      setName("MultiUDPNetworkDVS128Camera");

      setSizeX(MAX_NUM_CAMERAS * 128);
      setSizeY(128);
      setEventExtractor(new Extractor(this));
      chipMenu = new JMenu("MultiCamera");
      chipMenu.getPopupMenu().setLightWeightPopupEnabled(false);
      chipMenu.add(new JMenuItem(new ShowClientMapperAction()));
      loadClientMappingPrefs();
      displayMethod=new MultiUDPNetworkDVS128CameraDisplayMethod(getCanvas());
      getCanvas().addDisplayMethod(displayMethod);
      getCanvas().setDisplayMethod(displayMethod);
      chipMenu.add(new JCheckBoxMenuItem(new DisplayCameraInfoAction(displayMethod)));
chipMenu.add(new JMenuItem(new ShowPowerSettingsAction()));
      activateCameras();
}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:18,代碼來源:MultiUDPNetworkDVS128Camera.java

示例14: buildViewMenu

import javax.swing.JCheckBoxMenuItem; //導入依賴的package包/類
private void buildViewMenu() {
	
	ButtonGroup buttonGroup = new ButtonGroup();
	
	setCodeHMenu(new JMenu("Code highlighting"));
	raCodeHighLighting = new JCheckBoxMenuItem("Relational Algebra", true);
	sqlCodeHighLighting = new JCheckBoxMenuItem("SQL", true);
	
	getCodeHMenu().add(raCodeHighLighting);
	getCodeHMenu().add(sqlCodeHighLighting);
	
	setShowMenu(new JMenu("Show"));
	consoleShow = new JCheckBoxMenuItem("Console", true);
	dbViewerShow = new JCheckBoxMenuItem("DB Viewer", true);
	queriesListShow = new JCheckBoxMenuItem("Query List", true);
	
	getShowMenu().add(dbViewerShow);
	getShowMenu().add(queriesListShow);
	getShowMenu().add(consoleShow);
	
	setViewMenu(new JMenu());
	getViewMenu().setMnemonic(KeyEvent.VK_V);
	getViewMenu().add(getCodeHMenu());
	getViewMenu().add(getShowMenu());
}
 
開發者ID:tteguayco,項目名稱:JITRAX,代碼行數:26,代碼來源:MenuBar.java

示例15: initialize

import javax.swing.JCheckBoxMenuItem; //導入依賴的package包/類
private void initialize() {
	mouseToolbarCheckbox = new JCheckBoxMenuItem("Mouse toolbar");
	zoomToolbarCheckbox = new JCheckBoxMenuItem("Zoom toolbar");
	simulationToolbarCheckbox = new JCheckBoxMenuItem("Simulation toolbar");
	dbToolbarCheckbox = new JCheckBoxMenuItem("Explore toolbar");
	undoToolbarCheckbox = new JCheckBoxMenuItem("Undo/Redo toolbar");
	undoToolbarCheckbox.setSelected(true);
	
	mouseToolbarCheckbox.addItemListener(this);
	zoomToolbarCheckbox.addItemListener(this);
	simulationToolbarCheckbox.addItemListener(this);
	dbToolbarCheckbox.addItemListener(this);
	undoToolbarCheckbox.addItemListener(this);
	
	this.add(mouseToolbarCheckbox);
	this.add(zoomToolbarCheckbox);
	this.add(simulationToolbarCheckbox);
	this.add(dbToolbarCheckbox);
	this.add(undoToolbarCheckbox);

	
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:23,代碼來源:ViewMenu.java


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