當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。