How to check the size of JLabel before show it on the screen in JDialog

 When configuring a JDialog, there are times when you need to check the size of a JLabel.

Even if you set the text after creating a JLabel, its size is not set.


In this case, if you set the dialog panel and then call pack(), the size of the JLabel will be set and you can read the value.

Then, you can create the necessary UI using the read size value and set the panel again.


When a JLabel is placed next to another component, it is used to fit the window size.


No comments:

Lognote - Log viewer, Android logcat viewer for Windows, Linux, Mac

android logcat viewer for Windows, Linux, Mac   https://github.com/cdcsgit/lognote Filtered log viewer Android logcat viewer, kotlin ...