This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Using mouseClicked in swing" Watch "Using mouseClicked in swing" New topic
Author

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
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

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


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
wood burning stoves
 
subject: Using mouseClicked in swing
 
Similar Threads
BoxLayout
Key Events firing for non displayed controls
what layouts to use
Using swing for board game.
Can I distinguish JButtons?