List of usage examples for java.awt.event MouseEvent isPopupTrigger
public boolean isPopupTrigger()
From source file:net.sf.jabref.groups.GroupSelector.java
private void definePopup() { // These key bindings are just to have the shortcuts displayed // in the popup menu. The actual keystroke processing is in // BasePanel (entryTable.addKeyListener(...)). groupsContextMenu.add(editGroupPopupAction); groupsContextMenu.add(addGroupPopupAction); groupsContextMenu.add(addSubgroupPopupAction); groupsContextMenu.addSeparator();/*from w w w . j a v a 2 s .c om*/ groupsContextMenu.add(removeGroupAndSubgroupsPopupAction); groupsContextMenu.add(removeGroupKeepSubgroupsPopupAction); groupsContextMenu.add(removeSubgroupsPopupAction); groupsContextMenu.addSeparator(); groupsContextMenu.add(expandSubtreePopupAction); groupsContextMenu.add(collapseSubtreePopupAction); groupsContextMenu.addSeparator(); groupsContextMenu.add(moveSubmenu); sortSubmenu.add(sortDirectSubgroupsPopupAction); sortSubmenu.add(sortAllSubgroupsPopupAction); groupsContextMenu.add(sortSubmenu); moveSubmenu.add(moveNodeUpPopupAction); moveSubmenu.add(moveNodeDownPopupAction); moveSubmenu.add(moveNodeLeftPopupAction); moveSubmenu.add(moveNodeRightPopupAction); groupsContextMenu.addSeparator(); groupsContextMenu.add(addToGroup); groupsContextMenu.add(moveToGroup); groupsContextMenu.add(removeFromGroup); groupsTree.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { showPopup(e); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { showPopup(e); } } @Override public void mouseClicked(MouseEvent e) { TreePath path = groupsTree.getPathForLocation(e.getPoint().x, e.getPoint().y); if (path == null) { return; } GroupTreeNode node = (GroupTreeNode) path.getLastPathComponent(); // the root node is "AllEntries" and cannot be edited if (node.isRoot()) { return; } if ((e.getClickCount() == 2) && (e.getButton() == MouseEvent.BUTTON1)) { // edit editGroupAction.actionPerformed(null); // dummy event } else if ((e.getClickCount() == 1) && (e.getButton() == MouseEvent.BUTTON1)) { annotationEvent(node); } } }); // be sure to remove a possible border highlight when the popup menu // disappears groupsContextMenu.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { // nothing to do } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { groupsTree.setHighlightBorderCell(null); } @Override public void popupMenuCanceled(PopupMenuEvent e) { groupsTree.setHighlightBorderCell(null); } }); }
From source file:GlassPaneDemo.java
private void redispatchMouseEvent(MouseEvent e, boolean repaint) { Point glassPanePoint = e.getPoint(); Container container = contentPane; Point containerPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, contentPane); if (containerPoint.y < 0) { // we're not in the content pane if (containerPoint.y + menuBar.getHeight() >= 0) { // The mouse event is over the menu bar. // Could handle specially. } else {/*from ww w . ja v a 2s .c o m*/ // The mouse event is over non-system window // decorations, such as the ones provided by // the Java look and feel. // Could handle specially. } } else { // The mouse event is probably over the content pane. // Find out exactly which component it's over. Component component = SwingUtilities.getDeepestComponentAt(container, containerPoint.x, containerPoint.y); if ((component != null) && (component.equals(liveButton))) { // Forward events over the check box. Point componentPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, component); component.dispatchEvent(new MouseEvent(component, e.getID(), e.getWhen(), e.getModifiers(), componentPoint.x, componentPoint.y, e.getClickCount(), e.isPopupTrigger())); } } // Update the glass pane if requested. if (repaint) { glassPane.setPoint(glassPanePoint); glassPane.repaint(); } }
From source file:SwingGlassExample.java
private void redispatchMouseEvent(MouseEvent e) { boolean inButton = false; boolean inMenuBar = false; Point glassPanePoint = e.getPoint(); Component component = null;//from ww w .jav a 2s.co m Container container = contentPane; Point containerPoint = SwingUtilities.convertPoint(this, glassPanePoint, contentPane); int eventID = e.getID(); if (containerPoint.y < 0) { inMenuBar = true; container = menuBar; containerPoint = SwingUtilities.convertPoint(this, glassPanePoint, menuBar); testForDrag(eventID); } //XXX: If the event is from a component in a popped-up menu, //XXX: then the container should probably be the menu's //XXX: JPopupMenu, and containerPoint should be adjusted //XXX: accordingly. component = SwingUtilities.getDeepestComponentAt(container, containerPoint.x, containerPoint.y); if (component == null) { return; } else { inButton = true; testForDrag(eventID); } if (inMenuBar || inButton || inDrag) { Point componentPoint = SwingUtilities.convertPoint(this, glassPanePoint, component); component.dispatchEvent(new MouseEvent(component, eventID, e.getWhen(), e.getModifiers(), componentPoint.x, componentPoint.y, e.getClickCount(), e.isPopupTrigger())); } }
From source file:edu.ku.brc.specify.ui.containers.ContainerTreePanel.java
/** * @param actionTree// w w w. j a v a 2 s . c o m */ private void registerPrintContextMenu(final JTree actionTree) { actionTree.addMouseListener(new MouseAdapter() { private void displayMenu(MouseEvent e) { if (e.isPopupTrigger()) { JPopupMenu menu = new JPopupMenu(); JMenuItem printMenu = new JMenuItem(UIRegistry.getResourceString("Print")); menu.add(printMenu); menu.show(e.getComponent(), e.getX(), e.getY()); printMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { print(actionTree); } }); } } @Override public void mouseClicked(MouseEvent e) { super.mouseClicked(e); displayMenu(e); } @Override public void mousePressed(MouseEvent e) { super.mousePressed(e); displayMenu(e); } @Override public void mouseReleased(MouseEvent e) { super.mouseReleased(e); displayMenu(e); } }); }
From source file:edu.ku.brc.specify.tasks.SystemSetupTask.java
/** * Adds the Context PopupMenu for the RecordSet. * @param roc the RolloverCommand btn to add the pop to *//*from w ww . j av a 2 s. c o m*/ public void addPopMenu(final RolloverCommand roc, final PickList pickList) { if (roc.getLabelText() != null) { final JPopupMenu popupMenu = new JPopupMenu(); JMenuItem delMenuItem = new JMenuItem(getResourceString("Delete")); if (!pickList.getIsSystem()) { delMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { CommandDispatcher.dispatch(new CommandAction(SYSTEMSETUPTASK, DELETE_CMD_ACT, roc)); } }); } else { delMenuItem.setEnabled(false); } popupMenu.add(delMenuItem); JMenuItem viewMenuItem = new JMenuItem(getResourceString("EDIT")); viewMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { startEditor(edu.ku.brc.specify.datamodel.PickList.class, "name", roc.getName(), roc.getName(), PICKLIST); } }); popupMenu.add(viewMenuItem); MouseListener mouseListener = new MouseAdapter() { private boolean showIfPopupTrigger(MouseEvent mouseEvent) { if (roc.isEnabled() && mouseEvent.isPopupTrigger() && popupMenu.getComponentCount() > 0) { popupMenu.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY()); return true; } return false; } @Override public void mousePressed(MouseEvent mouseEvent) { if (roc.isEnabled()) { showIfPopupTrigger(mouseEvent); } } @Override public void mouseReleased(MouseEvent mouseEvent) { if (roc.isEnabled()) { showIfPopupTrigger(mouseEvent); } } }; roc.addMouseListener(mouseListener); } }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java
@Override public void mouseReleased(final MouseEvent e) { if (this.application == null) { if ((e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) == 0 && e.isPopupTrigger()) { final HexPosition hexNumber = this.hexMapPanel.getHexPosition(e.getPoint()); onPopup(e.getPoint(), hexNumber); } else {//from w w w . j av a 2 s . co m switch (e.getButton()) { case MouseEvent.BUTTON3: { this.dragging = false; this.hexMapPanelDesktop.endDrag(); } break; } } } else if (e.getButton() == MouseEvent.BUTTON3) { this.dragging = false; this.hexMapPanelDesktop.endDrag(); } }
From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java
/** * Handles a 'mouse pressed' event.// ww w . ja v a 2s. co m * <P> * This event is the popup trigger on Unix/Linux. For Windows, the popup * trigger is the 'mouse released' event. * * @param e The mouse event. */ public void mousePressed(MouseEvent e) { if (zoomRectangle == null) { this.zoomPoint = RefineryUtilities.getPointInRectangle(e.getX(), e.getY(), getScaledDataArea()); // check for popup trigger... if (e.isPopupTrigger()) { if (popup != null) { displayPopupMenu(e.getX(), e.getY()); } } } }
From source file:userinterface.properties.GUIGraphHandler.java
public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { popUpTriggered(e); } }
From source file:userinterface.properties.GUIGraphHandler.java
public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { popUpTriggered(e); } }
From source file:com.archivas.clienttools.arcmover.gui.panels.ProfilePanel.java
private void onFileListMouseClicked(MouseEvent evt) { try {/*from ww w. ja v a 2s . c om*/ if (evt.isPopupTrigger()) { updateSelectedFile(); updateRightClickMenu(); rightClickMenu.show(fileList, evt.getX(), evt.getY()); } } catch (Exception e1) { String msg = "Unexpected error showing right-click menu"; LOG.log(Level.WARNING, msg, e1); JOptionPane.showMessageDialog(this, msg, "Error", JOptionPane.ERROR_MESSAGE); } }