Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: All
Sep 16, 1999

Dynamically Resize Your JLabels

There is a simple way to resize your javax.swing.JLabels to the text they display.
For an instance of javax.swing.JLabel called jLabel1, if there is not Layout Manager installed :
 
        jLabel1.setText ("A somewaht long message I would not want to
stop");
        jLabel1.setSize(jLabel1.getPreferredSize());

If a Layout Manager:

 
        jLabel1.setText ("A somewaht long message I would not want to
stop");
        jLabel1.validate();

Behrouz Fallahi
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap