本文整理汇总了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();
}
示例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);
}
}