Java Problem: JLabel text messages overlap

Discussion in 'Mac Programming' started by wrldwzrd89, Jun 10, 2007.

  1. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #1
    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:
     
  2. toddburch macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #2
    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
     
  3. wrldwzrd89 thread starter macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #3
    That doesn't help, nor does removing it, recreating it, then adding it again.
     
  4. wrldwzrd89 thread starter macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #4
    Found the cause. The JLabel needed to have its opaque property set to true.
     
  5. toddburch macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas

Share This Page