I have a problem about close jfreechart frame.

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
bnakorn
Posts: 1
Joined: Wed Oct 05, 2011 3:18 pm
antibot: No, of course not.

I have a problem about close jfreechart frame.

Post by bnakorn » Wed Oct 05, 2011 3:34 pm

I was develope my application by netbean. My application is setdefaultcloseoperation EXIT_ON_CLOSE. My application call jfreechart as a child frame when jfreechart activate, I close it but my application will close too. I want close the child but i did not close my application. How I do? Where I set the close operation for the child? this is my code that call the child jfreechart
" Timeseries_two demo = new Timeseries_two("กราฟแสดงการเปรียบเทียบหุ้น");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);

"
i add this to the code but it not effect. "demo.setDefaultCloseOperation(DISPOSE_ON_CLOSE); "
Please, help me.... thank you

bhogsett
Posts: 1
Joined: Sun Dec 04, 2011 11:50 am
antibot: No, of course not.

Re: I have a problem about close jfreechart frame.

Post by bhogsett » Sun Dec 04, 2011 11:56 am

I am new to jfreechart and also need to close the chart and not exit the application that called the chart.

Like the original poster, I think DISPOSE_ON_CLOSE needs to be the default close operation, but I don't see how to tell the frame (using the modified demo bar chart for testing).

Any help would be appreciated.

Bill

mkrauskopf
Posts: 31
Joined: Thu May 27, 2010 4:23 pm
antibot: No, of course not.

Re: I have a problem about close jfreechart frame.

Post by mkrauskopf » Tue Dec 06, 2011 10:47 am

#setDefaultCloseOperation is a method of a JFrame not a method of your application. So you need to call:

Code: Select all

mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
.....
childFrame.setDefaultCloseOperation(WindowConstant.DISPOSE_ON_CLOSE);
like bhogsett suggested. You are likely setting EXIT_ON_CLOSE for both of your frames.

Cheers,
- m

Locked