PDA

View Full Version : Java Problem: JLabel text messages overlap




wrldwzrd89
Jun 10, 2007, 10:43 AM
For some reason, when I call setText multiple times on the same JLabel, the messages overlap one another and become unreadable. The first message displays just fine, but subsequent messages don't.

I've tried overwriting the current message with spaces before displaying a new message, calling invalidate() then validate(), and calling repaint(). None of those helped. :confused:



toddburch
Jun 10, 2007, 01:40 PM
Have you tried removing the JLabel from your panel/frame first before updating it? (Not just setting it to nulls or all blanks, but actually removing it and re-adding it)

Todd

wrldwzrd89
Jun 10, 2007, 02:23 PM
Have you tried removing the JLabel from your panel/frame first before updating it? (Not just setting it to nulls or all blanks, but actually removing it and re-adding it)

Todd
That doesn't help, nor does removing it, recreating it, then adding it again.

wrldwzrd89
Jun 10, 2007, 02:52 PM
Found the cause. The JLabel needed to have its opaque property set to true.

toddburch
Jun 10, 2007, 07:22 PM
Good for you - you found the answer!