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.

Recommended Answers

All 2 Replies

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;

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.