Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

dynamically change the position of Button on a panel  RSS feed

 
muktesh tripathi
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want a simple button to be displayed ..but on clicking it or by any other event I want it to be redrawn at some other coordinates..i.e it should it change its position....I dont want to draw many hidden buttons all over the panel and play with their visibility attribute..
Please help
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out
By manipulating the first two parameters you can move the same button where ever you wish.
Don't forget to call the revalidate() and repaint() on the parent container after you move though!
 
Brian Cole
Author
Ranch Hand
Posts: 932
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:Check out
By manipulating the first two parameters you can move the same button where ever you wish.
Don't forget to call the revalidate() and repaint() on the parent container after you move though!


But if you're using one of the standard layout managers than the revalidate() will eventually cause
the layout manager to set the bounds back to where it had been, so set the layout manager to null.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian Cole wrote:
Maneesh Godbole wrote:Check out
By manipulating the first two parameters you can move the same button where ever you wish.
Don't forget to call the revalidate() and repaint() on the parent container after you move though!


But if you're using one of the standard layout managers than the revalidate() will eventually cause
the layout manager to set the bounds back to where it had been, so set the layout manager to null.


Absolutely.
But as the OP had mentioned "co-ordinates" I presumed it was null layout already.
BTW, I really liked the use-cases you cited in the button right click thread. I had missed out on some of them. Fantastic analysis! I picked up a few tips there. Thank you
 
muktesh tripathi
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks your answers were of really great help..I was not using null layoutManager and that was creating problems as I was using netbeans ide to create the application..thanks again.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!