List of usage examples for java.awt.event MouseEvent getY
public int getY()
From source file:Main.java
@Override public boolean isCellEditable(EventObject e) { if (e instanceof MouseEvent && e.getSource() instanceof JTree) { MouseEvent me = (MouseEvent) e; JTree tree = (JTree) e.getSource(); TreePath path = tree.getPathForLocation(me.getX(), me.getY()); Rectangle r = tree.getPathBounds(path); if (r == null) { return false; }/*from w w w . j av a2s. c o m*/ Dimension d = check.getPreferredSize(); r.setSize(new Dimension(d.width, r.height)); if (r.contains(me.getX(), me.getY())) { check.setBounds(new Rectangle(0, 0, d.width, r.height)); return true; } } return false; }
From source file:Main.java
@Override public boolean isCellEditable(final EventObject event) { Object source = event.getSource(); if (!(source instanceof JTree) || !(event instanceof MouseEvent)) { return false; }/*from w w w . ja va 2s . c om*/ JTree tree = (JTree) source; MouseEvent mouseEvent = (MouseEvent) event; TreePath path = tree.getPathForLocation(mouseEvent.getX(), mouseEvent.getY()); if (path == null) { return false; } Object node = path.getLastPathComponent(); if (node == null || !(node instanceof DefaultMutableTreeNode)) { return false; } Rectangle r = tree.getPathBounds(path); if (r == null) { return false; } Dimension d = panel.getPreferredSize(); r.setSize(new Dimension(d.width, r.height)); if (r.contains(mouseEvent.getX(), mouseEvent.getY())) { Point pt = SwingUtilities.convertPoint(tree, mouseEvent.getPoint(), panel); Object o = SwingUtilities.getDeepestComponentAt(panel, pt.x, pt.y); if (o instanceof JComboBox) { comboBox.showPopup(); } else if (o instanceof Component) { Object oo = SwingUtilities.getAncestorOfClass(JComboBox.class, (Component) o); if (oo instanceof JComboBox) { comboBox.showPopup(); } } return true; } return delegate.isCellEditable(event); }
From source file:UndoableDrawingPanel.java
public UndoableDrawingPanel() { MouseListener mouseListener = new MouseAdapter() { public void mouseReleased(MouseEvent mouseEvent) { StateEdit stateEdit = new StateEdit(UndoableDrawingPanel.this); polygon.addPoint(mouseEvent.getX(), mouseEvent.getY()); stateEdit.end();/* w w w . j a va2 s . c om*/ undoableEditSupport.postEdit(stateEdit); repaint(); } }; addMouseListener(mouseListener); }
From source file:fi.smaa.jsmaa.gui.SMAA2GUIFactory.java
@Override protected JButton buildToolBarAddCriterionButton() { JButton button = new JButton(ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_ADDCRITERION)); button.setToolTipText("Add criterion"); final JPopupMenu addMenu = new JPopupMenu(); addUtilityAddItemsToMenu(addMenu);/*from w w w . j a v a 2s .c o m*/ button.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { addMenu.show((Component) evt.getSource(), evt.getX(), evt.getY()); } }); return button; }
From source file:CheckBoxNodeTreeSample.java
public boolean isCellEditable(EventObject event) { boolean returnValue = false; if (event instanceof MouseEvent) { MouseEvent mouseEvent = (MouseEvent) event; TreePath path = tree.getPathForLocation(mouseEvent.getX(), mouseEvent.getY()); if (path != null) { Object node = path.getLastPathComponent(); if ((node != null) && (node instanceof DefaultMutableTreeNode)) { DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) node; Object userObject = treeNode.getUserObject(); returnValue = ((treeNode.isLeaf()) && (userObject instanceof CheckBoxNode)); }//from w w w . j a v a 2 s . c o m } } return returnValue; }
From source file:UndoableDrawingPanel2.java
public UndoableDrawingPanel2() { MouseListener mouseListener = new MouseAdapter() { public void mouseReleased(MouseEvent mouseEvent) { StateEdit stateEdit = new StateEdit(UndoableDrawingPanel2.this); polygon.addPoint(mouseEvent.getX(), mouseEvent.getY()); stateEdit.end();/*from w ww .j av a 2s . co m*/ undoableEditSupport.postEdit(stateEdit); repaint(); } }; addMouseListener(mouseListener); }
From source file:BezLab.java
public void mousePressed(MouseEvent e) { dragIndex = NOT_DRAGGING;/* w ww. j a va 2s .c om*/ int minDistance = Integer.MAX_VALUE; int indexOfClosestPoint = -1; for (int i = 0; i < 4; i++) { int deltaX = xs[i] - e.getX(); int deltaY = ys[i] - e.getY(); int distance = (int) (Math.sqrt(deltaX * deltaX + deltaY * deltaY)); if (distance < minDistance) { minDistance = distance; indexOfClosestPoint = i; } } if (minDistance > NEIGHBORHOOD) return; dragIndex = indexOfClosestPoint; }
From source file:com.vgi.mafscaling.MafChartPanel.java
public void mousePressed(MouseEvent e) { Insets insets = chartPanel.getInsets(); int x = (int) ((e.getX() - insets.left) / chartPanel.getScaleX()); int y = (int) ((e.getY() - insets.top) / chartPanel.getScaleY()); ChartEntity entity = chartPanel.getChartRenderingInfo().getEntityCollection().getEntity(x, y); if (entity == null || !(entity instanceof XYItemEntity)) return;// www.j a va2 s .c om IsMovable = true; chartPanel.setCursor(new Cursor(Cursor.HAND_CURSOR)); xyItemEntity = (XYItemEntity) entity; XYPlot plot = chartPanel.getChart().getXYPlot(); Rectangle2D dataArea = chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea(); Point2D p = chartPanel.translateScreenToJava2D(e.getPoint()); initialMovePointY = plot.getRangeAxis().java2DToValue(p.getY(), dataArea, plot.getRangeAxisEdge()); }
From source file:UndoDrawing.java
public UndoableDrawingPanel() { MouseListener mouseListener = new MouseAdapter() { public void mouseReleased(MouseEvent mouseEvent) { undoableEditSupport.postEdit(new UndoableDrawEdit(UndoableDrawingPanel.this)); polygon.addPoint(mouseEvent.getX(), mouseEvent.getY()); repaint();/*from w w w . j av a 2 s . co m*/ } }; addMouseListener(mouseListener); }
From source file:it.unibas.spicygui.vista.listener.MyMouseEventListener.java
public void mousePressed(MouseEvent e) { e.consume();//from ww w . j a va 2 s.c o m Component comS = SwingUtilities.getDeepestComponentAt(pannelloPrincipale, e.getX(), e.getY()); if ((comS instanceof JScrollBar || !((comS instanceof JPanel) || (comS instanceof JTree))) && comS != null) { if (tmp12 == null) { tmp12 = comS; } } if (!(Costanti.INTERMEDIE.equals(comS.getName()))) { dispacciaEvento(null, e, e.getPoint(), false); } jLayeredPane.moveToFront(component); component.updateUI(); }