jfreechart
jfreechart copied to clipboard
Not possible to set a menu bar in two different windows with the same chart instance
Good afternoon I have been using it to show some XYSeries, to select which one should be shown and which one hide I used a menu bar with select boxes. It works fine when I have it only in a view, but...
When I have tried to open it in two views at same time (because belong a different parts of the APP) the second one doesn't show the menu bar, doesn't matter what I tried, different frame, add the same bar with Listeners again, whatever I Tried didn't work. The point to use the same Chart Instance is due to keep mvc structure and keep update in one window what is selected in the other one and so on.
In the second view it doesn't show the menu bar.
Using:
- JDK 11
- JFreeChart 1.5.3
- GNU/Linux OS (but problem remains in any other OS).
- AWT and Swing components to work with
.
As shown here, "a component can only exist in one parent at a time."
That is for Java 8, I am using JDK 11, that could have same issue, but... If it were like that said... how is possible I share the same chart in two different places? Same goes about another components that I share along my aplications.
Or it is only for JMenuItems components and with JFreeChart due to it is based on JDK 8?
The single parent rule is not version specific, for example. The exact solution will depend on your use-case, but you should be able to construct a new ChartPanel
from your JFreeChart
.