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

public void mouseReleased(MouseEvent e) {
    if (rect.contains(e.getX(), e.getY()))
        updateLocation(e);/* w w w .j  a v a2 s. c  o m*/
    else {
        ShapeMover.label.setText("Drag it.");
        pressOut = false;
    }
}

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());
    }//from   w  w w  . j  a v  a 2 s.  c o m
}

From source file:Main.java

MyJTree(DefaultMutableTreeNode dmtn) {
    super(dmtn);/*  ww w.  ja  v a 2  s.  co 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:BezLab.java

public void mouseReleased(MouseEvent e) {
    if (dragIndex == NOT_DRAGGING)
        return;// w w  w  .ja v a2  s .  c om
    xs[dragIndex] = e.getX();
    ys[dragIndex] = e.getY();
    dragIndex = NOT_DRAGGING;
    repaint();
}

From source file:BezLab.java

public void mouseDragged(MouseEvent e) {
    if (dragIndex == NOT_DRAGGING)
        return;/*  www  .jav  a2 s  .  co m*/

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

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: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 {//from  ww w . j a v a 2 s  .  c  o m
        ShapeMover.label.setText("drag inside the area.");
    }

    repaint();
}

From source file:BufferedDraw.java

public void mousePressed(MouseEvent e) {

    last_x = rect.x - e.getX();//from w ww.java2 s.co m
    last_y = rect.y - e.getY();

    // 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:Main.java

public Main(JTree jt) {
    super();//  w ww .  j av  a2s. co  m
    tree = jt;
    getContentPane().add(tree);
    tree.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent event) {
            if (((event.getModifiers() & InputEvent.BUTTON3_MASK) != 0) && (tree.getSelectionCount() > 0)) {
                showMenu(event.getX(), event.getY());
            }
        }
    });
}