本文整理汇总了Java中javax.swing.JPopupMenu.show方法的典型用法代码示例。如果您正苦于以下问题:Java JPopupMenu.show方法的具体用法?Java JPopupMenu.show怎么用?Java JPopupMenu.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JPopupMenu
的用法示例。
在下文中一共展示了JPopupMenu.show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mousePressed
import javax.swing.JPopupMenu; //导入方法依赖的package包/类
public void mousePressed(MouseEvent event) {
if (event.isMetaDown()) {
final JPopupMenu popup = new JPopupMenu();
final JMenuItem item = new JMenuItem("Return to default page");
item.addActionListener(new ActionListener() {
// Return to default page
public void actionPerformed(ActionEvent e) {
setFile(fileName);
}
});
popup.add(item);
if (event.getComponent().isShowing()) {
popup.show(event.getComponent(), event.getX(), event.getY());
}
}
}
示例2: maybeShowPopup
import javax.swing.JPopupMenu; //导入方法依赖的package包/类
private void maybeShowPopup(MouseEvent e) {
if (e.isPopupTrigger()) {
JPopupMenu popupMenu = new JPopupMenu();
popupMenu.setFocusable(false);
popupMenu.add(jMenuItemUndo);
popupMenu.add(jMenuItemRedo);
popupMenu.addSeparator();
popupMenu.add(jMenuItemCut);
popupMenu.add(jMenuItemCopy);
popupMenu.add(jMenuItemPaste);
popupMenu.addSeparator();
if (jMenuItemInsCell.getAction().isEnabled()) {
popupMenu.add(jMenuItemInsCell);
jMenuItemInsCell.setEnabled(true);
popupMenu.add(jMenuItemInsRow);
jMenuItemInsRow.setEnabled(true);
popupMenu.addSeparator();
}
popupMenu.add(jMenuItemProp);
popupMenu.show(e.getComponent(), e.getX(), e.getY());
}
}
示例3: handleClick
import javax.swing.JPopupMenu; //导入方法依赖的package包/类
private void handleClick(MouseEvent e) {
if (e.isPopupTrigger()) {
Point p = e.getPoint();
TreePath path = errorTree.getPathForLocation(e.getPoint().x, e.getPoint().y);
if (path != null) {
DefaultMutableTreeNode o = (DefaultMutableTreeNode) path.getLastPathComponent();
if (o.getUserObject() instanceof HintMetadata) {
HintMetadata hint = (HintMetadata) o.getUserObject();
if (hint.category.equals(Utilities.CUSTOM_CATEGORY)) {
JPopupMenu popup = new JPopupMenu();
popup.add(new JMenuItem(new RenameHint(o, hint, path)));
popup.add(new JMenuItem(new RemoveHint(o, hint)));
popup.show(errorTree, e.getX(), e.getY());
}
}
}
}
}
示例4: actionPerformed
import javax.swing.JPopupMenu; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
JPopupMenu menu = new JPopupMenu();
for (MergeServer server : Database.d.getMergeServers())
{
if ((server.isLocalHost()) || (!server.isActive() && !server.isRemote()))
continue;
try {
menu.add(new JMenuItem((Action)template.getConstructor(MergeServer.class).newInstance(server)));
} catch (Exception ex) {
log.log(Level.WARNING, "can't build action: " + ex, ex);
}
}
Component c = (Component)e.getSource();
menu.show(c, 5, c.getHeight()-5);
}
示例5: mousePressed
import javax.swing.JPopupMenu; //导入方法依赖的package包/类
public void mousePressed(MouseEvent ev) {
if (ev.isPopupTrigger()) {
int x = ev.getX();
int y = ev.getY();
TreePath path = view.getClosestPathForLocation(x, y);
if (path != null) {
LookTreeNode n = (LookTreeNode)path.getLastPathComponent();
clicked = new WeakReference<LookTreeNode>(n);
@SuppressWarnings("unchecked")
Action[] actions = n.getLook().getActions(n.getData(), n.getLookup() );
// XXX handle multiselects...
Node selection = makeNode( n );
Lookup context = Lookups.fixed(new Object[] {selection, actionMap});
JPopupMenu menu = Utilities.actionsToPopup(actions, context);
menu.show(view, x, y);
// XXX selection does not appear to be collected... do we need to
// also destroy the popup menu?
}
}
}
示例6: maybePopup
import javax.swing.JPopupMenu; //导入方法依赖的package包/类
private void maybePopup( MouseEvent e ) {
if( e.isPopupTrigger() ) {
e.consume();
int row = rowAtPoint( e.getPoint() );
if( row >= 0 )
getSelectionModel().setSelectionInterval( row, row );
JPopupMenu popup = Util.createPopup( this );
popup.show( this, e.getX(), e.getY() );
}
}
示例7: showPopupMenu
import javax.swing.JPopupMenu; //导入方法依赖的package包/类
/** Shows given popup on given coordinations and takes care about the
* situation when menu can exceed screen limits.
* Copied from org.netbeans.core.windows.frames.DefaultContainerImpl
*/
private static void showPopupMenu(JPopupMenu popup, Point p, Component comp) {
SwingUtilities.convertPointToScreen(p, comp);
Dimension popupSize = popup.getPreferredSize();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
if (p.x + popupSize.width > screenSize.width) {
p.x = screenSize.width - popupSize.width;
}
if (p.y + popupSize.height > screenSize.height) {
p.y = screenSize.height - popupSize.height;
}
SwingUtilities.convertPointFromScreen(p, comp);
popup.show(comp, p.x, p.y);
}
示例8: showPopup
import javax.swing.JPopupMenu; //导入方法依赖的package包/类
private void showPopup (Point e, Component invoker) {
int row = UnitTab.this.table.rowAtPoint (e);
if (row >= 0) {
table.getSelectionModel ().setSelectionInterval (row, row);
final JPopupMenu finalPopup = popupActionsSupport.createPopup ();
if (finalPopup != null && finalPopup.getComponentCount () > 0) {
finalPopup.show (invoker,e.x, e.y);
}
}
}
示例9: showPopup
import javax.swing.JPopupMenu; //导入方法依赖的package包/类
/**
* Shows a popup menu with cut, copy, paste, etc. options if the
* user clicked the right button.
*
* @param e The mouse event that caused this method to be called.
*/
private void showPopup(MouseEvent e) {
JPopupMenu popupMenu = getPopupMenu();
if (popupMenu!=null) {
configurePopupMenu(popupMenu);
popupMenu.show(e.getComponent(), e.getX(), e.getY());
e.consume();
}
}
示例10: showMenu
import javax.swing.JPopupMenu; //导入方法依赖的package包/类
private void showMenu(MouseEvent e) {
JPopupMenu popup = new JPopupMenu();
popup.add(new ProgressListAction(NbBundle.getMessage(StatusLineComponent.class, "StatusLineComponent.ShowProcessList")));
popup.add(new ViewAction());
popup.add(new CancelAction(true));
popup.show((Component)e.getSource(), e.getX(), e.getY());
}
示例11: evaluatePopup
import javax.swing.JPopupMenu; //导入方法依赖的package包/类
/**
* Checks if the given mouse event is a popup trigger and creates a new popup menu if necessary.
*/
private void evaluatePopup(MouseEvent e) {
if (e.isPopupTrigger()) {
JPopupMenu menu = createBookmarkPopupMenu();
if (menu != null) {
menu.show(this, e.getX(), e.getY());
}
}
}
示例12: actionPerformed
import javax.swing.JPopupMenu; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e)
{
saveCurrent();
final JPopupMenu menu = new JPopupMenu();
final PopupPanel popupPanel = new PopupPanel(menu);
menu.add(popupPanel);
menu.show(I18nTextField.this, 5, 5);
}
示例13: checkForPopup
import javax.swing.JPopupMenu; //导入方法依赖的package包/类
private void checkForPopup(MouseEvent e) {
if (e.isPopupTrigger()) {
TreePath path = getPathForLocation(e.getX(), e.getY());
if (path != null && listener != null) {
JPopupMenu menu = listener.menuRequested(new Event(path));
if (menu != null) {
menu.show(ProjectExplorer.this, e.getX(), e.getY());
}
}
}
}
示例14: mousePressed
import javax.swing.JPopupMenu; //导入方法依赖的package包/类
@Override
public void mousePressed(MouseEvent e) {
if (e.isConsumed() || (!e.isPopupTrigger()))
return;
int row = table.rowAtPoint(e.getPoint());
int column = table.columnAtPoint(e.getPoint());
table.changeSelection(row, column, false, false);
AddressBookEntry entry = entries.get(row);
JPopupMenu menu = new JPopupMenu();
JMenuItem sendCash = new JMenuItem("Send KMD to "+entry.name);
sendCash.addActionListener(new SendCashActionListener());
menu.add(sendCash);
JMenuItem copyAddress = new JMenuItem("Copy address to clipboard");
copyAddress.addActionListener(new CopyToClipboardActionListener());
menu.add(copyAddress);
JMenuItem deleteEntry = new JMenuItem("Delete "+entry.name+" from contacts");
deleteEntry.addActionListener(new DeleteAddressActionListener());
menu.add(deleteEntry);
menu.show(e.getComponent(), e.getPoint().x, e.getPoint().y);
e.consume();
}
示例15: showPopup
import javax.swing.JPopupMenu; //导入方法依赖的package包/类
/**
* Called when the sequence of mouse events should lead to actual showing popup menu
*/
protected void showPopup (MouseEvent e) {
Configuration conf = toolbarConfigs.get (name);
if (conf != null) {
JPopupMenu pop = conf.getContextMenu();
pop.show (e.getComponent (), e.getX (), e.getY ());
}
}