当前位置: 首页>>代码示例>>Java>>正文


Java PopupMenu.insert方法代码示例

本文整理汇总了Java中java.awt.PopupMenu.insert方法的典型用法代码示例。如果您正苦于以下问题:Java PopupMenu.insert方法的具体用法?Java PopupMenu.insert怎么用?Java PopupMenu.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.PopupMenu的用法示例。


在下文中一共展示了PopupMenu.insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteConnectionPopup

import java.awt.PopupMenu; //导入方法依赖的package包/类
/**
 * Popup a menu giving choices for connections to delete (if any)
 *
 * @param closestConnections a vector containing 0 or more BeanConnections
 * @param x the x coordinate at which to popup the menu
 * @param y the y coordinate at which to popup the menu
 *
 * Modified by Zerbetto: javax.swing.JPopupMenu transformed into java.awt.PopupMenu
 */
private void deleteConnectionPopup(Vector closestConnections, int x, int y) {
  if (closestConnections.size() > 0) {
    int menuItemCount = 0;

    // modifications by Zerbetto
    //JPopupMenu deleteConnectionMenu = new JPopupMenu();
    PopupMenu deleteConnectionMenu = new PopupMenu();

    //      deleteConnectionMenu.insert(new JLabel("Delete Connection", 
    //					     SwingConstants.CENTER), 
    //				  menuItemCount);
    MenuItem deleteConnection = new MenuItem("Delete Connection:");
    deleteConnection.setEnabled(false);
    deleteConnectionMenu.insert(deleteConnection, menuItemCount);
    menuItemCount++;

    for (int i = 0; i < closestConnections.size(); i++) {
      final BeanConnection bc = (BeanConnection) closestConnections.elementAt(i);
      String connName = bc.getSourceEventSetDescriptor().getName();

      //JMenuItem deleteItem = new JMenuItem(connName);
      String targetName = "";
      if (bc.getTarget().getBean() instanceof BeanCommon) {
        targetName = ((BeanCommon)bc.getTarget().getBean()).getCustomName();
      } else {
        targetName = bc.getTarget().getBean().getClass().getName();
        targetName = targetName.substring(targetName.lastIndexOf('.')+1, targetName.length());
      }
      MenuItem deleteItem = new MenuItem(connName + "-->" + targetName);
      deleteItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          bc.remove(m_mainKFPerspective.getCurrentTabIndex());
          m_beanLayout.revalidate();
          m_beanLayout.repaint();
          m_mainKFPerspective.setEditedStatus(true);
          notifyIsDirty();
        }
      });
      deleteConnectionMenu.add(deleteItem);
      menuItemCount++;
    }

    //deleteConnectionMenu.show(m_beanLayout, x, y);
    m_beanLayout.add(deleteConnectionMenu);
    deleteConnectionMenu.show(m_beanLayout, x, y);
  }
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:57,代码来源:KnowledgeFlowApp.java

示例2: deleteConnectionPopup

import java.awt.PopupMenu; //导入方法依赖的package包/类
/**
 * Popup a menu giving choices for connections to delete (if any)
 * 
 * @param closestConnections a vector containing 0 or more BeanConnections
 * @param x the x coordinate at which to popup the menu
 * @param y the y coordinate at which to popup the menu
 * 
 *          Modified by Zerbetto: javax.swing.JPopupMenu transformed into
 *          java.awt.PopupMenu
 */
private void deleteConnectionPopup(Vector closestConnections, int x, int y) {
  if (closestConnections.size() > 0) {
    int menuItemCount = 0;

    // modifications by Zerbetto
    // JPopupMenu deleteConnectionMenu = new JPopupMenu();
    PopupMenu deleteConnectionMenu = new PopupMenu();

    // deleteConnectionMenu.insert(new JLabel("Delete Connection",
    // SwingConstants.CENTER),
    // menuItemCount);
    MenuItem deleteConnection = new MenuItem(
        Messages
            .getInstance()
            .getString(
                "KnowledgeFlowApp_DeleteConnectionPopup_DeleteConnection_MenuItem_Text"));
    deleteConnection.setEnabled(false);
    deleteConnectionMenu.insert(deleteConnection, menuItemCount);
    menuItemCount++;

    for (int i = 0; i < closestConnections.size(); i++) {
      final BeanConnection bc = (BeanConnection) closestConnections
          .elementAt(i);
      String connName = bc.getSourceEventSetDescriptor().getName();

      // JMenuItem deleteItem = new JMenuItem(connName);
      String targetName = "";
      if (bc.getTarget().getBean() instanceof BeanCommon) {
        targetName = ((BeanCommon) bc.getTarget().getBean()).getCustomName();
      } else {
        targetName = bc.getTarget().getBean().getClass().getName();
        targetName = targetName.substring(targetName.lastIndexOf('.') + 1,
            targetName.length());
      }
      MenuItem deleteItem = new MenuItem(connName + "-->" + targetName);
      deleteItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          bc.remove();
          m_beanLayout.revalidate();
          m_beanLayout.repaint();
          notifyIsDirty();
        }
      });
      deleteConnectionMenu.add(deleteItem);
      menuItemCount++;
    }

    // deleteConnectionMenu.show(m_beanLayout, x, y);
    m_beanLayout.add(deleteConnectionMenu);
    deleteConnectionMenu.show(m_beanLayout, x, y);
  }
}
 
开发者ID:williamClanton,项目名称:jbossBA,代码行数:63,代码来源:KnowledgeFlowApp.java


注:本文中的java.awt.PopupMenu.insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。