File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Using mouseClicked in swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Using mouseClicked in swing" Watch "Using mouseClicked in swing" New topic

Using mouseClicked in swing

jagan raja
Ranch Hand

Joined: Jan 29, 2010
Posts: 54
I want to move JButton one step to the left , right, up and down when i click on the JButton.

Can any one help me in this?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
generally the parent would be a null layout, and you just change the location with the click
left/right change x, up/down change y
Rob Spoor

Joined: Oct 27, 2005
Posts: 19848

Check out setLocation. But as Michael said, you need a null layout, or the layout manager will ignore the location you set manually.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Using mouseClicked in swing