本文整理匯總了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);
}