List of usage examples for java.awt.event MouseEvent isPopupTrigger
public boolean isPopupTrigger()
From source file:Main.java
public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) myPopupEvent(e); }
From source file:Main.java
MyJTree(DefaultMutableTreeNode dmtn) { super(dmtn);//from w w w. ja v a 2s . c om mi.addActionListener(this); mi.setActionCommand("insert"); popup.add(mi); mi = new JMenuItem("Remove this node"); mi.addActionListener(this); mi.setActionCommand("remove"); popup.add(mi); addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { popup.show((JComponent) e.getSource(), e.getX(), e.getY()); } } }); }
From source file:de.codesourcery.eve.skills.ui.utils.PopupMenuBuilder.java
/** * Checks whether a mouse-click event// w w w . jav a2 s. co m * should trigger a context-sensitive popup menu * and renders the menu if so. * * @param e */ protected void maybeShowPopup(MouseEvent e) { if (!e.isPopupTrigger()) { return; } popupMenu.removeAll(); if (populateMenu() > 0) { popupMenu.show(e.getComponent(), e.getX(), e.getY()); } }
From source file:PopupDemo.java
void mouseAction(String which, MouseEvent e) { Component c = e.getComponent(); System.out.println(which + "e=" + e + ", mods=" + getMods(e) + ", component=" + c); if (e.isPopupTrigger()) { System.out.println("isPopup"); PopupMenu pm = getHash(c); pm.show(c, c.getSize().width / 2, c.getSize().height / 2); }//from w w w .j a v a 2 s . c o m }
From source file:org.nekorp.workflow.desktop.view.AutoDamageView.java
private void contentMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_contentMouseReleased if (evt.isPopupTrigger()) { for (DamageDetailGraphicsView x : damageDetail) { Point punto = new Point(evt.getX(), evt.getY()); if (x.shapeContains(punto) && editable) { this.currentEdited = x; this.jPopupMenu1.show(evt.getComponent(), evt.getX(), evt.getY()); break; }//from ww w. jav a 2s. c om } } else { if (currentView.shapeContains(evt.getX() - boundsX, evt.getY() - boundsY) && editable) { damageCaptura.setX(evt.getX() - boundsX); damageCaptura.setY(evt.getY() - boundsY); dialogFactory.createDialog(mainFrame, true).setVisible(true); } } }
From source file:com.iisigroup.ris.WebFileScanUtilBrowserUI.java
/** * Auto-generated method for setting the popup menu for a component *///from w w w . j a v a 2 s .c o m private void setComponentPopupMenu(final java.awt.Component parent, final javax.swing.JPopupMenu menu) { parent.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent e) { if (e.isPopupTrigger()) menu.show(parent, e.getX(), e.getY()); } public void mouseReleased(java.awt.event.MouseEvent e) { if (e.isPopupTrigger()) menu.show(parent, e.getX(), e.getY()); } }); }
From source file:burlov.ultracipher.swing.MainPanel.java
private void showTextPopup(MouseEvent e) { if (e.isPopupTrigger()) { e.getComponent().requestFocusInWindow(); textPopup.show(e.getComponent(), e.getX(), e.getY()); }/* w ww . ja va 2s .c o m*/ }
From source file:MouseTest.java
public MouseTest() { super();/* w ww. j a v a2 s. c o m*/ final JPopupMenu pop = new JPopupMenu(); pop.add(new JMenuItem("Cut")); pop.add(new JMenuItem("Copy")); pop.add(new JMenuItem("Paste")); pop.addSeparator(); pop.add(new JMenuItem("Select All")); pop.setInvoker(this); MouseListener popup = new MouseListener() { public void mouseClicked(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { showPopup(e); } } public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { showPopup(e); } } private void showPopup(MouseEvent e) { pop.show(e.getComponent(), e.getX(), e.getY()); } }; addMouseListener(popup); MouseListener drawing1 = new MouseListener() { public void mouseClicked(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { color = Color.RED; startX = endX = e.getX(); startY = endY = e.getY(); repaint(); } public void mouseReleased(MouseEvent e) { color = Color.BLACK; repaint(); } }; addMouseListener(drawing1); MouseMotionListener drawing2 = new MouseMotionListener() { public void mouseDragged(MouseEvent e) { endX = e.getX(); endY = e.getY(); repaint(); } public void mouseMoved(MouseEvent e) { } }; addMouseMotionListener(drawing2); }
From source file:Main.java
public Main() { Icon icon = UIManager.getIcon("html.pendingImage"); JTabbedPane jtb = new JTabbedPane(); JPanel jplInnerPanel1 = createInnerPanel("Tab 1: Tooltip and Icon"); jtb.addTab("One", icon, jplInnerPanel1, "Tab 1"); jtb.setSelectedIndex(0);/*from w w w. j av a 2 s . c o m*/ JPanel jplInnerPanel2 = createInnerPanel("Tab 2: Icon only"); jtb.addTab("Two", icon, jplInnerPanel2); JPanel jplInnerPanel3 = createInnerPanel("Tab 3: Tooltip and Icon"); jtb.addTab("Three", icon, jplInnerPanel3, "Tab 3"); JPanel jplInnerPanel4 = createInnerPanel("Tab 4: Text only"); jtb.addTab("Four", jplInnerPanel4); menu.add(new JMenuItem("Item 1")); menu.add(new JMenuItem("Item 2")); JLabel tab4Label = new JLabel(); tab4Label.setText("Four"); jtb.setTabComponentAt(3, tab4Label); tab4Label.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { maybeShowPopup(e); } @Override public void mousePressed(MouseEvent e) { maybeShowPopup(e); } private void maybeShowPopup(MouseEvent e) { jtb.getModel().setSelectedIndex(3); if (e.isPopupTrigger()) { menu.show(e.getComponent(), e.getX(), e.getY()); } } }); setLayout(new GridLayout()); add(jtb); }
From source file:lu.lippmann.cdb.graph.mouse.CadralEditingGraphMousePlugin.java
/** * {@inheritDoc}//from www . j a v a 2s . c om */ @Override public void mouseReleased(MouseEvent e) { //Don't create node or edge with right click ! if (!e.isPopupTrigger()) { @SuppressWarnings("unchecked") final VisualizationViewer<CNode, CEdge> vv = (VisualizationViewer<CNode, CEdge>) e.getSource(); final Point2D p = e.getPoint(); final Layout<CNode, CEdge> layout = vv.getModel().getGraphLayout(); final GraphWithOperations graph = (GraphWithOperations) layout.getGraph(); final GraphElementAccessor<CNode, CEdge> pickSupport = vv.getPickSupport(); if (pickSupport != null) { CNode vertex = pickSupport.getVertex(layout, p.getX(), p.getY()); // if no vertex create one on the fly if (vertex == null) { final CNode newNode = vertexFactory.create(); final Point2D newPos = vv.getRenderContext().getMultiLayerTransformer() .inverseTransform(e.getPoint()); graph.addVertex(newNode, new CPoint(newPos.getX(), newPos.getY())); layout.lock(newNode, false); vertex = newNode; } else { //reset to initial color if needed if (startVertex != null && !startVertex.equals(vertex)) { if (pointedVertices.containsKey(vertex)) { vertex.setColor(pointedVertices.get(vertex)); } } layout.lock(vertex, false); } // if the source & destination vertex are not the same : create edge if (vertex != null && startVertex != null) { if (!startVertex.equals(vertex)) { transformEdgeShape(down, down); transformArrowShape(down, e.getPoint()); graph.addEdge(edgeFactory.create(), startVertex, vertex, edgeIsDirected); } } } //Reset fields startVertex = null; down = null; edgeIsDirected = EdgeType.UNDIRECTED; vv.removePostRenderPaintable(edgePaintable); vv.removePostRenderPaintable(arrowPaintable); //clear color mapping map pointedVertices.clear(); dragVertex = null; lastDragVertex = null; vv.repaint(); } }