closing frame

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
T
Posts: 4
Joined: Wed Mar 02, 2005 4:20 pm

closing frame

Post by T » Wed Mar 30, 2005 4:28 pm

Hey,

I have created an application that produces multiple charts. I want to close individual charts without exiting the program. i have tried overriding the default...

setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
(i'm not sure if thats exactly right but you get wat i mean)

I was just wondering if something is stopping me overriding. i think my code is right as it works for a window created without any Jfreechart.
Any advice would be much appreciated.

T

vcardona
Posts: 10
Joined: Tue Mar 29, 2005 9:31 pm

Post by vcardona » Wed Mar 30, 2005 5:22 pm

I'm not sure I understand what you are asking, so the stuff below might not apply.

ChartFrame is just a subclass of JFrame. Its constructor sets the default close operation to dispose(). That should only destroy that particular frame. So unless it was the last frame still open your application will still be running.

In anycase, there is nothing in ChartFrame that should stop you from changing the default close operation.

I hope that helps.

Guest

Post by Guest » Wed Mar 30, 2005 5:36 pm

I think the default operation is to EXIT_ON_CLOSE. if i don't specify the setDefaultClo.... and i press the x the whole application closes.

When i run my application i prompt the user for inputs using textfields and buttons and such. When the user presses a button a graph appears. The user can then push a different button and a different graph will appear... and so on allowing alot of graphs to be generated.

When the x in the corner of the frame is pressed on any graph the application crashes... i'd like to override this so that just the graph wished to be closed is disposed and the application keeps running. I've tried overriding it but there is no response. I'm just a bit puzzled thats all.

vcardona
Posts: 10
Joined: Tue Mar 29, 2005 9:31 pm

Post by vcardona » Wed Mar 30, 2005 6:08 pm

OK, well what version are you using? I know that at least since 0.9.21 the default operation is DISPOSE_ON_CLOSE. In anycase, there is nothing stopping you from changing that.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Wed Mar 30, 2005 11:16 pm

Maybe you are using ApplicationFrame (as in the demos) rather than ChartFrame? The best idea is just to create a ChartPanel and embed that in your own JFrames...
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked