当前位置: 首页>>代码示例>>Java>>正文


Java JMenuItem.getWidth方法代码示例

本文整理汇总了Java中javax.swing.JMenuItem.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java JMenuItem.getWidth方法的具体用法?Java JMenuItem.getWidth怎么用?Java JMenuItem.getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JMenuItem的用法示例。


在下文中一共展示了JMenuItem.getWidth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

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

示例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();
	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

示例3: drawSubselectedItem

import javax.swing.JMenuItem; //导入方法依赖的package包/类
private void drawSubselectedItem(Graphics2D g2, JMenuItem item) {
    Point location = SwingUtilities.convertPoint(item, new java.awt.Point(0, 0), this);
    g2.translate(location.x, location.y);

    int iconGap = item.getIconTextGap();
    int iconLeft = getIconLeft(item);
    int iconWidth = getIconWidth(item);
    int iconHeight = getIconHeight(item);
    int iconTop = (item.getHeight() - iconHeight) / 2;
    int accelWidth = getAcceleratorWidth(item);

    int textWidth = item.getWidth() - iconLeft - iconWidth - iconGap - accelWidth;
    int accelLeft = item.getWidth() - accelWidth;

    // draw bounding boxes
    g2.setColor(Color.LIGHT_GRAY);
    //g2.drawRect(iconLeft, 0, iconWidth-1, item.getHeight()-1);
    //g2.drawRect(textLeft, 0, textWidth-1, item.getHeight()-1);
    //draw the accelerator areaa
    //g2.drawRect(accelLeft, 0, accelWidth - 1, item.getHeight() - 1);

    // draw the selection rectangles
    g2.setStroke(SELECTION_STROKE);
    g2.setColor(SELECTION_COLOR);
    switch (canvas.getCurrentSelectedPortion()) {
        case Icon:
            {
                if (item.getIcon() != null) {
                    g2.drawRect(iconLeft - 1, iconTop - 1, iconWidth + 1, iconHeight + 1);
                }
                break;
            }
        case Text:
            {
                g2.drawRect(iconLeft + iconWidth + iconGap - 1, -1, textWidth + 1, item.getHeight() + 1);
                break;
            }
        case Accelerator:
            {
                if (item instanceof javax.swing.JMenu) {
                    break;
                }
                g2.drawRect(accelLeft - 1, -1, accelWidth + 1, item.getHeight() + 1);
                break;
            }
        case All:
            {
                g2.drawRect(0, 0, item.getWidth() - 1, item.getHeight() - 1);
            }
    }
    g2.translate(-location.x, -location.y);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:53,代码来源:DropTargetLayer.java

示例4: getAcceleratorLeft

import javax.swing.JMenuItem; //导入方法依赖的package包/类
private static int getAcceleratorLeft(JMenuItem item) {
    return item.getWidth() - getAcceleratorWidth(item);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:DropTargetLayer.java


注:本文中的javax.swing.JMenuItem.getWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。