Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

How to calculate size of JLabel and resize it depending on its text?  RSS feed

 
Ranch Hand
Posts: 514
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hello!

I am doing my own tooltip like that for eclipse doc.
For this I use JDialog which has child JLabel wrapped inside JScrollPane.
Of course as user moves cursor I need to change text of JLabel.
The most important is that I want JLabel and JDialog to have just enough size to accomodate text only.

The problem for me is how to calculate and resize JDialog with JLabel so that jDialog is large enough to accomodate text of jlabel.

I guess I need to calculate size of JLabel using its text . But I do not know how to do that and also how to resize JDialog dynamically.
 
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Report post to moderator
Closing this thread as a duplicate of http://www.coderanch.com/t/619051/GUI/java/JLabel-size-accomodate-text
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!