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


Java JMenuItem.getModel方法代碼示例

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


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

示例1: paintIcon

import javax.swing.JMenuItem; //導入方法依賴的package包/類
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
	JMenuItem b = (JMenuItem) c;
	ButtonModel model = b.getModel();

	g.translate(x, y);

	boolean isSelected = model.isSelected();
	boolean isEnabled = model.isEnabled();

	Graphics2D g2 = (Graphics2D) g;
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

	// draw check mark
	if (isSelected) {
		g2.setStroke(CHECKBOX_STROKE);
		if (isEnabled) {
			g2.setColor(Colors.CHECKBOX_CHECKED);
		} else {
			g2.setColor(Colors.CHECKBOX_CHECKED_DISABLED);
		}
		g2.drawLine(2, 6, 5, 8);
		g2.drawLine(5, 8, 9, 1);
	}
	g.translate(-x, -y);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:27,代碼來源:CheckBoxMenuItemIcon.java

示例2: paintBackground

import javax.swing.JMenuItem; //導入方法依賴的package包/類
@Override
	protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
		ButtonModel model = menuItem.getModel();
		Color oldColor = g.getColor();
		if (model.isArmed()
				|| (menuItem instanceof JMenu && model.isSelected())) {
			paintButtonPressed(g, menuItem);
		} else {
			g.setColor(this.colorBg);
			//g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());//(0, 0, gap + 1, menuItem.getHeight());
//			g.drawLine(gap + 1, 0, gap + 1, menuItem.getHeight());
//			if (menuItem.getIcon() != null) {
//				int gap = menuItem.getIcon().getIconWidth() + 2;
//				g.setColor(this.darkColor);
//				g.drawLine(gap, 0, gap, menuItem.getHeight());
//				g.setColor(this.lightColor);
//				g.drawLine(gap + 1, 0, gap + 1, menuItem.getHeight());
//			}
		}
		g.setColor(oldColor);
	}
 
開發者ID:kmarius,項目名稱:xdman,代碼行數:22,代碼來源:XDMMenuUI.java

示例3: performAction

import javax.swing.JMenuItem; //導入方法依賴的package包/類
private static void performAction(StayOpen item, int modifiers) {
    JMenuItem i = item.getItem();
    
    // Skip disabled items
    if (!item.getItem().isEnabled()) return;
    
    // Handle toggle items
    if (i.getModel() instanceof JToggleButton.ToggleButtonModel)
        i.setSelected(!i.isSelected());
    
    // Invoke item action
    item.actionPerformed(new ActionEvent(item, ActionEvent.ACTION_PERFORMED,
                         item.getItem().getActionCommand(),
                         EventQueue.getMostRecentEventTime(), modifiers));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:StayOpenPopupMenu.java

示例4: drawMenuItemBackground

import javax.swing.JMenuItem; //導入方法依賴的package包/類
public static void drawMenuItemBackground(Graphics g, JMenuItem menuItem) {
	Color oldColor = g.getColor();
	ButtonModel model = menuItem.getModel();
	int w = menuItem.getWidth();
	int h = menuItem.getHeight();

	if (model.isArmed() || model.isSelected() && menuItem instanceof JMenu) {
		g.setColor(Colors.MENU_ITEM_BACKGROUND_SELECTED);
		g.fillRect(0, 0, w, h);
	} else if (!(menuItem instanceof JMenu && ((JMenu) menuItem).isTopLevelMenu())) {
		drawMenuItemFading(menuItem, g);
	}
	g.setColor(oldColor);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:15,代碼來源:RapidLookTools.java

示例5: paintBackground

import javax.swing.JMenuItem; //導入方法依賴的package包/類
@Override
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
	ButtonModel model = menuItem.getModel();
	Color oldColor = g.getColor();
	int menuWidth = menuItem.getWidth();
	int menuHeight = menuItem.getHeight();

	g.setColor(colorBg);
	g.fillRect(0, 0, menuWidth, menuHeight);

	if (model.isArmed()
			|| (menuItem instanceof JMenu && model.isSelected())) {
		paintButtonPressed(g, menuItem);
	} else {
		// if (menuItem.getIcon() != null) {
		// int gap = menuItem.getIcon().getIconWidth() + 2;
		// g.setColor(this.darkColor);
		// g.drawLine(gap, 0, gap, menuItem.getHeight());
		// g.setColor(this.lightColor);
		// g.drawLine(gap + 1, 0, gap + 1, menuItem.getHeight());
		// }
	}

	if (menuItem instanceof JCheckBoxMenuItem) {
		if (((JCheckBoxMenuItem) menuItem).isSelected()) {
			// chkIcon.paintIcon(menuItem, g, 5, 5);
		}
	}

	g.setColor(oldColor);
}
 
開發者ID:kmarius,項目名稱:xdman,代碼行數:32,代碼來源:XDMMenuItemUI.java

示例6: paintIcon

import javax.swing.JMenuItem; //導入方法依賴的package包/類
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
	JMenuItem b = (JMenuItem) c;
	ButtonModel bm = b.getModel();

	g.translate(x, y);

	boolean isSelected = bm.isSelected();
	boolean isEnabled = bm.isEnabled();
	boolean isPressed = bm.isPressed();

	Graphics2D g2 = (Graphics2D) g;
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

	// drawing background section
	if (!isEnabled) {
		g2.setColor(Colors.RADIOBUTTON_BORDER_DISABLED);
	} else {
		if (isPressed) {
			g2.setColor(Colors.RADIOBUTTON_BORDER_FOCUS);
		} else {
			g2.setColor(Colors.RADIOBUTTON_BORDER);
		}
	}
	g2.setStroke(RADIO_STROKE);
	Shape circle = new Ellipse2D.Double(0, 0, 9, 9);
	g2.draw(circle);

	// drawing sphere
	if (isSelected) {
		if (isEnabled) {
			g2.setColor(Colors.RADIOBUTTON_CHECKED);
		} else {
			g2.setColor(Colors.RADIOBUTTON_CHECKED_DISABLED);
		}
		circle = new Ellipse2D.Double(3, 3, 4, 4);
		g2.fill(circle);
	}

	g.translate(-x, -y);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:43,代碼來源:RadioButtonMenuItemIcon.java


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