Example usage for java.awt.event MouseEvent getX

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

Introduction

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

Prototype

public int getX() 

Source Link

Document

Returns the horizontal x position of the event relative to the source component.

Usage

From source file:ObjectInspector.java

@Override
public String getToolTipText(MouseEvent me) {
    TreePath pathForLocation = getPathForLocation(me.getX(), me.getY());

    if (pathForLocation != null) {
        Object lastPathComponent = pathForLocation.getLastPathComponent();
        if (lastPathComponent instanceof ObjectNode) {
            ObjectNode on = (ObjectNode) lastPathComponent;

            return on.tooltip;
        }/*from  w w  w .j  av a 2  s .c  o m*/
    }

    return null;
}

From source file:au.org.ala.delta.editor.ui.CharacterTree.java

@Override
public String getToolTipText(MouseEvent event) {
    TreePath path = getClosestPathForLocation(event.getX(), event.getY());
    if (path != null) {
        Object node = path.getLastPathComponent();
        if (node instanceof CharacterTreeNode) {
            CharacterTreeNode chNode = (CharacterTreeNode) node;
            String desc = chNode.getCharacter().getDescription();
            int width = getGraphics().getFontMetrics(getFont()).stringWidth(desc);
            if (width > getParent().getWidth() - 70) {
                if (width > 400) {
                    return String.format("<html><body style=\"width: %dpx;\">%s</body></html>", 400,
                            StringEscapeUtils.escapeHtml(desc));
                } else {
                    return desc;
                }/*from   w w w.  j  ava 2 s  .com*/
            }
        }
    }
    return null;
}

From source file:com.cmsoftware.keyron.vista.Login.java

private void panelContenidoMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_panelContenidoMousePressed
    yAnterior = evt.getY();/*from   w  ww .  ja v a  2 s .  c o  m*/
    xAnterior = evt.getX();
    this.setCursor(new Cursor(Cursor.MOVE_CURSOR));
}

From source file:com.projity.pm.graphic.graph.GraphInteractor.java

public void mouseMoved(MouseEvent e) {
    if (isReadOnly())
        return;
    select(e.getX(), e.getY());
}

From source file:de.tbuchloh.kiskis.gui.widgets.PasswordElement.java

private void initCreatePopup() {
    _pwdCreateMenu = new JPopupMenu();
    final JMenuItem secure = new JMenuItem(M.getString("secure_item")); //$NON-NLS-1$
    secure.addActionListener(new PasswordActionListener(PasswordFactory.SECURE));
    _pwdCreateMenu.add(secure);// ww  w . j a  v a 2 s  . co m

    final JMenuItem human = new JMenuItem(M.getString("human_readable_item")); //$NON-NLS-1$
    human.addActionListener(new PasswordActionListener(PasswordFactory.HUMAN_READABLE));
    _pwdCreateMenu.add(human);

    final JMenuItem template = new JMenuItem(M.createAction(this, "onCreateByTemplate"));
    _pwdCreateMenu.add(template);

    _specialActionsMenu = new JPopupMenu();
    _specialActionsMenu.add(M.createAction(this, "onCopyToClipboard"));

    _pwdField.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(final MouseEvent e) {
            if (e.getButton() != MouseEvent.BUTTON3) {
                return;
            }
            final int x = e.getX(); // _pwdField.getWidth()
            // - _specialActionsMenu.getWidth();
            final int y = e.getY();

            LOG.debug("Show context menu x=" + x + ", y=" + y);
            _specialActionsMenu.show(_pwdField, x, y);
        }
    });
}

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:eu.europa.esig.dss.applet.view.validationpolicy.EditView.java

private void registerMouseListener(final JTree tree) {

    MouseListener mouseAdapter = new MouseAdapter() {
        @Override//from w w  w  .ja  va  2  s  .  co m
        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: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();
    xy = evt.getY();/*w w  w  . j  a va 2 s.  co m*/
}

From source file:com.rapidminer.gui.plotter.charts.ChartPanelShiftController.java

@Override
public void mouseDragged(MouseEvent mouseEvent) {
    if (!mouseEvent.isControlDown()) {
        return;/*from  w ww.  j a v  a 2  s.  c o  m*/
    }

    if (oldx > -1 && oldy > -1) {
        int xdif = mouseEvent.getX() - oldx;
        int ydif = mouseEvent.getY() - oldy;

        final Rectangle2D scaledDataArea = chartPanel.getScreenDataArea();

        ValueAxis[] domAxes = getPlotAxis(chartPanel.getChart(), !axesSwaped);
        if (domAxes != null) {
            double[] xDelta = new double[domAxes.length];
            for (int i = 0; i < domAxes.length; i++) {
                xDelta[i] = xdif * domAxes[i].getRange().getLength() / (scaledDataArea.getWidth());
            }
            for (int i = 0; i < domAxes.length; i++) {
                domAxes[i].setRange(domAxes[i].getLowerBound() - xDelta[i],
                        domAxes[i].getUpperBound() - xDelta[i]);
            }
        }

        ValueAxis[] rngAxes = getPlotAxis(chartPanel.getChart(), axesSwaped);
        if (rngAxes != null) {
            double[] yDelta = new double[rngAxes.length];
            for (int i = 0; i < rngAxes.length; i++) {
                yDelta[i] = ydif * rngAxes[i].getRange().getLength() / (scaledDataArea.getHeight());
            }
            if (!onlyXShift) {
                for (int i = 0; i < rngAxes.length; i++) {
                    rngAxes[i].setRange(rngAxes[i].getLowerBound() + yDelta[i],
                            rngAxes[i].getUpperBound() + yDelta[i]);
                }
            }
        }
    }

    oldx = mouseEvent.getX();
    oldy = mouseEvent.getY();
}

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());
                    }/*from   w  ww .jav a  2  s.co  m*/
                }
            };

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

    setColumnControlVisible(enabled);
}