java.awt.event.MouseEvent#isPopupTrigger()源码实例Demo

下面列出了java.awt.event.MouseEvent#isPopupTrigger() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: pcgen   文件: JTreeTable.java
/**
 * Overridden to return false, and if the event is a mouse event
 * it is forwarded to the tree.<p>
 * The behavior for this is debatable, and should really be offered
 * as a property. By returning false, all keyboard actions are
 * implemented in terms of the table. By returning true, the
 * tree would get a chance to do something with the keyboard
 * events. For the most part this is ok. But for certain keys,
 * such as left/right, the tree will expand/collapse where as
 * the table focus should really move to a different column. Page
 * up/down should also be implemented in terms of the table.
 * By returning false this also has the added benefit that clicking
 * outside of the bounds of the tree node, but still in the tree
 * column will select the row, whereas if this returned true
 * that wouldn't be the case.
 * <p>By returning false we are also enforcing the policy that
 * the tree will never be editable (at least by a key sequence).
 * @param e
 * @return true if cell editable
 */
@Override
public boolean isCellEditable(EventObject e)
{
	if (e instanceof MouseEvent)
	{
		for (int counter = getColumnCount() - 1; counter >= 0; counter--)
		{
			if (getColumnClass(counter) == TreeTableNode.class)
			{
				MouseEvent me = (MouseEvent) e;
				int column = JTreeTable.this.columnAtPoint(me.getPoint());
				Rectangle cell = JTreeTable.this.getCellRect(0, column, true);
				MouseEvent newME = new MouseEvent(tree, me.getID(), me.getWhen(), me.getModifiers(), me.getX(),
					me.getY(), me.getClickCount(), me.isPopupTrigger());
				//we translate the event into the tree's coordinate system
				newME.translatePoint(-cell.x, 0);
				tree.dispatchEvent(newME);

				break;
			}
		}
	}

	return false;
}
 
源代码2 项目: libreveris   文件: JTreeTable.java
/**
 * Overridden to return false, and if the event is a mouse event it is
 * forwarded to the tree.
 * <p/>
 * <
 * p/>
 * The behavior for this is debatable, and should really be offered as
 * a property. By returning false, all keyboard actions are
 * implemented in terms of the table. By returning true, the tree
 * would get a chance to do something with the keyboard events. For
 * the most part this is ok. But for certain keys, such as left/right,
 * the tree will expand/collapse where as the table focus should
 * really move to a different column. Page up/down should also be
 * implemented in terms of the table. By returning false this also has
 * the added benefit that clicking outside of the bounds of the tree
 * node, but still in the tree column will select the row, whereas if
 * this returned true that wouldn't be the case. </p>
 * <p/>
 * <
 * p/>
 * By returning false we are also enforcing the policy that the tree
 * will never be editable (at least by a key sequence). </p>
 */
@Override
public boolean isCellEditable (EventObject e)
{
    if (e instanceof MouseEvent) {
        for (int counter = getColumnCount() - 1; counter >= 0;
                counter--) {
            if (getColumnClass(counter) == TreeTableModel.class) {
                MouseEvent me = (MouseEvent) e;
                MouseEvent newME = new MouseEvent(
                        tree,
                        me.getID(),
                        me.getWhen(),
                        me.getModifiers(),
                        me.getX() - getCellRect(0, counter, true).x,
                        me.getY(),
                        me.getClickCount(),
                        me.isPopupTrigger());
                tree.dispatchEvent(newME);

                break;
            }
        }
    }

    return false;
}
 
源代码3 项目: visualvm   文件: ProfilerTabbedPane.java
protected void processMouseEvent(MouseEvent e) {
    int index = indexAtLocation(e.getX(), e.getY());
    
    if (index != -1) {
        if (e.isPopupTrigger()) {
            // Show popup menu for the clicked tab
            final MouseEvent _e = e;
            final int _index = index;
            final Component _component = getComponentAt(index);
            
            SwingUtilities.invokeLater(new Runnable() {
                public void run() { showPopupMenu(_index, _component, _e); };
            });
            
            e.consume();
            return;
        } else if (e.getID() == MouseEvent.MOUSE_CLICKED && SwingUtilities.isMiddleMouseButton(e)) {
            // Close tab using middle button click
            if (isClosableAt(index)) closeTab(getComponentAt(index));
            
            e.consume();
            return;
        } else if (e.getID() == MouseEvent.MOUSE_PRESSED && !SwingUtilities.isLeftMouseButton(e)) {
            // Do not switch tabs using middle or right mouse button
            e.consume();
            return;
        }
    }
    
    super.processMouseEvent(e);
}
 
