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:com.sec.ose.osi.ui.frm.main.report.project.JListProjectWithPopup.java

private void initialize() {
    this.addListSelectionListener(new FileSelectionListener());
    this.addMouseListener(new MouseAdapter() {
        @SuppressWarnings("deprecation")
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
                log.debug("JLIstProjectWithPop.mouseClicked() : MouseEvent.BUTTON3");
                /// clicked right button
                mEventHandler.handle(EventHandler.RIGHT_BTN_CLICKED);

                if (JListProjectWithPopup.this.getSelectedValues() != null // existed selected item
                        && JListProjectWithPopup.this.getSelectedValues().length > 0) {
                    log.debug("button3");
                    mPopup.show(e.getComponent(), e.getX(), e.getY());
                }/*  w  ww. jav a 2  s .c  o  m*/
            }
        }
    });
}

From source file:net.sf.xmm.moviemanager.gui.DialogIMDbMultiAdd.java

/**
 * Not yet fully implemented/*from  ww  w .  j av a2 s  . c  o m*/
 * @param e
 */
void handleFileLocationPopup(MouseEvent e) {

    if (!GUIUtil.isRightMouseButton(e))
        return;

    JPopupMenu fileLocationPopup = new JPopupMenu();
    JMenuItem fileLocationItem = new JMenuItem("Open content folder");
    fileLocationPopup.add(fileLocationItem);

    fileLocationPopup.show(fileLocation, e.getX(), e.getY());
}

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

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

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

    setColumnControlVisible(enable);
}

From source file:ScribbleDragAndDrop.java

/**
 * This method, and the following four methods are from the MouseListener
 * interface. If we're in drawing mode, this method handles mouse down
 * events and starts a new scribble./*from  w  w w  .ja  va  2s  .  c om*/
 */
public void mousePressed(MouseEvent e) {
    if (dragMode)
        return;
    currentScribble = new Scribble();
    scribbles.add(currentScribble);
    currentScribble.moveto(e.getX(), e.getY());
}

From source file:com.limegroup.gnutella.gui.tables.ActionIconAndNameEditor.java

public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, int row,
        int column) {
    ActionIconAndNameHolder in = (ActionIconAndNameHolder) value;
    action = in.getAction();/*  w  w w  . j av  a  2  s  . co m*/

    final Component component = new ActionIconAndNameRenderer().getTableCellRendererComponent(table, value,
            isSelected, true, row, column);
    component.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                if (actionRegion == null) {
                    component_mousePressed(e);
                } else {
                    if (actionRegion.contains(e.getPoint())) {
                        component_mousePressed(e);
                    } else {
                        if (e.getClickCount() >= 2) {
                            Toolkit.getDefaultToolkit().getSystemEventQueue()
                                    .postEvent(new MouseEvent(table, MouseEvent.MOUSE_CLICKED, e.getWhen(),
                                            e.getModifiers(), component.getX() + e.getX(),
                                            component.getY() + e.getY(), e.getClickCount(), false));
                        }
                    }
                }
            } else if (e.getButton() == MouseEvent.BUTTON3) {
                Toolkit.getDefaultToolkit().getSystemEventQueue()
                        .postEvent(new MouseEvent(table, e.getID(), e.getWhen(), e.getModifiers(),
                                component.getX() + e.getX(), component.getY() + e.getY(), e.getClickCount(),
                                true));
            }
        }
    });

    return component;
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.AnnotationReportApplet.java

