I am attempting to embed a chart into a larger
application built with swing. There is a high-level
JFrame, and within it are several JPanels. In one of
these JPanels, I am trying to display a ChartPanel.
Should it be possible to display a chart in a nested
JPanel, and not just in the highest level component?
One of three things usually happens: either the entire
JFrame reduces down to 0x0 pixels, or it comes up the
usual size but empty. The more interesting behavior is
that it will show up without drawing the chart, but if
I drag the chart off-screen and back on, the chart will
sometimes be partly visible under the panel it is
contained in (i.e. it is being drawn beneath its ancestor).
If I add a repaint() to the Frame's paint() method,
then I can get the chart to display in the proper
place, but once paint() finishes, the application goes
into a busy-wait loop (not updating anymore, and using
100% of the processor).
I can add the ChartPanel to the highest level component
and it draws fine. I can also create a new JFrame and
add it to that, and the new frame will show the chart
perfectly. It is only when I try to embed the chart
into a sub-panel that it fails.