源代码4 项目: binnavi   文件: JCriteriumTree.java
@Override
public void mousePressed(final MouseEvent event) {
  m_currentCriteriumPath = getPathForLocation(event.getX(), event.getY());

  if (event.isPopupTrigger()) {
    showPopupMenu(event);
  }
}
 
源代码5 项目: SikuliX1   文件: EditorPatternLabel.java
private void checkPopup(MouseEvent me) {
  if (me.isPopupTrigger()) {
    wasPopup = true;
    popMenu = pane.getPopMenuImage();
    if (popMenu != null) {
      if (imgpop != null && imgpop.isShowing()) {
        showPopup(false);
      }
      popMenu.show(this, me.getX(), me.getY());
    }
    return;
  }
}
 
@Override
public void mouseReleased(MouseEvent e) {

    if (e.isPopupTrigger()) {
        createAndShowContextMenu(e);
    } else if (e.getClickCount() == 2) {
        // TODO: 2016-02-07 14:53:35EST copy to gold, if the row is not GS
    }
}
 
源代码7 项目: blog-codes   文件: mxGraphHandler.java
/**
 * 
 */
public void mousePressed(MouseEvent e)
{
	if (graphComponent.isEnabled() && isEnabled() && !e.isConsumed()
			&& !graphComponent.isForceMarqueeEvent(e))
	{
		cell = graphComponent.getCellAt(e.getX(), e.getY(), false);
		initialCell = cell;

		if (cell != null)
		{
			if (isSelectEnabled()
					&& !graphComponent.getGraph().isCellSelected(cell))
			{
				graphComponent.selectCellForEvent(cell, e);
				cell = null;
			}

			// Starts move if the cell under the mouse is movable and/or any
			// cells of the selection are movable
			if (isMoveEnabled() && !e.isPopupTrigger())
			{
				start(e);
				e.consume();
			}
		}
		else if (e.isPopupTrigger())
		{
			graphComponent.getGraph().clearSelection();
		}
	}
}
 
源代码8 项目: nmonvisualizer   文件: BaseChartPanel.java
@Override
public void mouseReleased(MouseEvent event) {
    if (event.isPopupTrigger()) {
        clickLocation = new Point(event.getX(), event.getY());
    }

    super.mouseReleased(event);
}
 
源代码9 项目: snap-desktop   文件: PopupMenuHandler.java
private void maybeShowPopupMenu(MouseEvent event) {
    if (event.isPopupTrigger()) {
        if (event.getComponent().isVisible()) {
            showPopupMenu(event);
        }
    }
}
 
源代码10 项目: netbeans   文件: InstancesListControllerUI.java
public void mouseReleased(MouseEvent e) {
    int row = instancesListTable.rowAtPoint(e.getPoint());
    updateSelection(row);
    if (row != -1 && e.isPopupTrigger())
        showTablePopup(e.getComponent(), e.getX(), e.getY());
}
 
源代码11 项目: mae-annotation   文件: TextPanelMouseListener.java
@Override
public void mouseReleased(MouseEvent e) {
    if (e.isPopupTrigger()) {
        createAndShowContextMenu(e);
    }
}
 
源代码12 项目: megan-ce   文件: ServicePanel.java
public void mousePressed(MouseEvent e) {
    if (e.isPopupTrigger()) {
        showPopupMenu(e);
    }
}
 
源代码13 项目: openstock   文件: ChartPanel.java
/**
 * Handles a 'mouse released' event.  On Windows, we need to check if this
 * is a popup trigger, but only if we haven't already been tracking a zoom
 * rectangle.
 *
 * @param e  information about the event.
 */
