本文整理了Java中javax.swing.JMenuItem.getParent()
方法的一些代码示例,展示了JMenuItem.getParent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMenuItem.getParent()
方法的具体详情如下:
包路径:javax.swing.JMenuItem
类名称:JMenuItem
方法名:getParent
暂无
代码示例来源:origin: org.terracotta.modules/tim-ehcache-2.x-ui
public void actionPerformed(ActionEvent e) {
JMenuItem mitem = (JMenuItem) e.getSource();
JPopupMenu popup = (JPopupMenu) mitem.getParent();
if (enable) {
queryEnableSelectedCaches(popup);
} else {
queryDisableSelectedCaches(popup);
}
}
}
代码示例来源:origin: org.terracotta.modules/tim-ehcache-2.x-ui
public void actionPerformed(ActionEvent e) {
JMenuItem mitem = (JMenuItem) e.getSource();
JPopupMenu popup = (JPopupMenu) mitem.getParent();
if (enable) {
queryEnableBulkLoad(popup);
} else {
queryDisableBulkLoad(popup);
}
}
}
代码示例来源:origin: org.terracotta.modules/tim-ehcache-2.x-ui
public void actionPerformed(ActionEvent e) {
JMenuItem mitem = (JMenuItem) e.getSource();
JPopupMenu popup = (JPopupMenu) mitem.getParent();
queryClearSelectedCaches(popup);
}
}
代码示例来源:origin: org.terracotta.modules/tim-ehcache-2.x-ui
public void actionPerformed(ActionEvent ae) {
JMenuItem mitem = (JMenuItem) ae.getSource();
JPopupMenu popup = (JPopupMenu) mitem.getParent();
if (enable) {
queryEnableSelectedStats(popup);
} else {
queryDisableSelectedStats(popup);
}
}
}
代码示例来源:origin: stackoverflow.com
public JMenu getMenuBarMenu(JMenuItem item)
{
JMenuItem menu = null;
while (menu == null)
{
JPopupMenu popup = (JPopupMenu)item.getParent();
item = (JMenuItem)popup.getInvoker();
if (item.getParent() instanceof JMenuBar)
menu = item;
}
return (JMenu)menu;
}
代码示例来源:origin: stackoverflow.com
class MenuActionListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
JMenuItem menuitem=(JMenuItem) e.getSource();
JPopupMenu popupMenu =(JPopupMenu) menuitem.getParent();
int index= popupMenu.getComponentIndex(menuitem);
System.out.println("index:"+index);
}
}
代码示例来源:origin: stackoverflow.com
private void CommonMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
JMenuItem menuItem = (JMenuItem)evt.getSource(); // source is clicked JMenuItem
JPopupMenu popupMenu = (JPopupMenu)menuItem.getParent(); // get parent JPopupMenu
Component component = popupMenu.getInvoker(); // who called JPopupMenu?
System.out.println(component.getName()); // get component name
}
代码示例来源:origin: com.github.insubstantial/substance
/**
* Cleans the layout metrics of the popup menu of the specified menu item.
*
* @param menuItem
* Menu item.
*/
private static void cleanPopupLayoutMetrics(JMenuItem menuItem) {
Component comp = menuItem.getParent();
if (comp instanceof JPopupMenu) {
JPopupMenu popupMenu = (JPopupMenu) comp;
cleanPopupLayoutMetrics(popupMenu);
}
}
代码示例来源:origin: joel-costigliola/assertj-swing
@RunsInCurrentThread
private Component parentOrInvokerOf(@Nonnull JMenuItem menuItem) {
Component parent = menuItem.getParent();
if (parent instanceof JPopupMenu) {
parent = ((JPopupMenu) parent).getInvoker();
}
return parent;
}
代码示例来源:origin: jpcsp/jpcsp
private void copyItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copyItemActionPerformed
JTable source = (JTable) ((JPopupMenu) ((JMenuItem) evt.getSource()).getParent()).getInvoker();
ActionEvent ae = new ActionEvent(source, ActionEvent.ACTION_PERFORMED, "");
source.getActionMap().get("copy").actionPerformed(ae);
}//GEN-LAST:event_copyItemActionPerformed
代码示例来源:origin: com.eas.platypus/platypus-js-forms
@ScriptFunction
@Override
public void setLeft(int aValue) {
if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) {
MarginLayout.ajustLeft(this, aValue);
}
super.setLocation(aValue, getTop());
}
代码示例来源:origin: com.github.arnabk/pgslookandfeel
protected void paintText(Graphics g, JMenuItem c, Rectangle textRect, String text) {
PgsUtils.installAntialiasing(g);
if (c.getParent() instanceof JMenuBar) {
c.setForeground(UIManager.getColor("MenuBarMenu.foreground"));
selectionForeground = UIManager.getColor("MenuBarMenu.foreground");
}
super.paintText(g, c, textRect, text);
PgsUtils.uninstallAntialiasing(g);
}
}
代码示例来源:origin: com.eas.platypus/platypus-js-forms
@ScriptFunction
@Override
public void setTop(int aValue) {
if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) {
MarginLayout.ajustTop(this, aValue);
}
super.setLocation(getLeft(), aValue);
}
代码示例来源:origin: com.eas.platypus/platypus-js-forms
@ScriptFunction(name = "parent", jsDoc = PARENT_JSDOC)
@Override
public Widget getParentWidget() {
java.awt.Container parent = super.getParent();
if (parent instanceof JPopupMenu && ((JPopupMenu) parent).getInvoker() instanceof JMenu) {
parent = (java.awt.Container) ((JPopupMenu) parent).getInvoker();
}
return parent instanceof HasChildren ? (Widget) parent : null;
}
代码示例来源:origin: com.jidesoft/jide-oss
@Override
public Dimension getPreferredSize(JComponent c) {
Dimension size = super.getPreferredSize(c);
if (menuItem instanceof JMenu && ((JMenu) menuItem).isTopLevelMenu() &&
isDownArrowVisible(menuItem.getParent())) {
if (JideSwingUtilities.getOrientationOf(menuItem) == SwingConstants.HORIZONTAL)
size.width += 11;
else
size.height += 11;
}
return size;
}
代码示例来源:origin: abbot/abbot
public static String getPath(JMenuItem item) {
Component parent = item.getParent();
if (parent instanceof JPopupMenu) {
parent = ((JPopupMenu)parent).getInvoker();
}
if (parent instanceof JMenuItem) {
return getPath((JMenuItem)parent) + "|" + item.getText();
}
return item.getText();
}
代码示例来源:origin: com.jidesoft/jide-oss
@Override
public Dimension getPreferredSize(JComponent c) {
Dimension size = super.getPreferredSize(c);
if (menuItem instanceof JMenu && ((JMenu) menuItem).isTopLevelMenu() &&
isDownArrowVisible(menuItem.getParent())) {
if (JideSwingUtilities.getOrientationOf(menuItem) == SwingConstants.HORIZONTAL)
size.width += 11;
else
size.height += 11;
}
return size;
}
}
代码示例来源:origin: com.jidesoft/jide-oss
@Override
public Dimension getPreferredSize(JComponent c) {
Dimension size = super.getPreferredSize(c);
if (menuItem instanceof JMenu && ((JMenu) menuItem).isTopLevelMenu() &&
isDownArrowVisible(menuItem.getParent())) {
if (JideSwingUtilities.getOrientationOf(menuItem) == SwingConstants.HORIZONTAL)
size.width += 11;
else
size.height += 11;
}
return size;
}
}
代码示例来源:origin: com.github.insubstantial/substance
@Override
public void mouseEntered(MouseEvent e) {
if (this.toRepaint()) {
stateTransitionTracker.turnOffModelChangeTracking();
menuItem.getModel().setRollover(true);
stateTransitionTracker.onModelStateChanged();
// fix for issue 371 - repaint the menu bar since the
// menu is marked as flat
Rectangle bounds = menuItem.getBounds();
menuItem.getParent().repaint(bounds.x, bounds.y,
bounds.width, bounds.height);
}
}
代码示例来源:origin: freeplane/freeplane
@Test
public void createsMenuButtonWithAction() {
new EntryAccessor().setComponent(menuEntry, menu);
menuEntry.addChild(actionEntry);
menuActionGroupBuilder.visit(actionEntry);
JMenuItem item = (JMenuItem)new EntryAccessor().getComponent(actionEntry);
assertThatMenuItemHasCorrectAction(item);
assertThat(item.getParent(), CoreMatchers.<Container>equalTo(menu.getPopupMenu()));
}
内容来源于网络,如有侵权,请联系作者删除!