java.awt.MenuItem.getParent()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(129)

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

暂无

代码示例

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

MenuItem root = null;
MenuItem curr = myMenuItem;
while(curr.getParent() != null) {
  curr = curr.getParent(); 
}
root = curr;

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

List<Integer> toPositions(MenuItem i) {
  List<Integer> positions = new LinkedList<>();
  while (i != null) {
    position.addFirst(i.getPosition());
    i = i.getParent();
  }
  return positions;
}

代码示例来源:origin: imagej/ImageJA

public void actionPerformed(ActionEvent e) {
  MenuItem item = (MenuItem)e.getSource();
  String cmd = e.getActionCommand();
  PopupMenu popup = (PopupMenu)item.getParent();
  int tool = -1;
  for (int i=CUSTOM1; i<getNumTools(); i++) {
    if (popup==menus[i]) {
      tool = i;
      break;
    }
  }
  if (tool==-1) return;
  if (tools[tool]!=null)
    tools[tool].runMenuTool(names[tool], cmd);
}

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

public void actionPerformed(ActionEvent e) {
  MenuItem item = (MenuItem)e.getSource();
  String cmd = e.getActionCommand();
  PopupMenu popup = (PopupMenu)item.getParent();
  int tool = -1;
  for (int i=CUSTOM1; i<getNumTools(); i++) {
    if (popup==menus[i]) {
      tool = i;
      break;
    }
  }
  if (tool==-1) return;
  if (tools[tool]!=null)
    tools[tool].runMenuTool(names[tool], cmd);
}

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

/** Handles CheckboxMenuItem state changes. */
public void itemStateChanged(ItemEvent e) {
  MenuItem item = (MenuItem)e.getSource();
  MenuComponent parent = (MenuComponent)item.getParent();
  String cmd = e.getItem().toString();
  if ("Autorun Examples".equals(cmd)) // Examples>Autorun Examples
    Prefs.autoRunExamples = e.getStateChange()==1;
  else if ((Menu)parent==Menus.window)
    WindowManager.activateWindow(cmd, item);
  else
    doCommand(cmd);
}

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

public void actionPerformed(ActionEvent evt) {
  String cmd = evt.getActionCommand();
  ImageJ.setCommandName(cmd);
  MenuItem item = (MenuItem)evt.getSource();
  MenuContainer parent = item.getParent();
  if (parent instanceof PopupMenu) {
    for (int i=0; i<nMacros; i++) {
      if (macroNames[i].equals("Popup Menu")) {
        new MacroRunner(pgm, macroStarts[i], "Popup Menu", cmd);
        return;
      }
    }
  }
  runMacro(cmd);
}

代码示例来源:origin: imagej/ImageJA

public void actionPerformed(ActionEvent evt) {
  String cmd = evt.getActionCommand();
  ImageJ.setCommandName(cmd);
  MenuItem item = (MenuItem)evt.getSource();
  MenuContainer parent = item.getParent();
  if (parent instanceof PopupMenu) {
    for (int i=0; i<nMacros; i++) {
      if (macroNames[i].equals("Popup Menu")) {
        new MacroRunner(pgm, macroStarts[i], "Popup Menu", cmd);
        return;
      }
    }
  }
  runMacro(cmd);
}

代码示例来源:origin: imagej/ImageJA

/** Handles CheckboxMenuItem state changes. */
public void itemStateChanged(ItemEvent e) {
  MenuItem item = (MenuItem)e.getSource();
  MenuComponent parent = (MenuComponent)item.getParent();
  String cmd = e.getItem().toString();
  if ("Autorun Examples".equals(cmd)) // Examples>Autorun Examples
    Prefs.autoRunExamples = e.getStateChange()==1;
  else if ((Menu)parent==Menus.window)
    WindowManager.activateWindow(cmd, item);
  else
    doCommand(cmd);
}

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

if (invoker == null) {
  top = item.getParent();
  while (top instanceof Menu
      && !(((Menu)top).getParent() instanceof MenuBar)) {
  top = item.getParent();
  while (top instanceof Menu
      && !(((Menu)top).getParent() instanceof Component)) {
while (mi.getParent() != top) {
  mi = (MenuItem)mi.getParent();
  path = mi.getLabel() + "|" + path;

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

private void setMenu(final Table table) {
  Listener popUpListener = new Listener() {

    @Override
    public void handleEvent(Event event) {
      MenuItem item = (MenuItem)event.widget;
      Menu pare = item.getParent();
      Decorations fdf = pare.getParent();

      // Now you can access the table from within the Listener
      System.out.println(table);
    }
  };
  Menu menu = new Menu(table); // where table1 is your table
  MenuItem item1 = new MenuItem(menu, SWT.PUSH);
  item1.setText("Copy cell");
  item1.addListener(SWT.Selection, popUpListener);
  MenuItem item2 = new MenuItem(menu, SWT.PUSH);
  item2.setText("Copy row");
  item2.addListener(SWT.Selection, popUpListener);
  MenuItem item3 = new MenuItem(menu, SWT.PUSH);
  item3.setText("Copy column");
  item3.addListener(SWT.Selection, popUpListener);
  MenuItem item4 = new MenuItem(menu, SWT.PUSH);
  item4.setText("Copy all");
  item4.addListener(SWT.Selection, popUpListener);
  table.setMenu(menu);
}

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

if (item.getParent()==Menus.getOpenRecentMenu()) {
  new RecentOpener(cmd); // open image in separate thread
  return;
} else if (item.getParent()==Menus.getPopupMenu()) {
  Object parent = Menus.getPopupMenu().getParent();
  if (parent instanceof ImageCanvas)

代码示例来源:origin: imagej/ImageJA

if (item.getParent()==Menus.getOpenRecentMenu()) {
  new RecentOpener(cmd); // open image in separate thread
  return;
} else if (item.getParent()==Menus.getPopupMenu()) {
  Object parent = Menus.getPopupMenu().getParent();
  if (parent instanceof ImageCanvas)

相关文章