0

hi guys

i like to open as many frames user wants to open, i mean they can keep clicking the button and i like new frame keep opening. so this is something i got, now i know i have to use int to keep track of how many frames are open and when they are closing.

int openFrams;
Frame newFrame= new Frame("quiz");

openFrams = newFrame;

will that work i tried that but gave me some errors about newFrame is not int so what can i do to make this work. any hint will be appreciated, thank you.

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by brianlevine
0

hi guys

i like to open as many frames user wants to open, i mean they can keep clicking the button and i like new frame keep opening. so this is something i got, now i know i have to use int to keep track of how many frames are open and when they are closing.

int openFrams;
Frame newFrame= new Frame("quiz");

openFrams = newFrame;

will that work i tried that but gave me some errors about newFrame is not int so what can i do to make this work. any hint will be appreciated, thank you.

nope, this will most certainly not work. as the errors you received allready stated, it is a Frame-Object, not a numerical value (corresponding to an int).
'm not really sure why you want to keep track of how many frames you're opening, but you might try this:

int openFrams = 0;

...
// next line must be added to the action where you open a new Frame

openFrams += 1;
0

You should look into the WindowAdapter class. It has a windowClosed method that you can override to keep track of when a window is closing.

You'll need to subclass WindowApater and then add an instance of the class as a windowlistener to each of the Frames you create.

Hope that makes sense.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.