java.awt.Menu.remove()方法的使用及代码示例

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

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

暂无

代码示例

代码示例来源:origin: com.dorkbox/SystemTray

@Override
  public
  void run() {
    parent._native.remove(_native);
  }
});

代码示例来源:origin: com.dorkbox/SystemTray

@Override
  public
  void run() {
    _native.removeAll();
    _native.deleteShortcut();
    _native.setEnabled(false);
    _native.removeNotify();
    if (parent != null) {
      parent._native.remove(_native);
    }
  }
});

代码示例来源:origin: com.dorkbox/SystemTray

@Override
  public
  void run() {
    parent._native.remove(_native);
  }
});

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

/** Removes the specified item from the Window menu. */
static synchronized void removeWindowMenuItem(int index) {
  //IJ.log("removeWindowMenuItem: "+index+" "+windowMenuItems2+" "+window.getItemCount());
  if (ij==null)
    return;
  try {
    if (index>=0 && index<window.getItemCount()) {
      window.remove(WINDOW_MENU_ITEMS+index);
      if (index<windowMenuItems2) {
        windowMenuItems2--;
        if (windowMenuItems2==1) {
          window.remove(WINDOW_MENU_ITEMS);
          windowMenuItems2 = 0;
        }
      }
    }
  } catch (Exception e) {}
}

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

/** Removes the specified item from the Window menu. */
static synchronized void removeWindowMenuItem(int index) {
  //IJ.log("removeWindowMenuItem: "+index+" "+windowMenuItems2+" "+window.getItemCount());
  if (ij==null)
    return;
  try {
    if (index>=0 && index<window.getItemCount()) {
      window.remove(WINDOW_MENU_ITEMS+index);
      if (index<windowMenuItems2) {
        windowMenuItems2--;
        if (windowMenuItems2==1) {
          window.remove(WINDOW_MENU_ITEMS);
          windowMenuItems2 = 0;
        }
      }
    }
  } catch (Exception e) {}
}

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

/** Adds a file path to the beginning of the File/Open Recent submenu. */
public static synchronized void addOpenRecentItem(String path) {
  if (ij==null) return;
  int count = openRecentMenu.getItemCount();
  for (int i=0; i<count; ) {
    if (openRecentMenu.getItem(i).getLabel().equals(path)) {
      openRecentMenu.remove(i);
      count--;
    } else
      i++;
  }
  if (count==MAX_OPEN_RECENT_ITEMS)
    openRecentMenu.remove(MAX_OPEN_RECENT_ITEMS-1);
  MenuItem item = new MenuItem(path);
  openRecentMenu.insert(item, 0);
  item.addActionListener(ij);
}

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

/** Adds a file path to the beginning of the File/Open Recent submenu. */
public static synchronized void addOpenRecentItem(String path) {
  if (ij==null) return;
  int count = openRecentMenu.getItemCount();
  for (int i=0; i<count; ) {
    if (openRecentMenu.getItem(i).getLabel().equals(path)) {
      openRecentMenu.remove(i);
      count--;
    } else
      i++;
  }
  if (count==MAX_OPEN_RECENT_ITEMS)
    openRecentMenu.remove(MAX_OPEN_RECENT_ITEMS-1);
  MenuItem item = new MenuItem(path);
  openRecentMenu.insert(item, 0);
  item.addActionListener(ij);
}

代码示例来源:origin: com.dorkbox/SystemTray

@Override
  public
  void run() {
    _native.deleteShortcut();
    _native.setEnabled(false);
    if (callback != null) {
      _native.removeItemListener(callback);
      callback = null;
    }
    parent._native.remove(_native);
    _native.removeNotify();
  }
});

代码示例来源:origin: com.dorkbox/SystemTray

@Override
  public
  void run() {
    _native.deleteShortcut();
    _native.setEnabled(false);
    if (callback != null) {
      _native.removeActionListener(callback);
      callback = null;
    }
    parent._native.remove(_native);
    _native.removeNotify();
  }
});

代码示例来源:origin: com.stevesoft.pat/pat

void SetGotoQuestionMenu() {
  Menu m = GotoQuestionMenu;
  while(GotoQuestionMenu.getItemCount() > 0)
    GotoQuestionMenu.remove(0);
  int i;
  MenuItem mui = null;
  for(i=0;QuizDataTable.get("pat"+i) != null;i++) {
    m.add(mui = new MenuItem((String)(
      QuizDataTable.get("pat"+i))));
    class MenuNum implements ActionListener {
      int num;
      MenuNum(int n) { num = n; }
      public void actionPerformed(ActionEvent ae) {
        UpdateCurrentQuestion();
        quizno=num;
        LoadQuestion();
        setnLabel();
      }
    }
    mui.addActionListener(new MenuNum(i));
    if(i % 10==9) {
      Menu nm = new Menu("More");
      m.add(nm);
      m = nm;
    }
  }
}
void LoadQuestion() {

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

/** Open the file and move the path to top of the submenu. */
public void run() {
  Opener o = new Opener();
  o.open(path);
  Menu menu = Menus.getOpenRecentMenu();
  int n = menu.getItemCount();
  int index = 0;
  for (int i=0; i<n; i++) {
    if (menu.getItem(i).getLabel().equals(path)) {
      index = i;
      break;
    }
  }
  if (index>0) {
    MenuItem item = menu.getItem(index);
    menu.remove(index);
    menu.insert(item, 0);
  }
}

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

public void updateRecentMenu(final String path) {
  final Menu menu = Menus.getOpenRecentMenu();
  if (menu == null) return;
  final int n = menu.getItemCount();
  int index = -1;
  for (int i = 0; i < n; i++) {
    if (menu.getItem(i).getLabel().equals(path)) {
      index = i;
      break;
    }
  }
  // Move to most recent
  if (index > 0) {
    final MenuItem item = menu.getItem(index);
    menu.remove(index);
    menu.insert(item, 0);
  }
  // not found, so replace oldest
  else if (index < 0) {
    final int count = menu.getItemCount();
    if (count >= Menus.MAX_OPEN_RECENT_ITEMS) {
      menu.remove(count - 1);
    }
    final MenuItem item = new MenuItem(path);
    final ImageJ instance = IJ.getInstance();
    if (instance != null) item.addActionListener(instance);
    menu.insert(item, 0);
  }
  // if index was 0, already at the head so do nothing
}

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

private void nullShortcut(final IJ1Helper ij1Helper, final String menuLabel,
    final String subMenuLabel, final String itemLabel)
  {
    final MenuBar menuBar = ij1Helper.getMenuBar();
    for (int m = 0; m < menuBar.getMenuCount(); m++) {
      final Menu menu = menuBar.getMenu(m);
      if (!menuLabel.equals(menu.getLabel())) continue;
      for (int s = 0; s < menu.getItemCount(); s++) {
        final MenuItem ms = menu.getItem(s);
        if (!(ms instanceof Menu)) continue;
        final Menu subMenu = (Menu) ms;
        if (!subMenuLabel.equals(subMenu.getLabel())) continue;
        for (int i = 0; i < subMenu.getItemCount(); i++) {
          final MenuItem mi = subMenu.getItem(i);
          if (!itemLabel.equals(mi.getLabel())) continue;
          subMenu.remove(i);
          mi.deleteShortcut();
          subMenu.insert(mi, i);
        }
      }
    }
  }
}

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

/** Open the file and move the path to top of the submenu. */
public void run() {
  Opener o = new Opener();
  o.open(path);
  Menu menu = Menus.getOpenRecentMenu();
  int n = menu.getItemCount();
  int index = 0;
  for (int i=0; i<n; i++) {
    if (menu.getItem(i).getLabel().equals(path)) {
      index = i;
      break;
    }
  }
  if (index>0) {
    MenuItem item = menu.getItem(index);
    menu.remove(index);
    menu.insert(item, 0);
  }
}

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

if (itemCount>baseCount) {
  for (int i=itemCount-1; i>=baseCount; i--)
    macrosMenu.remove(i);

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

if (itemCount>baseCount) {
  for (int i=itemCount-1; i>=baseCount; i--)
    macrosMenu.remove(i);

相关文章