Avatar of hipal
hipal
Flag for United States of America asked on

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!
Java

Avatar of undefined
Last Comment
alpharom

8/22/2022 - Mon
incerc

ASKER CERTIFIED SOLUTION
Valeri

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
CEHJ

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

With most  layout managers it does this automatically. Which one are you using?
hipal

ASKER
I am not using any layout manager .. in that cas e??
Your help has saved me hundreds of hours of internet surfing.
fblack61
alpharom

try pack() , it will adjust it automatically no ??
Valeri

read my link, it's exactly for buttons places in panel without  any layout manager...
Valeri

@alpharom
JButton doesn't have pack method
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
alpharom

@Valeri
Sorry, i thought it did !!!