Since experimenting suggested that using one of the tool bar actions causes the map to appear I tried manually calling JMapPane.reset() after adding layers.
This was not working. Firther experiments suggested that it is a timing related issue. If I make my thread wait 3 second (less may be OK too) before calling reset() then all is well and map appears.

Any idea what is going on and how to do this better?

On 04/11/2013 02:36 PM, Farrukh Najmi wrote:

I am using org.geotools.swing.JMapPane within a custom JDialog class that is modeled after the org.geotools.swing.JMapFrame class.
I am observing that the JMapPane does not paint its layers (no map or other features are visible and all we see is a blank area) the first time the dialog is displayed. Then if I do any of the following the JMapPane displays its layers:

I realize that I have extended the original code and could have broken something in the process.
But I was wondering if anyone familiar with the code can suggest what the cause might be. Any debugging tips would be terrific.

On a related note, what is the recommended way to trigger a refresh on the JMapPane after I dynamically add layers (with FeatureCollection) to the MapContent .

Thanks very much.

Farrukh Najmi