Originally posted by Dave Donohoe:
Does anyone know if there is a way to allow the user of a Java Application to move components like buttons around the screen ?
Dear Dave,
Here is a working code.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class MoveAhead extends
Applet implements MouseMotionListener
{
Label lbl = new Label ("Hello World");
public void init()
{
add(lbl);
addMouseMotionListener(this);
}
public void mouseDragged(MouseEvent e)
{
lbl.setLocation(e.getX(), e.getY());
}
public void mouseMoved(MouseEvent e)
{
lbl.setLocation(e.getX(), e.getY());
}
}