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

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

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

JPopupMenu.getComponentIndex介绍

暂无

代码示例

代码示例来源:origin: MegaMek/megamek

/**
 * Scrolls the specified item into view each time the menu is opened.  Call this method with
 * <code>null</code> to restore the default behavior, which is to show the menu as it last
 * appeared.
 *
 * @param item the item to keep visible
 * @see #keepVisible(int)
 */
public void keepVisible(JMenuItem item) {
 if (item == null) {
  keepVisibleIndex = -1;
 } else {
  int index = menu.getComponentIndex(item);
  keepVisibleIndex = index;
 }
}

代码示例来源:origin: GoldenGnu/jeveassets

/**
 * Scrolls the specified item into view each time the menu is opened. Call
 * this method with
 * <code>null</code> to restore the default behavior, which is to show the
 * menu as it last appeared.
 *
 * @param item the item to keep visible
 * @see #keepVisible(int)
 */
public void keepVisible(final JMenuItem item) {
  if (item == null) {
    keepVisibleIndex = -1;
  } else {
    int index = menu.getComponentIndex(item);
    keepVisibleIndex = index;
  }
}

代码示例来源:origin: org.apache.jmeter/jorphan

/**
 * Scrolls the specified item into view each time the menu is opened. Call
 * this method with <code>null</code> to restore the default behavior, which
 * is to show the menu as it last appeared.
 * 
 * @param item
 *            the item to keep visible
 * @see #keepVisible(int)
 */
public void keepVisible(JMenuItem item) {
  if (item == null) {
    keepVisibleIndex = -1;
  } else {
    int index = menu.getComponentIndex(item);
    keepVisibleIndex = index;
  }
}

代码示例来源: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: org.cytoscape/swing-util-api

@Override
public void removeComponent(final Component component) {
  if (componentGravity.remove(component) != null)
    menu.remove(menu.getComponentIndex(component));
}

相关文章

JPopupMenu类方法