List of usage examples for java.awt.event MouseEvent getY
public int getY()
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 a v a2 s . c om*/ 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:burlov.ultracipher.swing.MainPanel.java
private void showTextPopup(MouseEvent e) { if (e.isPopupTrigger()) { e.getComponent().requestFocusInWindow(); textPopup.show(e.getComponent(), e.getX(), e.getY()); }/* ww w .j a v a 2 s . com*/ }
From source file:net.sf.mzmine.desktop.impl.projecttree.ProjectTreeMouseHandler.java
private void handlePopupTriggerEvent(MouseEvent e) { TreePath clickedPath = tree.getPathForLocation(e.getX(), e.getY()); if (clickedPath == null) return;//from ww w .j a v a 2 s .c o m DefaultMutableTreeNode node = (DefaultMutableTreeNode) clickedPath.getLastPathComponent(); Object clickedObject = node.getUserObject(); if (clickedObject instanceof RawDataFile) dataFilePopupMenu.show(e.getComponent(), e.getX(), e.getY()); if (clickedObject instanceof Scan) scanPopupMenu.show(e.getComponent(), e.getX(), e.getY()); if (clickedObject instanceof MassList) massListPopupMenu.show(e.getComponent(), e.getX(), e.getY()); if (clickedObject instanceof PeakList) peakListPopupMenu.show(e.getComponent(), e.getX(), e.getY()); if (clickedObject instanceof PeakListRow) peakListRowPopupMenu.show(e.getComponent(), e.getX(), e.getY()); }
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; }// w w w . j av a2s . c o m } } 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:br.univali.ps.ui.telas.TelaPrincipal.java
/** /**//from ww w . j a v a2s . co m * Creates new form TelaInicial */ public TelaPrincipal() { initComponents(); criaAbas(); configurarCores(); instalarObservadores(); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent me) { // Get x,y and store them pX = me.getX(); pY = me.getY(); } public void mouseDragged(MouseEvent me) { Lancador.getJFrame().setLocation(Lancador.getJFrame().getLocation().x + me.getX() - pX, Lancador.getJFrame().getLocation().y + me.getY() - pY); } }); addMouseMotionListener(new MouseMotionAdapter() { public void mouseDragged(MouseEvent me) { Lancador.getJFrame().setLocation(Lancador.getJFrame().getLocation().x + me.getX() - pX, Lancador.getJFrame().getLocation().y + me.getY() - pY); } }); }
From source file:net.rptools.tokentool.ui.TokenCompositionPanel.java
public void mousePressed(MouseEvent e) { dragStartX = e.getX(); dragStartY = e.getY(); }
From source file:lu.lippmann.cdb.common.gui.DragAndDroppablePieChartPanel.java
/** * {@inheritDoc}/*from ww w . ja v a 2 s .c o m*/ */ @Override public void mouseDragged(MouseEvent e) { if (source != null) { final ChartRenderingInfo info = getChartRenderingInfo(); final Rectangle2D dataArea = info.getPlotInfo().getPlotArea(); final double xx = dataArea.getCenterX(); final double yy = dataArea.getCenterY(); tx = e.getX() - xx; ty = e.getY() - yy; repaint(); } }
From source file:edu.ku.brc.specify.tasks.subpane.security.NavigationTreeContextMenuMgr.java
public void mousePressed(MouseEvent e) { TreePath clickedElement = getTree().getPathForLocation(e.getX(), e.getY()); // Update the selection if necessary updateSelection(clickedElement);//from www. ja v a 2 s . c o m TreePath tp = clickedElement; if (tp != null) { lastClickComp = (DefaultMutableTreeNode) tp.getLastPathComponent(); updateBtnUI(); } }
From source file:dbseer.gui.panel.DBSeerExplainChartPanel.java
@Override public void mouseDragged(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3 || this.popupMenu.isShowing()) { return;// www . jav a 2s .c o m } endX = e.getX(); endY = e.getY(); Graphics2D g2 = (Graphics2D) this.getGraphics(); // drawSelectRectangle(g2); double xmin = Math.min(startX, endX); double ymin = Math.min(startY, endY); double xmax = Math.max(startX, endX); double ymax = Math.max(startY, endY); // this.selectRectangle = new Rectangle2D.Double( // xmin, ymin, // xmax - xmin, ymax - ymin); this.x = xmin; this.y = ymin; this.width = xmax - xmin; this.height = ymax - ymin; // drawSelectRectangle(g2); // g2.dispose(); this.isNewRectangle = false; repaint(); }
From source file:dbseer.gui.panel.DBSeerExplainChartPanel.java
@Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { displayPopupMenu(e.getX(), e.getY()); return;//w ww .ja v a 2 s . co m } repaint(); int smallX = Math.min(startX, endX); int smallY = Math.min(startY, endY); int bigX = Math.max(startX, endX); int bigY = Math.max(startY, endY); XYPlot plot = this.getChart().getXYPlot(); Rectangle2D plotArea = this.getScreenDataArea(); double chartSmallX = plot.getDomainAxis().java2DToValue(smallX, plotArea, plot.getDomainAxisEdge()); double chartBigX = plot.getDomainAxis().java2DToValue(bigX, plotArea, plot.getDomainAxisEdge()); double chartSmallY = plot.getRangeAxis().java2DToValue(smallY, plotArea, plot.getRangeAxisEdge()); double chartBigY = plot.getRangeAxis().java2DToValue(bigY, plotArea, plot.getRangeAxisEdge()); double minXValue = Math.min(chartSmallX, chartBigX); double maxXValue = Math.max(chartSmallX, chartBigX); double minYValue = Math.min(chartSmallY, chartBigY); double maxYValue = Math.max(chartSmallY, chartBigY); //testLog.append("Scanning: (" + smallX + ", " + smallY + "), (" + bigX + ", " + bigY + ")\n"); //testLog.append("Scanning: X = [" + Math.min(chartSmallX, chartBigX) + ", " + Math.max(chartSmallX, chartBigX) + "]\n"); //testLog.append("Scanning: Y = [" + Math.min(chartSmallY, chartBigY) + ", " + Math.max(chartSmallY, chartBigY) + "]\n"); Set<XYItemEntity> foundItem = new HashSet<XYItemEntity>(); XYDataset dataset = this.getChart().getXYPlot().getDataset(); EntityCollection collection = this.getChartRenderingInfo().getEntityCollection(); for (Object obj : collection.getEntities()) { if (obj instanceof XYItemEntity) { XYItemEntity entity = (XYItemEntity) obj; int series = entity.getSeriesIndex(); int idx = entity.getItem(); if (dataset.getX(series, idx).doubleValue() >= minXValue && dataset.getX(series, idx).doubleValue() <= maxXValue && dataset.getY(series, idx).doubleValue() >= minYValue && dataset.getY(series, idx).doubleValue() <= maxYValue) { foundItem.add(entity); } } } // for (int x = smallX; x <= bigX; ++x) // { // for (int y = smallY; y <= bigY; ++y) // { // ChartEntity entity = this.getEntityForPoint(x, y); // if (entity instanceof XYItemEntity) // { // foundItem.add((XYItemEntity)entity); // } // } // } selectedItems = foundItem; // outlierRegion.clear(); // for (XYItemEntity entity : foundItem) // { // //testLog.append(entity.toString() + "\n"); // //testLog.append("Series = " + entity.getSeriesIndex() + ", "); // //testLog.append("X = " + entity.getDataset().getX(entity.getSeriesIndex(), entity.getItem()) + ", "); // //testLog.append("Y = " + entity.getDataset().getY(entity.getSeriesIndex(), entity.getItem()) + "\n"); // outlierRegion.add(entity.getDataset().getX(entity.getSeriesIndex(), entity.getItem()).doubleValue()); // } // // Collections.sort(outlierRegion); // if (!outlierRegion.isEmpty()) // { // testLog.setText(""); // testLog.append("Outlier time selected = ["); // for (int i = 0; i < outlierRegion.size(); ++i) // { // testLog.append(outlierRegion.get(i).toString()); // if (i < outlierRegion.size() - 1) // { // testLog.append(" "); // } // } // testLog.append("]\n"); // } }