本文整理汇总了Java中javax.swing.JMenuItem.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java JMenuItem.getHeight方法的具体用法?Java JMenuItem.getHeight怎么用?Java JMenuItem.getHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JMenuItem
的用法示例。
在下文中一共展示了JMenuItem.getHeight方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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);
}