jzbakos jzbakos - 4 years ago 122
Java Question

setBounds value for width that will set width to minimum?

Is there a value that can be put into setBounds to set the width to the minimum needed?

JLabel title = new JLabel("Title Text");
title.setBounds(50, 20, ?, 13);

Rather than using guess & check to find the minimum width, is there a value I can use?

Answer Source

If you already know the text that will be in the JLabel (i.e., if that text won't change after being assigned once), there is no need to set the minimum width; the JLabel should do so automatically.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download