@Override
public void mouseReleased(MouseEvent e) {

    // if we've been panning, we need to reset now that the mouse is 
    // released...
    if (this.panLast != null) {
        this.panLast = null;
        setCursor(Cursor.getDefaultCursor());
    }

    else if (this.zoomRectangle != null) {
        boolean hZoom, vZoom;
        if (this.orientation == PlotOrientation.HORIZONTAL) {
            hZoom = this.rangeZoomable;
            vZoom = this.domainZoomable;
        }
        else {
            hZoom = this.domainZoomable;
            vZoom = this.rangeZoomable;
        }

        boolean zoomTrigger1 = hZoom && Math.abs(e.getX()
            - this.zoomPoint.getX()) >= this.zoomTriggerDistance;
        boolean zoomTrigger2 = vZoom && Math.abs(e.getY()
            - this.zoomPoint.getY()) >= this.zoomTriggerDistance;
        if (zoomTrigger1 || zoomTrigger2) {
            if ((hZoom && (e.getX() < this.zoomPoint.getX()))
                || (vZoom && (e.getY() < this.zoomPoint.getY()))) {
                restoreAutoBounds();
            }
            else {
                double x, y, w, h;
                Rectangle2D screenDataArea = getScreenDataArea(
                        (int) this.zoomPoint.getX(),
                        (int) this.zoomPoint.getY());
                double maxX = screenDataArea.getMaxX();
                double maxY = screenDataArea.getMaxY();
                // for mouseReleased event, (horizontalZoom || verticalZoom)
                // will be true, so we can just test for either being false;
                // otherwise both are true
                if (!vZoom) {
                    x = this.zoomPoint.getX();
                    y = screenDataArea.getMinY();
                    w = Math.min(this.zoomRectangle.getWidth(),
                            maxX - this.zoomPoint.getX());
                    h = screenDataArea.getHeight();
                }
                else if (!hZoom) {
                    x = screenDataArea.getMinX();
                    y = this.zoomPoint.getY();
                    w = screenDataArea.getWidth();
                    h = Math.min(this.zoomRectangle.getHeight(),
                            maxY - this.zoomPoint.getY());
                }
                else {
                    x = this.zoomPoint.getX();
                    y = this.zoomPoint.getY();
                    w = Math.min(this.zoomRectangle.getWidth(),
                            maxX - this.zoomPoint.getX());
                    h = Math.min(this.zoomRectangle.getHeight(),
                            maxY - this.zoomPoint.getY());
                }
                Rectangle2D zoomArea = new Rectangle2D.Double(x, y, w, h);
                zoom(zoomArea);
            }
            this.zoomPoint = null;
            this.zoomRectangle = null;
        }
        else {
            // erase the zoom rectangle
            Graphics2D g2 = (Graphics2D) getGraphics();
            if (this.useBuffer) {
                repaint();
            }
            else {
                drawZoomRectangle(g2, true);
            }
            g2.dispose();
            this.zoomPoint = null;
            this.zoomRectangle = null;
        }

    }

    else if (e.isPopupTrigger()) {
        if (this.popup != null) {
            displayPopupMenu(e.getX(), e.getY());
        }
    }

}
 
源代码14 项目: netbeans   文件: ClassesListControllerUI.java
public void mousePressed(final MouseEvent e) {
    final int row = classesListTable.rowAtPoint(e.getPoint());
    updateSelection(row);
    if (e.isPopupTrigger()) showPopupMenu(row, e.getX(), e.getY());
}
 
