Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

setting the JButton length according to text displayed

Posted on 2010-11-11
8
364 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
session migration servlets 2 42
ForLoop Example 3 53
Java string replace 11 54
jboss 7.1 start up error 1 40
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…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This video teaches viewers about errors in exception handling.

828 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