• Post Reply Bookmark Topic Watch Topic
  • New Topic

JButton, setText after setBounds reverts to old size  RSS feed

 
Rich Dulabahn
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok this is a baffling one. What I'm trying to do is to set a JButton's text. No biggie, but I'd like to resize it to the preferred width so I don't get an ellipsis (...) if the text is too long. And I've found a really strange thing. If you setText after setBounds, for whatever reason the setText reverts the button to the original size. Here is a code example.



Click the button once, button resized just like you'd expect. Click it a 2nd time and set the text? BLAMMO. Button reverts to old geometry. I've tried setting preferred size and invalidate and all sorts of hocus-pocus and I just can't get this to work.

Why is this happening? And how do I make it behave?

Thanks,
Rich
 
Rich Dulabahn
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Argh solved it nevermind. Make this change:



And it's ok. Oops! Nevermind.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!