Hi,
I'm using JFreeReport in my application. I shows a special chart during my program run time.
The problem is: When I close the chart window (JfreeCharts' window), it closes my main program window also. (The program main window have been made with JFRame).
How can I control the close command on my chart window (jfreechart's produced window).
Thanks in advence,
Payam
here is the code:
........
rs = exploreDB ("SELECT * FROM myTable");
Pie3DChart demo = new Pie3DChart("Test");
demo.Pie3DChartPreview(chartTitle,rs);
demo.pack();
demo.setVisible(true);
..
...
---------------------------
and the Class Declaration:
public class Pie3DChart extends ApplicationFrame {
/**
* Default constructor.
*/
public Pie3DChart(String title) {
super(title);
}
public void Pie3DChartPreview(String title,ResultSet rs) {
//int i=0;
boolean more;
// create a dataset...
DefaultPieDataset data = new DefaultPieDataset();
try {
more = rs.next();
if (!more) {
System.out.println("No rows found.");
return;
}
// Loop through the rows retrieved from the query
while (more) {
data.setValue(rs.getString(1), new Double(rs.getDouble(2)));
//i++;
rs.next();
}
}
catch (SQLException e) {
System.out.println(" results where found.");
}
// create the chart...
JFreeChart chart = ChartFactory.createPie3DChart(title, // chart title
data, // data
true // include legend
);
// set the background color for the chart...
chart.setBackgroundPaint(Color.lightGray);
// add the chart to a panel...
ChartPanel chartPanel = new ChartPanel(chart);
this.setContentPane(chartPanel);
}
jfreechart close my application main window
Re: jfreechart close my application main window
First I had the same problem.
I just changed
public class Chart extends AplicationFrame
into
I just changed
public class Chart extends AplicationFrame
into
Re: jfreechart close my application main window
(sorry, i hit the post-button accidantly)
...
into
public class Chart extends JFrame
and in th chart-class-method
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
Now, everything should work fine.
...
into
public class Chart extends JFrame
and in th chart-class-method
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
Now, everything should work fine.
Re: jfreechart close my application main window
Most of the demo applications extend ApplicationFrame to provide the behaviour of closing down completely upon exit. It is not intended that you use ApplicatioFrame within your own applications, just create a ChartPanel and add it to whatever container you want to use.
Regards,
DG.
Regards,
DG.