Example usage for java.awt.event MouseEvent getPoint

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

Introduction

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

Prototype

public Point getPoint() 

Source Link

Document

Returns the x,y position of the event relative to the source component.

Usage

From source file:GlassPaneDemo.java

private void redispatchMouseEvent(MouseEvent e, boolean repaint) {
    Point glassPanePoint = e.getPoint();
    Container container = contentPane;
    Point containerPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, contentPane);
    if (containerPoint.y < 0) { // we're not in the content pane
        if (containerPoint.y + menuBar.getHeight() >= 0) {
            // The mouse event is over the menu bar.
            // Could handle specially.
        } else {/*  w w w  .  j a va  2s .c  o m*/
            // The mouse event is over non-system window
            // decorations, such as the ones provided by
            // the Java look and feel.
            // Could handle specially.
        }
    } else {
        // The mouse event is probably over the content pane.
        // Find out exactly which component it's over.
        Component component = SwingUtilities.getDeepestComponentAt(container, containerPoint.x,
                containerPoint.y);

        if ((component != null) && (component.equals(liveButton))) {
            // Forward events over the check box.
            Point componentPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, component);
            component.dispatchEvent(new MouseEvent(component, e.getID(), e.getWhen(), e.getModifiers(),
                    componentPoint.x, componentPoint.y, e.getClickCount(), e.isPopupTrigger()));
        }
    }

    // Update the glass pane if requested.
    if (repaint) {
        glassPane.setPoint(glassPanePoint);
        glassPane.repaint();
    }
}

From source file:it.unibas.spicygui.vista.listener.MyMouseEventListener.java

public void mouseClicked(MouseEvent e) {
    e.consume();//from ww w.  j a va 2 s . c  o  m
    dispacciaEvento(null, e, e.getPoint(), false);
    jLayeredPane.moveToFront(component);
    component.updateUI();
}

From source file:it.unibas.spicygui.vista.listener.MyMouseEventListener.java

public void mouseReleased(MouseEvent e) {
    e.consume();// w  w w .ja  v  a  2 s.  c o m
    dispacciaEvento(null, e, e.getPoint(), false);
    dispacciaEvento(tmp12, e, e.getPoint(), false);

    tmp12 = null;
    jLayeredPane.moveToFront(component);
    component.updateUI();
}

From source file:uk.co.modularaudio.util.audio.gui.patternsequencer.PatternSequenceNoteGridMouseListener.java

@Override
public void mousePressed(final MouseEvent e) {
    //      log.debug("Mouse pressed");
    final Point clickPoint = e.getPoint();
    calculateCellIndexesFromPoint(clickPoint, cellPoint);
    if (!cellPoint.equals(previouslySetCellPoint)) {
        lastNoteChangeWasSet = setNoteForPoint(clickPoint, false);
        previouslySetCellPoint.x = cellPoint.x;
        previouslySetCellPoint.y = cellPoint.y;
    }/*from  w  w  w . j  a  v  a  2 s . com*/
}

From source file:it.unibas.spicygui.vista.listener.MyMouseEventListener.java

public void mouseDragged(MouseEvent e) {
    e.consume();
    dispacciaEventoDrag(tmp12, e, e.getPoint(), true);
    jLayeredPane.moveToFront(component);
}

From source file:StrokeTest.java

public StrokeComponent() {
    addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent event) {
            Point p = event.getPoint();
            for (int i = 0; i < points.length; i++) {
                double x = points[i].getX() - SIZE / 2;
                double y = points[i].getY() - SIZE / 2;
                Rectangle2D r = new Rectangle2D.Double(x, y, SIZE, SIZE);
                if (r.contains(p)) {
                    current = i;/*from  w w w .  ja va 2s  .  c o m*/
                    return;
                }
            }
        }

        public void mouseReleased(MouseEvent event) {
            current = -1;
        }
    });

    addMouseMotionListener(new MouseMotionAdapter() {
        public void mouseDragged(MouseEvent event) {
            if (current == -1)
                return;
            points[current] = event.getPoint();
            repaint();
        }
    });

    points = new Point2D[3];
    points[0] = new Point2D.Double(200, 100);
    points[1] = new Point2D.Double(100, 200);
    points[2] = new Point2D.Double(200, 200);
    current = -1;
    width = 8.0F;
}

From source file:com.original.widget.OPicture.java

/** mouse event processing **/
public void mouseClicked(MouseEvent e) {
    Point pt = e.getPoint();
    Rectangle btnRect = getUI().getBtnRect();
    if (btnRect.contains(pt)) {
        //here, you can make a dialog to select a image file.
        File fil = chooseImgFile();
        if (fil != null) {
            try {
                int ind = fil.getAbsolutePath().lastIndexOf(".");
                if (ind != -1) {
                    this.model.setDataformat(fil.getAbsolutePath().substring(ind + 1));
                    this.model.setDatablock(IOUtils.toByteArray(new FileInputStream(fil)));
                    //_hasImg = true;
                    this.model.setHasdata(true);
                    this.model.setBrwbtntext("?");
                    repaint();//from   w ww  . j av  a2  s  .com
                }
            } catch (IOException ex) {

            }

        }

    }
}

From source file:de.fhg.igd.mapviewer.MapToolPainter.java

private void mouseMove(MouseEvent me) {
    // save mouse position (viewport pixels)
    mousePos = me.getPoint();
    // repaint if necessary
    if (mapTool != null && mapTool.getRenderer() != null && mapTool.getRenderer().repaintOnMouseMove())
        mapViewer.repaint();/*from  www . ja  v a 2  s  .co m*/
}

From source file:uk.co.modularaudio.util.audio.gui.patternsequencer.PatternSequenceNoteGridMouseListener.java

@Override
public void mouseDragged(final MouseEvent e) {
    //      log.debug("Got a drag event " + e.toString() );
    final Point dragPoint = e.getPoint();
    calculateCellIndexesFromPoint(dragPoint, cellPoint);
    if (!cellPoint.equals(previouslySetCellPoint)) {
        //         log.debug("Was for a new cell, will call set note for point");
        setNoteForPoint(dragPoint, true);
        previouslySetCellPoint.x = cellPoint.x;
        previouslySetCellPoint.y = cellPoint.y;
    }/*w ww . ja v  a  2s.c  om*/
}