Solved

setting the JButton length according to text displayed

Posted on 2010-11-11
8
365 Views
Last Modified: 2012-05-10
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!
0
Comment
Question by:hipal
8 Comments
 
LVL 4

Expert Comment

by:incerc
ID: 34112427
0
 
LVL 16

Accepted Solution

by:
Valeri earned 500 total points
ID: 34112650
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34112835
>> 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:hipal
ID: 34113536
I am not using any layout manager .. in that cas e??
0
 
LVL 3

Expert Comment

by:alpharom
ID: 34113709
try pack() , it will adjust it automatically no ??
0
 
LVL 16

Expert Comment

by:Valeri
ID: 34113710
read my link, it's exactly for buttons places in panel without  any layout manager...
0
 
LVL 16

Expert Comment

by:Valeri
ID: 34113725
@alpharom
JButton doesn't have pack method
0
 
LVL 3

Expert Comment

by:alpharom
ID: 34113739
@Valeri
Sorry, i thought it did !!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question