public void mousePressed(MouseEvent e) {
    if (MouseUtils.isPopupTrigger(e)) {
        theCanvas.enforceSelection(e.getPoint());
        createPopupMenu().show(theCanvas, e.getX(), e.getY());
    }/*from   ww  w  .  j a v a2s .  c o m*/
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.AnnotationReportApplet.java

public void mouseReleased(MouseEvent e) {
    if (MouseUtils.isPopupTrigger(e)) {
        theCanvas.enforceSelection(e.getPoint());
        createPopupMenu().show(theCanvas, e.getX(), e.getY());
    }/*from   w ww . j  a  v a 2s.  c o m*/
}

From source file:com.ivli.roim.controls.ChartControl.java

private ValueMarker findMarker(MouseEvent e) {
    final XYPlot plot = getChart().getXYPlot();

    Collection mark = plot.getDomainMarkers(Layer.FOREGROUND);

    if (null == mark || mark.isEmpty())
        return null;

    final double domainX = plot.getDomainAxis().java2DToValue(e.getX(), getScreenDataArea(),
            plot.getDomainAxisEdge());//from ww  w  .  ja  v a 2s .  c om

    final double Epsilon = plot.getDataRange(plot.getDomainAxis()).getLength() * .01d;

    for (Object o : mark) {
        if (o instanceof DomainMarker) {
            //DomainMarker m = (DomainMarker)o;
            double val = ((DomainMarker) o).getValue();
            if (val >= domainX - Epsilon && val <= domainX + Epsilon) {
                //getContentPane().setCursor(new Cursor(Cursor.HAND_CURSOR)); 
                return (ValueMarker) o;
            }
        }
    }
    return null;
}

From source file:javazoom.jlgui.player.amp.playlist.ui.PlaylistUI.java

/**
 * Handle mouse clicks on playlist./*from w w w  . j  ava 2s.  c o  m*/
 * @param evt
 */
protected void handleMouseClick(MouseEvent evt) {
    int x = evt.getX();
    int y = evt.getY();
    ui.getAcPlAddPopup().setVisible(false);
    ui.getAcPlAdd().setVisible(true);
    ui.getAcPlRemovePopup().setVisible(false);
    ui.getAcPlRemove().setVisible(true);
    ui.getAcPlSelectPopup().setVisible(false);
    ui.getAcPlSelect().setVisible(true);
    ui.getAcPlMiscPopup().setVisible(false);
    ui.getAcPlMisc().setVisible(true);
    ui.getAcPlListPopup().setVisible(false);
    ui.getAcPlList().setVisible(true);
    // Check select action
    if (ui.getPlaylistPanel().isInSelectArea(x, y)) {
        int index = getIndex(y);
        if (index != -1) {
            // PopUp
            if (javax.swing.SwingUtilities.isRightMouseButton(evt)) {
                if (fipopup != null)
                    fipopup.show(this, x, y);
            } else {
                PlaylistItem pli = playlist.getItemAt(index);
                if (pli != null) {
                    pli.setSelected(!pli.isSelected());
                    if ((evt.getClickCount() == 2) && (evt.getModifiers() == MouseEvent.BUTTON1_MASK)) {
                        player.pressStop();
                        player.setCurrentSong(pli);
                        playlist.setCursor(index);
                        player.pressStart();
                    }
                }
            }
            repaint();
        }
    }
}

From source file:EventTestPane.java

/**
 * Display mouse events that don't involve mouse motion. The mousemods()
 * method prints modifiers, and is defined below. The other methods return
 * additional information about the mouse event. showLine() displays a line
 * of text in the window. It is defined at the end of this class, along with
 * the paintComponent() method.//w ww  .  j  a v a2 s.  c o  m
 */
public void processMouseEvent(MouseEvent e) {
    String type = null;
    switch (e.getID()) {
    case MouseEvent.MOUSE_PRESSED:
        type = "MOUSE_PRESSED";
        break;
    case MouseEvent.MOUSE_RELEASED:
        type = "MOUSE_RELEASED";
        break;
    case MouseEvent.MOUSE_CLICKED:
        type = "MOUSE_CLICKED";
        break;
    case MouseEvent.MOUSE_ENTERED:
        type = "MOUSE_ENTERED";
        break;
    case MouseEvent.MOUSE_EXITED:
        type = "MOUSE_EXITED";
        break;
    }
    showLine(mousemods(e) + type + ": [" + e.getX() + "," + e.getY() + "] " + "num clicks = "
            + e.getClickCount() + (e.isPopupTrigger() ? "; is popup trigger" : ""));

    // When the mouse enters the component, request keyboard focus so
    // we can receive and respond to keyboard events
    if (e.getID() == MouseEvent.MOUSE_ENTERED)
        requestFocus();
}