本文整理汇总了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);
}
示例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());
}
}
示例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);
}
示例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);
}
}
示例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();
}
示例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);
}
}