Good morning CodeCall !

I had before a request of how to create a multiply window function on a frame. Which gives the user ability to open new frames and dispose it without affecting nor freezing the previous window.

So let’s get going !




Packages
Since the user requested a detailed one I will explain it with a bit more heart…
By creating GUI tools, we need to have something that will draw the windows and tools for it. Java presents their own GUI API, swing. The awt presents our Listener functions and the awt.event presents our “event” accordance…

The class
By using extends we inherit every single method from the JFrame class itself. Which residents inside our javax.swing package…Which makes it really neat 😀
Our variables
By creating 2 static integers to keep the track of numbers of window we create we are able to give a future method which I will present soon, which will help us to dispose and open windows with any bother.
The int Nr will present the numbers of window created to our WindowAdapter later on.While creating a JMenuBar, you can add buttons and items to it, you can also just add icons.
Constructor
The constructor is our base frame. Now, every single time we are about to launch a new window, we will use these standards we point out. As well does it add the total numbers of windows as the current windows open. Now comes the part. Why didn’t I use a JFrame instance? Well if I can inherit it instead. Then you don’t need to refer to an instance variable. Just type out the methods and add your components !
Action methods…
Here we have our actions. While pressing New in the JMenuItem inside the Bar. We can launch a new Drawwindow. Hence this is the method of launching a new frame.
While our close is disposing the old ones.
WindowAdapter
Here we have our Window listener. To keep track of our windows we are checking if the totNumbers equals to 0. Making it simple for use to exit without crashing application.
The main
Our main, the heart of launch our application. Which makes it simple to understand we are only launching the method. DrawWindow, the rest is just the windows 🙂

What Do You Think on This ? Say Here