javax.swing.JPopupMenu.getInvoker()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中javax.swing.JPopupMenu.getInvoker()方法的一些代码示例,展示了JPopupMenu.getInvoker()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JPopupMenu.getInvoker()方法的具体详情如下:
包路径:javax.swing.JPopupMenu
类名称:JPopupMenu
方法名:getInvoker

JPopupMenu.getInvoker介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-awt

private static boolean willPopupBeContained(JPopupMenu popup, Point origin) {
  if (!popup.isShowing()) {
    return false;
  }
  Window w = SwingUtilities.windowForComponent(popup.getInvoker());
  Rectangle r = new Rectangle(origin, popup.getSize());
  return (w != null) && w.getBounds().contains(r);
}

代码示例来源:origin: stackoverflow.com

JTable table = (JTable)popup.getInvoker();
System.out.println(table.getSelectedRow() + " : " + table.getSelectedColumn());

代码示例来源:origin: khuxtable/seaglass

/**
 * @param c
 * @return
 */
private Component getInvoker(JComponent c) {
  JPopupMenu popup = (JPopupMenu) c;
  return popup.getInvoker();
}

代码示例来源:origin: org.netbeans.api/org-openide-awt

public static void dynamicChangeToSubmenu(JPopupMenu popup, boolean usedToBeContained) {
  Object invoker = popup.getInvoker();

代码示例来源:origin: tinyMediaManager/tinyMediaManager

@Override
 public void actionPerformed(ActionEvent e) {
  if (menu.getInvoker() instanceof JTextComponent) {
   ((JTextComponent) menu.getInvoker()).cut();
  }
 }
});

代码示例来源:origin: tinyMediaManager/tinyMediaManager

@Override
 public void actionPerformed(ActionEvent e) {
  if (menu.getInvoker() instanceof JTextComponent) {
   ((JTextComponent) menu.getInvoker()).copy();
  }
 }
});

代码示例来源:origin: tinyMediaManager/tinyMediaManager

@Override
 public void actionPerformed(ActionEvent e) {
  if (menu.getInvoker() instanceof JTextComponent) {
   ((JTextComponent) menu.getInvoker()).paste();
  }
 }
});

代码示例来源:origin: net.imagej/ij-ui-swing

public Component findUltimateParent(Component c) {
 Component parent = c;
 while (null != parent.getParent()) {
  parent = parent.getParent();
  if (parent instanceof JPopupMenu) {
   JPopupMenu popup = (JPopupMenu) parent;
   parent = popup.getInvoker();
  }
 }
 return parent;
}
// == Diagnostics =======================================================

代码示例来源:origin: org.scijava/scijava-ui-swing

public Component findUltimateParent(final Component c) {
  Component parent = c;
  while (null != parent.getParent()) {
    parent = parent.getParent();
    if (parent instanceof JPopupMenu) {
      final JPopupMenu popup = (JPopupMenu) parent;
      parent = popup.getInvoker();
    }
  }
  return parent;
}

代码示例来源:origin: abbot/abbot

/** Returns the invoker, if any, of the given component.  Returns null if
 * the component is not on a popup of any sort.
 */
public static Component getInvoker(Component comp) {
  if (comp instanceof JPopupMenu)
    return ((JPopupMenu)comp).getInvoker();
  comp = comp.getParent();
  return comp != null ? getInvoker(comp) : null;
}

代码示例来源: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.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: abbot/abbot

/** Return an identifying tag for the popup menu. */
public String deriveTag(Component comp) {
  Component invoker = ((JPopupMenu)comp).getInvoker();
  return invoker == null ? "Popup menu"
    : "Popup on " + getTag(invoker);
}

代码示例来源:origin: abbot/abbot

private boolean isOnJMenuBar(Component item) {
  if (item instanceof javax.swing.JMenuBar)
    return true;
  Component parent = item instanceof JPopupMenu
    ? ((JPopupMenu)item).getInvoker() : item.getParent();
  return parent != null && isOnJMenuBar(parent);
}

代码示例来源: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: freeplane/freeplane

public void removeMenuComponent(final Component component) {
  final Container parent = component.getParent();
  if (parent != null) {
    parent.remove(component);
    if (parent instanceof JPopupMenu) {
      final Component invoker = ((JPopupMenu) parent).getInvoker();
      if (isExtraSubMenu(invoker) && parent.getComponentCount() == 0)
        removeMenuComponent(invoker);
    }
  }
}

代码示例来源:origin: tinyMediaManager/tinyMediaManager

@Override
 public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
  JTextComponent jtc = (JTextComponent) popupMenu.getInvoker();
  boolean enableCutCopy = (jtc.getSelectionEnd() - jtc.getSelectionStart()) > 0;
  boolean enablePaste = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null) != null;
  mntmCut.setEnabled(enableCutCopy);
  mntmCopy.setEnabled(enableCutCopy);
  mntmPaste.setEnabled(enablePaste);
 }
});

代码示例来源: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: net.sf.squirrel-sql.thirdpary-non-maven/openide

private static boolean willPopupBeContained(JPopupMenu popup, Point origin) {
  if (!popup.isShowing()) {
    return false;
  }
  Window w = SwingUtilities.windowForComponent (popup.getInvoker());
  Rectangle r = new Rectangle (origin, popup.getSize ());
  return w != null && w.getBounds ().contains (r);
}

代码示例来源: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();
}

相关文章

JPopupMenu类方法