当前位置: 首页>>代码示例>>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;未经允许,请勿转载。