當前位置: 首頁>>代碼示例>>Java>>正文


Java JMenu.getParent方法代碼示例

本文整理匯總了Java中javax.swing.JMenu.getParent方法的典型用法代碼示例。如果您正苦於以下問題:Java JMenu.getParent方法的具體用法?Java JMenu.getParent怎麽用?Java JMenu.getParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JMenu的用法示例。


在下文中一共展示了JMenu.getParent方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildMenuElementArray

import javax.swing.JMenu; //導入方法依賴的package包/類
private String buildMenuElementArray(JMenuItem leaf) {
    Vector<JMenuItem> elements = new Vector<JMenuItem>();

    elements.insertElementAt(leaf, 0);
    Component current = leaf.getParent();

    while (current != null) {
        if (current instanceof JPopupMenu) {
            JPopupMenu pop = (JPopupMenu) current;
            current = pop.getInvoker();
        } else if (current instanceof JMenu) {
            JMenu menu = (JMenu) current;
            elements.insertElementAt(menu, 0);
            current = menu.getParent();
        } else if (current instanceof JMenuBar) {
            break;
        } else {
            current = current.getParent();
        }
    }
    mainMenu = elements.get(0);
    JMenuItem parent = null;
    StringBuilder sb = new StringBuilder();
    RComponentFactory finder = new RComponentFactory(omapConfig);
    for (JMenuItem jMenuItem : elements) {
        RComponent rComponent = finder.findRComponent(jMenuItem, null, recorder);
        recorder.recordMenuItem(rComponent);
        String text = JMenuItemJavaElement.getText(JMenuItemJavaElement.getItemText(jMenuItem), jMenuItem,
                parent == null ? new Component[0] : ((JMenu) parent).getMenuComponents());
        parent = jMenuItem;
        sb.append(text).append(">>");
    }
    sb.setLength(sb.length() - 2);
    return sb.toString();
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:36,代碼來源:RMenuItem.java

示例2: completeInterMenuDrag

import javax.swing.JMenu; //導入方法依賴的package包/類
private void completeInterMenuDrag(Point pt) {
    if(targetComponent == null) return;
    
    //check if it's still a valid target
    JComponent tcomp = getDeepestComponent(pt);
    if(targetComponent != tcomp) {
        menuEditLayer.formDesigner.toggleSelectionMode();
        return;
    }
    
    // conver to target component's coords.
    Point pt2 = SwingUtilities.convertPoint(menuEditLayer.glassLayer, pt, tcomp);
    if(tcomp instanceof JMenu) {
        JMenu menu = (JMenu) tcomp;
        
        
        // if dragging a jmenu onto a toplevel jmenu
        if(menu.getParent() instanceof JMenuBar && isOnlyJMenus(payloadComponents)) { //payloadComponent instanceof JMenu) {
            if(DropTargetLayer.isMenuLeftEdge(pt2, menu)) {
                menuEditLayer.moveRadComponentToBefore(payloadComponent, menu);
                return;
            } else if (DropTargetLayer.isMenuRightEdge(pt2, menu)) {
                menuEditLayer.moveRadComponentToAfter(payloadComponent, menu);
                return;
            } else {  // else must be in the center so just add to the menu instead of next to
                menuEditLayer.moveRadComponentInto(payloadComponent, menu);
                return;
            }
        }
        if(DropTargetLayer.isSubMenuRightEdge(pt2, menu)) {
            menuEditLayer.moveRadComponentInto(payloadComponent, menu);
        } else {
            if(DropTargetLayer.isBelowItem(pt2,menu)) {
                menuEditLayer.moveRadComponentToAfter(payloadComponent, targetComponent);
            } else {
                menuEditLayer.moveRadComponentToBefore(payloadComponent, targetComponent);
            }
        }
        return;
    }
    
    if(tcomp instanceof JMenuBar) {
        if(payloadComponent instanceof JMenu) {
            menuEditLayer.moveRadComponentInto(payloadComponent, targetComponent);
            return;
        } else {
            return;
        }
    }
    
    //if after or before the current item
    if(DropTargetLayer.isBelowItem(pt2,tcomp)) {
        menuEditLayer.moveRadComponentToAfter(payloadComponent, targetComponent);
    } else {
        menuEditLayer.moveRadComponentToBefore(payloadComponent, targetComponent);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:58,代碼來源:DragOperation.java


注:本文中的javax.swing.JMenu.getParent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。