Forums Register Login

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

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
money grubbing section goes here:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


Reply locked
This thread has been viewed 1801 times.
Similar Threads
Fixed Size
TableRenderer with multiple lines of text
Exception in GUI
Resize width only?
same old gridbag
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 02:15:19.