List of usage examples for java.awt.event MouseEvent getX
public int getX()
From source file:net.rptools.tokentool.ui.TokenCompositionPanel.java
public void mouseDragged(MouseEvent e) { int dx = e.getX() - dragStartX; int dy = e.getY() - dragStartY; dragStartX = e.getX();// w ww. j a v a 2 s.c o m dragStartY = e.getY(); tokenOffsetX += dx; tokenOffsetY += dy; repaint(); fireCompositionChanged(); }
From source file:com.mirth.connect.client.ui.components.MirthIconTextField.java
public MirthIconTextField(ImageIcon icon) { setIcon(icon);/* www . j av a 2s . c o m*/ addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { if (isIconActive(evt) && iconPopupMenuComponent != null) { JPopupMenu iconPopupMenu = new JPopupMenu(); iconPopupMenu.insert(iconPopupMenuComponent, 0); iconPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); } } }); addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent evt) { int cursorType = getCursor().getType(); if (isIconActive(evt)) { if (StringUtils.isNotBlank(alternateToolTipText)) { MirthIconTextField.super.setToolTipText(alternateToolTipText); } if (iconPopupMenuComponent != null) { if (cursorType != Cursor.HAND_CURSOR) { setCursor(new Cursor(Cursor.HAND_CURSOR)); } } else { if (cursorType != Cursor.DEFAULT_CURSOR) { setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } } else { if (StringUtils.isNotBlank(alternateToolTipText)) { MirthIconTextField.super.setToolTipText(originalToolTipText); } if (cursorType != Cursor.TEXT_CURSOR) { setCursor(new Cursor(Cursor.TEXT_CURSOR)); } } } }); }
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 . ja v a2s . 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:dbseer.gui.panel.DBSeerExplainChartPanel.java
@Override public void mouseDragged(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3 || this.popupMenu.isShowing()) { return;//from w w w . j a v 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:ListProperties.java
public void mouseClicked(MouseEvent mouseEvent) { TableColumnModel columnModel = table.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(mouseEvent.getX()); int column = table.convertColumnIndexToModel(viewColumn); if (mouseEvent.getClickCount() == 1 && column != -1) { System.out.println("Sorting ..."); int shiftPressed = (mouseEvent.getModifiers() & InputEvent.SHIFT_MASK); boolean ascending = (shiftPressed == 0); sorter.sortByColumn(column, ascending); }// w w w . j a va 2 s. com }
From source file:org.jax.maanova.plot.MaanovaChartPanel.java
private void myMouseDragged(MouseEvent e) { if (this.dragRectangle != null) { this.dragRectangle.width = e.getX() - this.dragRectangle.x; this.dragRectangle.height = e.getY() - this.dragRectangle.y; this.repaint(); }//from ww w.ja v a2 s . co m }
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 w w.java 2 s . c om }
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 w w w. j a v a 2s . 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 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:MouseClickListener.java
public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e)) { System.out.print("The mouse left button was clicked"); } else if (SwingUtilities.isRightMouseButton(e)) { System.out.print("The mouse right button was clicked"); } else if (SwingUtilities.isMiddleMouseButton(e)) { System.out.print("The mouse middle button was clicked"); }/*from w w w . j av a 2s.c o m*/ System.out.print(e.getClickCount() + "time(s)"); int x = e.getX(); int y = e.getY(); System.out.println(" at (" + x + "," + y + ")"); }