源代码15 项目: rapidminer-studio   文件: LinkAndBrushChartPanel.java
@Override
public void mouseReleased(MouseEvent e) {

	// if we've been panning, we need to reset now that the mouse is
	// released...
	Rectangle2D zoomRectangle = (Rectangle2D) getChartFieldValueByName("zoomRectangle");
	Point2D zoomPoint = (Point2D) getChartFieldValueByName("zoomPoint");
	if (getChartFieldValueByName("panLast") != null) {
		setChartFieldValue(getChartFieldByName("panLast"), null);
		setCursor(Cursor.getDefaultCursor());
	} else if (zoomRectangle != null) {
		boolean hZoom = false;
		boolean vZoom = false;
		if ((PlotOrientation) getChartFieldValueByName("orientation") == PlotOrientation.HORIZONTAL) {
			hZoom = (Boolean) getChartFieldValueByName("rangeZoomable");
			vZoom = (Boolean) getChartFieldValueByName("domainZoomable");
		} else {
			hZoom = (Boolean) getChartFieldValueByName("domainZoomable");
			vZoom = (Boolean) getChartFieldValueByName("rangeZoomable");
		}

		boolean zoomTrigger1 = hZoom
				&& Math.abs(e.getX() - zoomPoint.getX()) >= (Integer) getChartFieldValueByName("zoomTriggerDistance");
		boolean zoomTrigger2 = vZoom
				&& Math.abs(e.getY() - zoomPoint.getY()) >= (Integer) getChartFieldValueByName("zoomTriggerDistance");
		if (zoomTrigger1 || zoomTrigger2) {
			if (hZoom && e.getX() < zoomPoint.getX() || vZoom && e.getY() < zoomPoint.getY()) {
				restoreAutoBounds();
			} else {
				double x, y, w, h;
				Rectangle2D screenDataArea = getScreenDataArea((int) zoomPoint.getX(), (int) zoomPoint.getY());
				double maxX = screenDataArea.getMaxX();
				double maxY = screenDataArea.getMaxY();
				// for mouseReleased event, (horizontalZoom || verticalZoom)
				// will be true, so we can just test for either being false;
				// otherwise both are true
				if (!vZoom) {
					x = zoomPoint.getX();
					y = screenDataArea.getMinY();
					w = Math.min(zoomRectangle.getWidth(), maxX - zoomPoint.getX());
					h = screenDataArea.getHeight();
				} else if (!hZoom) {
					x = screenDataArea.getMinX();
					y = zoomPoint.getY();
					w = screenDataArea.getWidth();
					h = Math.min(zoomRectangle.getHeight(), maxY - zoomPoint.getY());
				} else {
					x = zoomPoint.getX();
					y = zoomPoint.getY();
					w = Math.min(zoomRectangle.getWidth(), maxX - zoomPoint.getX());
					h = Math.min(zoomRectangle.getHeight(), maxY - zoomPoint.getY());
				}
				Rectangle2D zoomArea = new Rectangle2D.Double(x, y, w, h);
				zoom(zoomArea);
			}
			setChartFieldValue(getChartFieldByName("zoomPoint"), null);
			setChartFieldValue(getChartFieldByName("zoomRectangle"), null);
		} else {
			// erase the zoom rectangle
			Graphics2D g2 = (Graphics2D) getGraphics();
			if ((Boolean) getChartFieldValueByName("useBuffer")) {
				repaint();
			} else {
				drawZoomRectangle(g2, true);
			}
			g2.dispose();
			setChartFieldValue(getChartFieldByName("zoomPoint"), null);
			setChartFieldValue(getChartFieldByName("zoomRectangle"), null);
		}

	}

	else if (e.isPopupTrigger()) {
		if (getChartFieldValueByName("popup") != null) {
			displayPopupMenu(e.getX(), e.getY());
		}
	}

}
 
源代码16 项目: wildfly-core   文件: ManagementModel.java
@Override
public void mouseReleased(MouseEvent e) {
    if (!e.isPopupTrigger()) return;
    showPopup(e);
}
 
源代码17 项目: openjdk-jdk9   文件: AquaPopupMenuUI.java
public boolean isPopupTrigger(final MouseEvent e) {
    // Use the awt popup trigger code since this only runs on our OS!
    return e.isPopupTrigger();
}
 
源代码18 项目: mzmine2   文件: ProjectTreeMouseHandler.java
@Override
public void mouseReleased(MouseEvent e) {
  if (e.isPopupTrigger())
    handlePopupTriggerEvent(e);
}
 
源代码19 项目: consulo   文件: PopupHandler.java
public void mousePressed(MouseEvent e) {
  if (e.isPopupTrigger()) {
    invokePopup(e.getComponent(), e.getX(), e.getY());
    e.consume();
  }
}
 
源代码20 项目: netbeans   文件: HistoryFileView.java
@Override
public void mousePressed(MouseEvent e) {
    pressedPopup = e.isPopupTrigger();
}