• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using mouseClicked in swing

 
jagan raja
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20608
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out setLocation. But as Michael said, you need a null layout, or the layout manager will ignore the location you set manually.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic