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:BezLab.java

public void mouseDragged(MouseEvent e) {
    if (dragIndex == NOT_DRAGGING)
        return;/*  ww w  .  j a v a2  s .  co m*/

    xs[dragIndex] = e.getX();
    ys[dragIndex] = e.getY();
    repaint();
}

From source file:BufferedDraw.java

public void mousePressed(MouseEvent e) {

    last_x = rect.x - e.getX();
    last_y = rect.y - e.getY();//  www  .  j a  va  2s  .  co  m

    // Checks whether or not the cursor is inside of the rectangle while the
    // user is pressing themouse.
    if (rect.contains(e.getX(), e.getY())) {
        updateLocation(e);
    } else {
        pressOut = true;
    }
}

From source file:BufferedDraw.java

public void updateLocation(MouseEvent e) {

    rect.setLocation(last_x + e.getX(), last_y + e.getY());
    repaint();
}

From source file:PopupSample.java

private void showIfPopupTrigger(MouseEvent mouseEvent) {
    if (popup.isPopupTrigger(mouseEvent)) {
        popup.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
    }/*  w  w w  . ja  va 2s.c o m*/
}

From source file:ShapeMover.java

public void mouseReleased(MouseEvent e) {
    if (rect.contains(e.getX(), e.getY()))
        updateLocation(e);// w  ww  .  ja v  a 2s . co m
    else {
        ShapeMover.label.setText("Drag it.");
        pressOut = false;
    }
}

From source file:ShapeMover.java

public void mousePressed(MouseEvent e) {
    preX = rect.x - e.getX();
    preY = rect.y - e.getY();// www  .j a v a  2 s . c  o m

    if (rect.contains(e.getX(), e.getY()))
        updateLocation(e);
    else {
        ShapeMover.label.setText("Drag it.");
        pressOut = true;
    }
}

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

private boolean isIconActive(MouseEvent evt) {
    return icon != null && evt.getX() < icon.getIconWidth();
}

From source file:SwingMouseMotionEventDemo.java

void saySomething(String eventDescription, MouseEvent e) {
    textArea.append(eventDescription + " (" + e.getX() + "," + e.getY() + ")" + " detected on "
            + e.getComponent().getClass().getName() + newline);
    textArea.setCaretPosition(textArea.getDocument().getLength());
}

From source file:Main.java

MyJTree(DefaultMutableTreeNode dmtn) {
    super(dmtn);/*from   w w  w  .  j  av  a2 s .  c  o m*/
    mi.addActionListener(this);
    mi.setActionCommand("insert");
    popup.add(mi);
    mi = new JMenuItem("Remove this node");
    mi.addActionListener(this);
    mi.setActionCommand("remove");
    popup.add(mi);
    addMouseListener(new MouseAdapter() {
        public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
                popup.show((JComponent) e.getSource(), e.getX(), e.getY());
            }
        }
    });

}

From source file:ShapeMover.java

public void updateLocation(MouseEvent e) {
    rect.setLocation(preX + e.getX(), preY + e.getY());

    if (checkRect()) {
        ShapeMover.label.setText(rect.getX() + ", " + rect.getY());
    } else {/* ww  w  . jav a2 s  .c  om*/
        ShapeMover.label.setText("drag inside the area.");
    }

    repaint();
}