Saturday, 24 August 2013

Java Swing - Changing JLabel.setText of Label changes the location!!! of another label, which is on another JPANEL

Java Swing - Changing JLabel.setText of Label changes the location!!! of
another label, which is on another JPANEL

This is super weird for me! ... here is the thing: I'm working on
university project, My app has several (4) JPanels. Each Panel has
different JComponents (mostly jlabels). I've set a "Parent" for each
JComponent (e.g. the label on my MAP jpanel has "Parent" MAP).
My map panel has 1 label, which I move (with .setLocation) based on ...
different stuff.... The weird thing is that when I change the text
(.setText) of a JLabel, which is located on different jpanel (under the
MAP panel), the location of my MAP label is changed to it's original
one!!! How is that even possible ?! I tried debugging - you must be really
patient for that : )) What I saw is that the location change of my MAP
label happens when my other jpanel label get's repaint()-ed (.setText()
method calls .repaint() at certain point).
So, have you seen something like that, and what is the workaround ?
IDE - netbeans 7.2 Java Swing
Regards, nilux

No comments:

Post a Comment