FileDocCategorySizeDatePackage
MoveButton.javaAPI DocExample813Mon May 01 14:42:00 BST 2000None

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 f = new JFrame("MoveButton");
    f.addWindowListener(new WindowAdapter(  ) {
      public void windowClosing(WindowEvent e) { System.exit(0); }
    });
    f.setSize(250, 200);
    f.setLocation(200, 200);
    f.setContentPane(new MoveButton(  ));
    f.setVisible(true);