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


Java JMenuItem.isSelected方法代碼示例

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


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

示例1: paintMenuItem

import javax.swing.JMenuItem; //導入方法依賴的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

示例2: NbMenuItem

import javax.swing.JMenuItem; //導入方法依賴的package包/類
/**
     * @param it
     * @return instance of NbMenuItem constructed from parameter it */
    public NbMenuItem(JMenuItem it) {
        setName(it.getText());//getLabel();
        this.accelerator = (it.getAccelerator() == null) ? null : it.getAccelerator().toString();
        this.mnemo = (char) it.getMnemonic();
//        System.out.println("NbMenuItem ["+name+"] - mnemo: ["+it.getMnemonic()+"]"); why are the mnemonic always in capital?
        this.enabled = it.isEnabled();
        this.checkbox = it instanceof JCheckBoxMenuItem;
        this.radiobutton = it instanceof JRadioButtonMenuItem;
        this.checked = it.isSelected();
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:NbMenuItem.java

示例3: getValue

import javax.swing.JMenuItem; //導入方法依賴的package包/類
/**
 * Returns the current value of a given options name. If the option is a
 * checkbox menu, the value is <code>0</code> for <code>false</code> and
 * <code>1</code> for <code>true</code>.
 * @param name the name of the checkbox menu item for which to get the value
 * @return the current value of the checkbox item with the given name
 */
public int getValue(String name) {
    JMenuItem item = this.itemMap.get(name);
    if (item instanceof BehaviourOption) {
        return ((BehaviourOption) item).getValue();
    } else {
        return item.isSelected() ? 1 : 0;
    }
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:16,代碼來源:Options.java


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