Solved

setting the JButton length according to text displayed

Posted on 2010-11-11
8
363 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
allswap challenge 6 96
couple of eclipse 5 36
servlet example 11 40
by zero exception 10 39
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

776 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