If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Instanciating an application in an application

Hi,

I'm having trouble with java applications. I'm hoping that some-one can help me with my program.
I read in the beginning that stupid questions are OK here, so I'm realy at ease to ask this question now ...

I know that java is multi-threading and multi-tasking and I've had a basic java training, so I can understand some of the more difficult things in java. I want to make an AWT application with a menubar. In that menubar is a button with "NEW" as label. The user should be able to instanciate this application again, lets say open it again. I've got it working like this:

import java.awt.*;
import java.awt.event.*;

public class Application1 extends Frame{
// declarations go here
public static void main(String[] args){
new Application1();
}
public Application1(){
// stuff in the program goes here
}
// other stuf goes here, like handlers for the menu
}
// end of program

Now I've got an windowhandler so when you click on the close button that the window will close.
And then I've got the "NEW" button like this:

So the program makes another instance of the CLASS, and I can do this multiple times while they all interact with the user seperately. So I would say its all OK. But when I press the close button, then it closes all of the windows ...
I also get only one dos-window, while I need to have as many as there are instances.

Can some-one save me from my misery? And explain to me what I did wrong and what I did do with this instruction (this instruction must do something, but its not what I hoped). And maybe give the solution to my problem as well.

But I have apsolutely no experience with SWING. Is there a way to do this with AWT? I thought about counting the amount of windows in an array or vector, and thus keeping track of the windows. When the user closes an particular window than the application could maybe look up in what window the close button is pressed and delete that one out of the vector and close that window. But I don't realy know how to program this ... if it is possible.

Or is it possible to open (instantiate) a different application by klicking on a button in an application? And how can I do this if it is possible.
I would also want to have popups in my application, and with AWT it isn't realy possible. But with this way it could be possible, just open another application ... ... ??

The usage of this application is not very important or life-saving . It's just for fun, I was trying to make a game.

I already taught myself how to use cardlayout to make this game. The main idea after this is to keep my knowledge of java up to date. The previous semester I had an exam of java, but I like java so much that I don't want to let it go.

But swing is another matter ... when we had to make an application for the first time, we started in AWT and when it was finished we could make a swing application. The AWT application was fairly easy, but when I started at the SWING application I was confused. Everything had another name, almost all of the things started with a "J", ... And we didn't get any information or lesson or exam about it, we had to look it up, use it one time and that was it. I didn't finish that application either. It looked so complicated!

So this means that i should get rid of my fears and get cracking at that swing application anyways ... if i want to finish this game?