FileDocCategorySizeDatePackage
MoveMouseListener.javaAPI DocExample1678Mon Jan 09 11:01:58 GMT 2006None

MoveMouseListener

public class MoveMouseListener extends Object implements MouseListener, MouseMotionListener

Fields Summary
JComponent
target
Point
start_drag
Point
start_loc
Constructors Summary
public MoveMouseListener(JComponent target)

        this.target = target;
    
Methods Summary
public static javax.swing.JFramegetFrame(java.awt.Container target)

        if(target instanceof JFrame) {
            return (JFrame)target;
        }
        return getFrame(target.getParent());
    
java.awt.PointgetScreenLocation(java.awt.event.MouseEvent e)

        Point cursor = e.getPoint();
        Point target_location = this.target.getLocationOnScreen();
        return new Point(
            (int)(target_location.getX()+cursor.getX()),
            (int)(target_location.getY()+cursor.getY()));
    
public voidmouseClicked(java.awt.event.MouseEvent e)

public voidmouseDragged(java.awt.event.MouseEvent e)

        Point current = this.getScreenLocation(e);
        Point offset = new Point(
            (int)current.getX()-(int)start_drag.getX(),
            (int)current.getY()-(int)start_drag.getY());
        JFrame frame = this.getFrame(target);
        Point new_location = new Point(
            (int)(this.start_loc.getX()+offset.getX()),
            (int)(this.start_loc.getY()+offset.getY()));
        frame.setLocation(new_location);
    
public voidmouseEntered(java.awt.event.MouseEvent e)

public voidmouseExited(java.awt.event.MouseEvent e)

public voidmouseMoved(java.awt.event.MouseEvent e)

public voidmousePressed(java.awt.event.MouseEvent e)

        this.start_drag = this.getScreenLocation(e);
        this.start_loc = this.getFrame(this.target).getLocation();
    
public voidmouseReleased(java.awt.event.MouseEvent e)