setting the JButton length according to text displayed

How can I set the JButton length according to text displayed ?

Using setSize() I have to everytime adjust it according to want I want as text on button.

thanks!
hipalAsked:
Who is Participating?
 
incercCommented:
0
 
CEHJCommented:
>> How can I set the JButton length according to text displayed ?

With most  layout managers it does this automatically. Which one are you using?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
hipalAuthor Commented:
I am not using any layout manager .. in that cas e??
0
 
alpharomCommented:
try pack() , it will adjust it automatically no ??
0
 
ValeriCommented:
read my link, it's exactly for buttons places in panel without  any layout manager...
0
 
ValeriCommented:
@alpharom
JButton doesn't have pack method
0
 
alpharomCommented:
@Valeri
Sorry, i thought it did !!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.