FileDocCategorySizeDatePackage
MoveButton.javaAPI DocExample741Sat Apr 23 22:35:40 BST 2005None

MoveButton

public class MoveButton extends JPanel

Fields Summary
JButton
button
Constructors Summary
public MoveButton()


    
    setLayout(null);
    add(button);
    button.setSize(button.getPreferredSize());
    button.setLocation(20, 20);
    addMouseListener(new MouseAdapter() {
      public void mousePressed(MouseEvent e) {
      button.setLocation(e.getX(), e.getY());
      }
    });
  
Methods Summary
public static voidmain(java.lang.String[] args)

    JFrame frame = new JFrame("MoveButton");
    frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    frame.setSize(250, 200);
    frame.setLocation(200, 200);
    frame.setContentPane(new MoveButton());
    frame.setVisible(true);