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


Java JMenuItem.getIcon方法代码示例

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


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

示例1: configureMenuItem

import javax.swing.JMenuItem; //导入方法依赖的package包/类
void configureMenuItem(final JMenu parent, final JComponent c) {
    if(c instanceof JMenuItem) {
        JMenuItem item = (JMenuItem) c;
        if(!(item.getIcon() instanceof WrapperIcon)) {
            item.setIcon(new WrapperIcon(item.getIcon()));
        }
        installAcceleratorPreview(item);
        item.setBorderPainted(true);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:MenuEditLayer.java

示例2: getTextFromIcon

import javax.swing.JMenuItem; //导入方法依赖的package包/类
private static String getTextFromIcon(JMenuItem mi) {
    Icon icon = mi.getIcon();
    if (icon != null && icon instanceof ImageIcon) {
        String description = ((ImageIcon) icon).getDescription();
        return getNameFromImageDescription(description);
    }
    return null;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:9,代码来源:JMenuItemJavaElement.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: getIconWidth

import javax.swing.JMenuItem; //导入方法依赖的package包/类
private static int getIconWidth(JMenuItem item) {
    int iconWidth = item.getIcon() != null ? item.getIcon().getIconWidth() : 0;
    return iconWidth;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:DropTargetLayer.java

示例5: getIconHeight

import javax.swing.JMenuItem; //导入方法依赖的package包/类
private static int getIconHeight(JMenuItem item) {
    int iconHeight = item.getIcon() != null ? item.getIcon().getIconHeight() : 0;
    return iconHeight;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:DropTargetLayer.java


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