PDA

View Full Version : Newly added Widget not visible and setVisible, layout(), repaint() not working



pascal.m.
24 Nov 2011, 7:24 AM
Hi everyone,
i am experiencing some strange problems. I have a created a window by extending the Window-class of gxt and added a vertical panel which holds two ContentPanels. One of the ContentPanels holds buttons and other controls and the other is used für displaying widgets, in this case some Charts, but only one of them at a time.

Everything works fine, i load my data and the first chart is displayed automatically, as intended. The problem occurs when i try to switch to another chart: The previous chart is removed as desired, but the new chart is not displayed. I checked the forum and google before posting and found that calling the containers layout()-function might help, but it doesn't.

I even tried repaint() and even setting setVisible(true) explicitly, but again no success.
After that i inserted some Window.alert() messages into my code to see if the other charts exist and which chart was removed and if it was setVisible(true).

The alerts clarified that most of it works fine, the right chart was removed, a new chart added, but the newly added chart is not setVisible(true) (isVisible returns false) even though i set it after it was added.

Here some examples:
Removing the old Chart:


if (lineChartBla.isAttached()) { removed = lineChartBla;
lineChartBla.removeFromParent();
//center.remove(lineChartBla);

} else if (barChartBla.isAttached()) {
removed = barChartBla;
barChartBla.removeFromParent();
//center.remove(barChartBla);

}

Adding a new one:


if (aggregation.equals("day")) { center.add(lineChartBla);
lineChartBla.setVisible(true);
center.layout();
com.google.gwt.user.client.Window.alert(String.valueOf(lineChartBla.isVisible()));


} else {
center.add(monthBlaLine);
monthBlaLine.setVisible(true);
center.layout();
com.google.gwt.user.client.Window.alert(String.valueOf(monthBlaLine.isVisible()));
}

I hope someone can help.

Regards Pascal

Mike_javaJunior
18 Feb 2013, 3:54 AM
maybe it's too simple, but I had such problem when trying to run my project withou recompiling.(I use maven). when I packaged it, everything appeared.