About
Pricing
Community
Teams
Start Free Trial
Log in
hipal
asked on
11/11/2010
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
8
1
Last Comment
alpharom
8/22/2022 - Mon
incerc
11/11/2010
Hi,
Do you use a LayoutManager class?
Please take a look at this :
http://download.oracle.com/javase/1.4.2/docs/api/java/awt/FlowLayout.html
http://download.oracle.com/javase/tutorial/uiswing/layout/using.html
ASKER CERTIFIED SOLUTION
Valeri
11/11/2010
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
11/11/2010
>> 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
11/11/2010
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
11/11/2010
try pack() , it will adjust it automatically no ??
Valeri
11/11/2010
read my link, it's exactly for buttons places in panel without any layout manager...
Valeri
11/11/2010
@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
11/11/2010
@Valeri
Sorry, i thought it did !!!
Do you use a LayoutManager class?
Please take a look at this :
http://download.oracle.com/javase/1.4.2/docs/api/java/awt/FlowLayout.html
http://download.oracle.com/javase/tutorial/uiswing/layout/using.html