|
From: Liu, L. \(Exchange\) <LL...@Be...> - 2004-11-15 15:23:37
|
Hi, Nathaniel:
I have a JFrame which holds several JPanels. One of these JPanels holds
another JPanel (variable name jPanel_Graph) and this one displays my
axisChart. I used the following code to show the chart and now wondering
what is the right way to repaint the graph.=20
...
axisChart.setGraphics2D((Graphics2D)jPanel_Graph.getGraphics());
axisChart.render();
...
In order to ensure that the chart is repainted when it was hidden or
resized, I overrode the JFrame (the top parent)'s paint() method as
follows:
Public void paint(Graphics graphics){
Super.paint(graphics);
try{
=20
axisChart.setGraphics2D((Graphics2D)jPanel_Graph.getGraphics());
axisChart.render();
}
...
}
The above code works for purpose of repainting the graph but when other
controls on frame needs repainting (such as combobox selection change),
the chart was redrawn too unnecessarily. And this made the graph redraw
itself so often and caused visual discomfort.=20
My question is: for a chart that renders itself on a JPanel which is
part of JFrame, how to make sure that the chart is repainted only when
needed? Can you suggest another way ?
Thanks,
Louis
***********************************************************************
Bear Stearns is not responsible for any recommendation, solicitation,
offer or agreement or any information about any transaction, customer
account or account activity contained in this communication.
***********************************************************************
|