Hi there, Is there any way to resize a JLabel to fit it's text? I'm adding several JLabels to a GridBagLayout, but they have a standard size (which is too large). I could manually resize them all, but it would be much nicer if there was some kind of method I could invoke on them (then changing the labels text would not mean more experimenting with label sizes)... Tnx!
Post your code for where you are adding the JLabels to the container with GridBagLayout. The constraints you have set for the GridBagLayout are mainly what is affecting the size of the JLabels in this case.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Joined: Mar 12, 2004
I've got several labels with a gridx=0, but a different gridy. None of these labels are as large as the width of that 'column'... I also got a JTable spanning several 'rows' and 'columns' in the GridBagLayout.. I don't know if he havs something to do with it.. Check out this view... the red lines show the 'columns' I defined... I could do an entire listing of the code, but there are quite a few objects in this pane.. view tnx!