當前位置: 首頁>>代碼示例>>Java>>正文


Java PopupMenu.show方法代碼示例

本文整理匯總了Java中java.awt.PopupMenu.show方法的典型用法代碼示例。如果您正苦於以下問題:Java PopupMenu.show方法的具體用法?Java PopupMenu.show怎麽用?Java PopupMenu.show使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.PopupMenu的用法示例。


在下文中一共展示了PopupMenu.show方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createTemplateMenuPopup

import java.awt.PopupMenu; //導入方法依賴的package包/類
/**
 * Pops up the menu for selecting template layouts
 */
private void createTemplateMenuPopup() {
  PopupMenu templatesMenu = new PopupMenu();
  //MenuItem addToUserTabItem = new MenuItem("Add to user tab");
  for (int i = 0; i < TEMPLATE_PATHS.size(); i++) {
    String mE = TEMPLATE_DESCRIPTIONS.get(i);
    final String path = TEMPLATE_PATHS.get(i);
    
    MenuItem m = new MenuItem(mE);
    m.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ee) {
        try {
          InputStream inR = this.getClass().getClassLoader()
          .getResourceAsStream(path);
          m_mainKFPerspective.addTab("Untitled" + m_untitledCount++);
          XMLBeans xml = new XMLBeans(m_beanLayout, m_bcSupport, 
              m_mainKFPerspective.getCurrentTabIndex());
          InputStreamReader isr = new InputStreamReader(inR);

          Vector v     = (Vector) xml.read(isr);
          Vector beans        = (Vector) v.get(XMLBeans.INDEX_BEANINSTANCES);
          Vector connections  = (Vector) v.get(XMLBeans.INDEX_BEANCONNECTIONS);
          isr.close();

          integrateFlow(beans, connections, false, false);
          notifyIsDirty();
          revalidate();
        } catch (Exception ex) {
          m_mainKFPerspective.getCurrentLogPanel().
            logMessage("Problem loading template: " + ex.getMessage());
        }
      }
    });            
    templatesMenu.add(m);            
  }
  
  m_templatesB.add(templatesMenu);
  templatesMenu.show(m_templatesB, 0, 0);
}
 
開發者ID:dsibournemouth,項目名稱:autoweka,代碼行數:42,代碼來源:KnowledgeFlowApp.java

示例2: mouseClicked

import java.awt.PopupMenu; //導入方法依賴的package包/類
public void mouseClicked(MouseEvent e) {
    if (SwingUtilities.isRightMouseButton(e) || e.isControlDown()) {
        //pop up context menu
        PopupMenu popup = ContextMenu.getContextMenuFor(BlockCanvas.this);
        this.add(popup);
        popup.show(this, e.getX(), e.getY());
    }
}
 
開發者ID:heqichen,項目名稱:openblocks,代碼行數:9,代碼來源:BlockCanvas.java

示例3: createTemplateMenuPopup

import java.awt.PopupMenu; //導入方法依賴的package包/類
/**
 * Pops up the menu for selecting template layouts
 */
private void createTemplateMenuPopup() {
  PopupMenu templatesMenu = new PopupMenu();
  // MenuItem addToUserTabItem = new MenuItem("Add to user tab");
  for (int i = 0; i < BeansProperties.TEMPLATE_PATHS.size(); i++) {
    String mE = BeansProperties.TEMPLATE_DESCRIPTIONS.get(i);
    final String path = BeansProperties.TEMPLATE_PATHS.get(i);

    MenuItem m = new MenuItem(mE);
    m.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent ee) {
        try {
          InputStream inR = this.getClass().getClassLoader()
            .getResourceAsStream(path);
          m_mainKFPerspective.addTab("Untitled" + m_untitledCount++);
          XMLBeans xml = new XMLBeans(m_beanLayout, m_bcSupport,
            m_mainKFPerspective.getCurrentTabIndex());
          InputStreamReader isr = new InputStreamReader(inR);

          @SuppressWarnings("unchecked")
          Vector<Vector<?>> v = (Vector<Vector<?>>) xml.read(isr);
          @SuppressWarnings("unchecked")
          Vector<Object> beans = (Vector<Object>) v
            .get(XMLBeans.INDEX_BEANINSTANCES);
          @SuppressWarnings("unchecked")
          Vector<BeanConnection> connections = (Vector<BeanConnection>) v
            .get(XMLBeans.INDEX_BEANCONNECTIONS);
          isr.close();

          integrateFlow(beans, connections, false, false);
          notifyIsDirty();
          revalidate();
        } catch (Exception ex) {
          m_mainKFPerspective.getCurrentLogPanel().logMessage(
            "Problem loading template: " + ex.getMessage());
        }
      }
    });
    templatesMenu.add(m);
  }

  m_templatesB.add(templatesMenu);
  templatesMenu.show(m_templatesB, 0, 0);
}
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:48,代碼來源:KnowledgeFlowApp.java

示例4: 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

示例5: mouseReleased

import java.awt.PopupMenu; //導入方法依賴的package包/類
public void mouseReleased(MouseEvent e) {
	if (SwingUtilities.isLeftMouseButton(e)) {
		if (!pickedUp) {
			throw new RuntimeException("dropping without prior dragging?");
		}
		dragHandler.mouseReleased(e);

		// if the block was dragged before...then
		if (dragging) {
			BlockLink link = getNearbyLink(); // look for nearby link
												// opportunities
			WorkspaceWidget widget = null;

			// if a suitable link wasn't found, just drop the block
			if (link == null) {
				widget = lastDragWidget;
				stopDragging(this, widget);
			} // otherwise, if a link WAS found...
			else {

				/*
				 * Make sure that no matter who's connecting to whom, the
				 * block that's being dragged gets dropped on the parent
				 * widget of the block that's already on the canvas.
				 */
				if (blockID.equals(link.getSocketBlockID())) {
					// dragged block is the socket block, so take plug's
					// parent.
					widget = workspace.getEnv()
							.getRenderableBlock(link.getPlugBlockID())
							.getParentWidget();
				} else {
					// dragged block is the plug block, so take the socket
					// block's parent.
					widget = workspace.getEnv()
							.getRenderableBlock(link.getSocketBlockID())
							.getParentWidget();
				}

				// drop the block and connect its link
				stopDragging(this, widget);
				link.connect();
				workspace.notifyListeners(new WorkspaceEvent(workspace,
						widget, link, WorkspaceEvent.BLOCKS_CONNECTED));
				workspace.getEnv()
						.getRenderableBlock(link.getSocketBlockID())
						.moveConnectedBlocks();
			}

			// set the locations for X and Y based on zoom at 1.0
			this.unzoomedX = this.calculateUnzoomedX(this.getX());
			this.unzoomedY = this.calculateUnzoomedY(this.getY());

			workspace.notifyListeners(new WorkspaceEvent(workspace, widget,
					link, WorkspaceEvent.BLOCK_MOVED, true));
			if (widget instanceof MiniMap) {
				workspace.getMiniMap().animateAutoCenter(this);
			}
		}
	}
	pickedUp = false;
	if (e.isPopupTrigger() || SwingUtilities.isRightMouseButton(e)
			|| e.isControlDown()) {
		// add context menu at right click location to provide functionality
		// for adding new comments and removing comments
		PopupMenu popup = ContextMenu.getContextMenuFor(this);
		add(popup);
		popup.show(this, e.getX(), e.getY());
	}
	workspace.getMiniMap().repaint();
}
 
開發者ID:heqichen,項目名稱:openblocks,代碼行數:72,代碼來源:RenderableBlock.java

示例6: 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.show方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。