List of usage examples for java.awt.event MouseEvent getX
public int getX()
From source file:com.cmsoftware.keyron.vista.Login.java
private void panelContenidoMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_panelContenidoMouseDragged this.setLocation(evt.getX() - xAnterior + this.getLocation().x, evt.getY() - yAnterior + this.getLocation().y); }
From source file:com.igormaznitsa.sciareto.ui.tree.ExplorerTree.java
public ExplorerTree(@Nonnull final Context context) { super();/*from w ww .j a v a2s. c o m*/ this.projectTree = new DnDTree(); this.context = context; this.projectTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); this.projectTree.setDropMode(DropMode.ON); this.projectTree.setEditable(true); ToolTipManager.sharedInstance().registerComponent(this.projectTree); this.projectTree.setCellRenderer(new TreeCellRenderer()); this.projectTree.setModel(new NodeProjectGroup(context, ".")); this.projectTree.setRootVisible(false); this.setViewportView(this.projectTree); this.projectTree.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(@Nonnull final MouseEvent e) { if (e.getClickCount() > 1) { final int selRow = projectTree.getRowForLocation(e.getX(), e.getY()); final TreePath selPath = projectTree.getPathForLocation(e.getX(), e.getY()); if (selRow >= 0) { final NodeFileOrFolder node = (NodeFileOrFolder) selPath.getLastPathComponent(); if (node != null && node.isLeaf()) { final File file = node.makeFileForNode(); if (file != null && !context.openFileAsTab(file)) { UiUtils.openInSystemViewer(file); } } } } } @Override public void mouseReleased(@Nonnull final MouseEvent e) { if (e.isPopupTrigger()) { processPopup(e); } } @Override public void mousePressed(@Nonnull final MouseEvent e) { if (e.isPopupTrigger()) { processPopup(e); } } private void processPopup(@Nonnull final MouseEvent e) { final TreePath selPath = projectTree.getPathForLocation(e.getX(), e.getY()); if (selPath != null) { projectTree.setSelectionPath(selPath); final Object last = selPath.getLastPathComponent(); if (last instanceof NodeFileOrFolder) { makePopupMenu((NodeFileOrFolder) last).show(e.getComponent(), e.getX(), e.getY()); } } } }); }
From source file:MainGUI.java
private void bkgPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_bkgPanelMouseClicked for (CButton c : ((BKGPanel) bkgPanel).getButtons()) { if (c.isContained(evt.getX(), evt.getY())) { if (c.text.equals("Play")) { final MainGUI main = this; SwingUtilities.invokeLater(new Runnable() { @Override/*from w w w . j ava 2 s. com*/ public void run() { QuestionGUI gui = new QuestionGUI(main, Question.generateQuestionSet(main.getDifficulty(), 20), username); gui.setVisible(true); } }); } else if (c.text.equals("Check Stats")) { try { if (stats != null && stats.isValid()) { return; } stats = new UserHistoryGUI(username); stats.setVisible(true); } catch (ParseException e) { e.printStackTrace(); } } else if (c.text.equals("Options")) { opt.setVisible(true); } else if (c.text.equals("Facebook Connect")) { } } } }
From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java
public void mousePressed(MouseEvent e) { if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) { if (this.coElutionRegion == null) { shifted = true;// w w w . ja va 2 s .c om Rectangle2D screenDataArea = _cp.getScreenDataArea(e.getX(), e.getY()); if (screenDataArea != null) { this.coElutionStart = getPointInRectangle(e.getX(), e.getY(), screenDataArea); } else { this.coElutionStart = null; } } } else { _cp.mousePressed(e); } }
From source file:com.tradedesksoftware.ets.client.charting.ChartShiftController.java
public void mouseMoved(MouseEvent mouseEvent) { if (mouseEvent.isControlDown()) { final Rectangle scaledDataArea = chartPanel.getScreenDataArea(); if (mouseEvent.getX() > (int) scaledDataArea.x && mouseEvent.getY() > (int) scaledDataArea.y && mouseEvent.getX() < (int) scaledDataArea.x + scaledDataArea.width && mouseEvent.getY() < (int) scaledDataArea.y + scaledDataArea.height) chartPanel.setCursor(MOVE);/*ww w. j a v a2s . c om*/ else chartPanel.setCursor(ARROW); } }
From source file:dbseer.gui.panel.DBSeerExplainChartPanel.java
@Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3 || this.popupMenu.isShowing()) { return;//from ww w.ja va2 s. c o m } //testLog.append("Mouse pressed: " + e.getX() + ", " + e.getY() + "\n"); startX = e.getX(); startY = e.getY(); endX = e.getX(); endY = e.getY(); // if (selectRectangle != null) // { // Graphics2D g2 = (Graphics2D) this.getGraphics(); // drawSelectRectangle(g2); // this.selectRectangle = new Rectangle2D.Double(e.getX(), e.getY(), 0, 0); // } this.isNewRectangle = true; this.x = e.getX(); this.y = e.getY(); this.width = 0; this.height = 0; repaint(); }
From source file:PopUpColorMenu.java
public PopUpColorMenu() { JFrame frame = new JFrame(); final JPopupMenu colorMenu = new JPopupMenu("Color"); colorMenu.add(makeMenuItem("Red")); colorMenu.add(makeMenuItem("Green")); colorMenu.add(makeMenuItem("Blue")); MouseListener mouseListener = new MouseAdapter() { public void mousePressed(MouseEvent e) { checkPopup(e);/*from www . j a va 2 s . c om*/ } public void mouseClicked(MouseEvent e) { checkPopup(e); } public void mouseReleased(MouseEvent e) { checkPopup(e); } private void checkPopup(MouseEvent e) { if (e.isPopupTrigger()) { selectedComponent = e.getComponent(); colorMenu.show(e.getComponent(), e.getX(), e.getY()); } } }; frame.setLayout(new FlowLayout()); JButton button = new JButton("Uno"); button.addMouseListener(mouseListener); frame.add(button); button = new JButton("Due"); button.addMouseListener(mouseListener); frame.add(button); button = new JButton("Tre"); button.addMouseListener(mouseListener); frame.add(button); frame.getContentPane().addMouseListener(mouseListener); frame.setSize(200, 50); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:EventTestPane.java
/** * Display mouse moved and dragged mouse event. Note that MouseEvent is the * only event type that has two methods, two EventListener interfaces and * two adapter classes to handle two distinct categories of events. Also, as * seen in init(), mouse motion events must be requested separately from * other mouse event types./*from w w w. j a va 2 s .c om*/ */ public void processMouseMotionEvent(MouseEvent e) { String type = null; switch (e.getID()) { case MouseEvent.MOUSE_MOVED: type = "MOUSE_MOVED"; break; case MouseEvent.MOUSE_DRAGGED: type = "MOUSE_DRAGGED"; break; } showLine(mousemods(e) + type + ": [" + e.getX() + "," + e.getY() + "] " + "num clicks = " + e.getClickCount() + (e.isPopupTrigger() ? "; is popup trigger" : "")); }
From source file:components.ScrollDemo2.java
public void mouseReleased(MouseEvent e) { final int W = 100; final int H = 100; boolean changed = false; if (SwingUtilities.isRightMouseButton(e)) { //This will clear the graphic objects. circles.removeAllElements();/* w w w . jav a2 s. c om*/ area.width = 0; area.height = 0; changed = true; } else { int x = e.getX() - W / 2; int y = e.getY() - H / 2; if (x < 0) x = 0; if (y < 0) y = 0; Rectangle rect = new Rectangle(x, y, W, H); circles.addElement(rect); drawingPane.scrollRectToVisible(rect); int this_width = (x + W + 2); if (this_width > area.width) { area.width = this_width; changed = true; } int this_height = (y + H + 2); if (this_height > area.height) { area.height = this_height; changed = true; } } if (changed) { //Update client's preferred size because //the area taken up by the graphics has //gotten larger or smaller (if cleared). drawingPane.setPreferredSize(area); //Let the scroll pane know to update itself //and its scrollbars. drawingPane.revalidate(); } drawingPane.repaint(); }
From source file:eu.europa.ec.markt.dss.applet.view.validationpolicy.EditView.java
private void registerMouseListener(final JTree tree) { MouseListener mouseAdapter = new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { if (mouseEvent.getButton() == MouseEvent.BUTTON3) { final int selectedRow = tree.getRowForLocation(mouseEvent.getX(), mouseEvent.getY()); final TreePath selectedPath = tree.getPathForLocation(mouseEvent.getX(), mouseEvent.getY()); if (selectedRow != -1) { final XmlDomAdapterNode clickedItem = (XmlDomAdapterNode) selectedPath .getLastPathComponent(); final boolean isLeaf = tree.getModel().isLeaf(selectedPath.getLastPathComponent()); // Do nothing on root element if (selectedPath.getPathCount() > 1) { // find the allowed actions, to know if a popup menu should be displayed and the content of the popup menu + action handlers if (clickedItem.node instanceof Element) { nodeActionAdd(mouseEvent, selectedRow, selectedPath, clickedItem, tree); } else if (isLeaf) { valueLeafActionEdit(mouseEvent, selectedPath, clickedItem, tree); }/*from w ww .j a v a 2 s . c o m*/ } } } } }; tree.addMouseListener(mouseAdapter); }