Example usage for java.awt.event MouseEvent getY

List of usage examples for java.awt.event MouseEvent getY

Introduction

In this page you can find the example usage for java.awt.event MouseEvent getY.

Prototype

public int getY() 

Source Link

Document

Returns the vertical y position of the event relative to the source component.

Usage

From source file:dbseer.gui.panel.DBSeerExplainChartPanel.java

@Override
public void mousePressed(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON3 || this.popupMenu.isShowing()) {
        return;/*w w  w . j  ava2s  . 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:de.dakror.villagedefense.game.entity.Entity.java

public boolean mousePressed(MouseEvent e) {
    if (alpha == 0)
        return false;

    if (alpha != 1 && this instanceof Struct)
        return clicked = getBump(true).contains(e.getPoint());

    return clicked = contains(e.getX(), e.getY());
}

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);/*from  w ww .  j  a va  2 s. c om*/
        else
            chartPanel.setCursor(ARROW);
    }
}

From source file:net.sf.mzmine.chartbasics.gui.swing.ChartGestureMouseAdapter.java

/**
 * Find chartentities like JFreeChartEntity, AxisEntity, PlotEntity, TitleEntity, XY...
 * //w  w  w . j  a  va2s . com
 * @param chartPanel
 * @param x
 * @param y
 * @return
 */
private ChartEntity findChartEntity(ChartPanel chartPanel, MouseEvent e) {
    // coordinates to find chart entities
    Insets insets = chartPanel.getInsets();
    int x = (int) ((e.getX() - insets.left) / chartPanel.getScaleX());
    int y = (int) ((e.getY() - insets.top) / chartPanel.getScaleY());

    if (lastEntity != null && x == lastEntityX && y == lastEntityY)
        return lastEntity;
    else {
        ChartRenderingInfo info = chartPanel.getChartRenderingInfo();
        ChartEntity entity = null;
        if (info != null) {
            EntityCollection entities = info.getEntityCollection();
            if (entities != null) {
                entity = entities.getEntity(x, y);
            }
        }
        return entity;
    }
}

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  ww  .j  ava  2 s.  com
        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: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:eu.europa.esig.dss.applet.view.validationpolicy.EditView.java

private void registerMouseListener(final JTree tree) {

    MouseListener mouseAdapter = new MouseAdapter() {
        @Override//  w w  w. j  av a  2 s. com
        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);
                        }
                    }
                }
            }
        }
    };
    tree.addMouseListener(mouseAdapter);
}

From source file:com.mirth.connect.client.ui.components.MirthTable.java

public void setMirthColumnControlEnabled(boolean enabled) {
    if (enabled) {
        if (tableSortAdapter == null) {
            tableSortAdapter = new MouseAdapter() {
                public void mouseClicked(MouseEvent e) {
                    if (SwingUtilities.isRightMouseButton(e)) {
                        getColumnMenu().show(e.getComponent(), e.getX(), e.getY());
                    }/*w w  w  .  j a v  a 2s.  c o m*/
                }
            };

            getTableHeader().addMouseListener(tableSortAdapter);
        }
    } else {
        if (tableSortAdapter != null) {
            getTableHeader().removeMouseListener(tableSortAdapter);
            tableSortAdapter = null;
        }
    }

    setColumnControlVisible(enabled);
}

From source file:FileTree3.java

public FileTree3() {
    super("Directories Tree [Tool Tips]");
    setSize(400, 300);//from w ww  .j  av  a  2s  .  c o m

    DefaultMutableTreeNode top = new DefaultMutableTreeNode(new IconData(ICON_COMPUTER, null, "Computer"));

    DefaultMutableTreeNode node;
    File[] roots = File.listRoots();
    for (int k = 0; k < roots.length; k++) {
        node = new DefaultMutableTreeNode(new IconData(ICON_DISK, null, new FileNode(roots[k])));
        top.add(node);
        node.add(new DefaultMutableTreeNode(new Boolean(true)));
    }

    m_model = new DefaultTreeModel(top);
    // NEW
    m_tree = new JTree(m_model) {
        public String getToolTipText(MouseEvent ev) {
            if (ev == null)
                return null;
            TreePath path = m_tree.getPathForLocation(ev.getX(), ev.getY());
            if (path != null) {
                FileNode fnode = getFileNode(getTreeNode(path));
                if (fnode == null)
                    return null;
                File f = fnode.getFile();
                return (f == null ? null : f.getPath());
            }
            return null;
        }
    };
    ToolTipManager.sharedInstance().registerComponent(m_tree);

    m_tree.putClientProperty("JTree.lineStyle", "Angled");

    TreeCellRenderer renderer = new IconCellRenderer();
    m_tree.setCellRenderer(renderer);

    m_tree.addTreeExpansionListener(new DirExpansionListener());

    m_tree.addTreeSelectionListener(new DirSelectionListener());

    m_tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    m_tree.setShowsRootHandles(true);
    m_tree.setEditable(false);

    JScrollPane s = new JScrollPane();
    s.getViewport().add(m_tree);
    getContentPane().add(s, BorderLayout.CENTER);

    m_display = new JTextField();
    m_display.setEditable(false);
    getContentPane().add(m_display, BorderLayout.NORTH);

    m_popup = new JPopupMenu();
    m_action = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (m_clickedPath == null)
                return;
            if (m_tree.isExpanded(m_clickedPath))
                m_tree.collapsePath(m_clickedPath);
            else
                m_tree.expandPath(m_clickedPath);
        }
    };
    m_popup.add(m_action);
    m_popup.addSeparator();

    Action a1 = new AbstractAction("Delete") {
        public void actionPerformed(ActionEvent e) {
            m_tree.repaint();
            JOptionPane.showMessageDialog(FileTree3.this, "Delete option is not implemented", "Info",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    };
    m_popup.add(a1);

    Action a2 = new AbstractAction("Rename") {
        public void actionPerformed(ActionEvent e) {
            m_tree.repaint();
            JOptionPane.showMessageDialog(FileTree3.this, "Rename option is not implemented", "Info",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    };
    m_popup.add(a2);
    m_tree.add(m_popup);
    m_tree.addMouseListener(new PopupTrigger());

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);

    setVisible(true);
}

From source file:project16.Home16.java

private void pnl_sidebarMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnl_sidebarMousePressed
    // TODO add your handling code here:
    xx = evt.getX();//from   w  w  w .  j  a  v a2 s.c o  m
    xy = evt.getY();
}