Search code examples
javaeclipse-rcpjfreechartorder-of-execution

Difference between "m_Frame.add(chartPanel); m_Frame.validate()" and "m_Frame.add(chartPanel).validate();" using jfreechart


I am migrating an Eclipse RCP applilcation from Eclipse 3.0 to 4.4 and I have a class in which I create a java.awt.Frame m_Frame and a ChartPanel chartPanel using jfreechart (jfreechart-1.0.15.jar, jcommom-1.0.18.jar).

The code originally looks like this:

...

m_Frame.add(chartPanel);
m_Frame.validate();

In Eclipse RCP 3.0 this worked without problems. Now, the application just gets stuck if I am trying to create a chart.

But if I change it to this:

...
m_Frame.add(chartPanel).validate();

it works fine. I I ditch the validation entirely or validate m_Frame before the ChartPanel is added or use doLayout() it works fine.

Can somebody explain the difference between these two approaches?

I am using Eclipse RCP 4.4 and JDK 1.8.0_60


Solution

  • The solution was to use the method doLayout() instead of validate(), which did the job just fine.