The following example code repeatedly adds and removes a JMap from a JFrame. At first the JMap shows without issue but it throws an Excetpion when trying to add a map for a second time. (java.lang.RuntimeException: Failed to create map context.)
The code included works fine when adding and removing regular swing components you can make the sample application work with a JButton instead by setting the button boolean at the top of the class to true. I believe this shows that the code *should* be fundamentally sound in its approach.
Would anyone be able to shed any light on why we are seeing an exception when doing this?
PS: The solution cannot be to keep a reference to a single map and just hide and show it I am specifically looking to delete and recreate the map every time.