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

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

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

JPopupMenu.getName介绍

暂无

代码示例

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@Override
  public String toString() {
    return String.format("%s [%s] count:%d", super.getName() != null ? super.getName() : "", getClass().getSimpleName(), getCount());
  }
}

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@ScriptFunction(jsDoc = JS_NAME_DOC)
@Override
public String getName() {
  return super.getName();
}

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

@Override
public void actionPerformed(ActionEvent e) {
  JMenuItem source = (JMenuItem)(e.getSource());
  try{
    JMenuItem menuItem = (JMenuItem) e.getSource(); 
    JPopupMenu popupMenu = (JPopupMenu) menuItem.getParent(); 
    Component invoker = popupMenu.getInvoker();  
    // Print name of JMenu
    System.out.println("NAME OF JMENU: "+invoker.getName());    
    JPopupMenu popup = (JPopupMenu) invoker.getParent();
    // Print name of JPopupMenu
    System.out.println("NAME OF POPMENU: "+popup.getName());
  }catch(Exception ex){
    ex.printStackTrace();
  }
}

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

@Override
public void actionPerformed(ActionEvent e) {
  JMenuItem source = (JMenuItem)(e.getSource());
  try{
    JMenuItem menuItem = (JMenuItem) e.getSource(); 
    JPopupMenu popupMenu = (JPopupMenu) menuItem.getParent(); 
    Component invoker = popupMenu.getInvoker();      
    JPopupMenu popup = (JPopupMenu) invoker.getParent();
    System.out.println("NAME OF JMENU: "+popup.getName());

    //If you need the selection of cell(s)
    JTable table = (JTable)popup.getInvoker();
    int row = table.getSelectedRow();
    int col = table.getSelectedColumn();
    System.out.println("Selected cell: "+row+"-"+col);
  }catch(Exception ex){
    ex.printStackTrace();
  }
}

相关文章

JPopupMenu类方法