Click here to Skip to main content
15,745,336 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Sir/Mam i am new in java environment. i have to develop a project based on java swing. i have made a single form using JFrame.but as per the requirement in main frame window there is some tab on opening there should be open new frame window.i have not gotten the idea how to open multiple frame window from main frame window.plz help me someone thanks in advance.

1 solution

You need an architecture.

You application does not need to have a visible JFrame - therefor your application can also have multiple JFrames.

Your Main-class - starting point for the application - needs to trigger a basic application without GUI.

That basic application defines the lifecycle. When it is closed down the application is finished.
The basic application has one major task: it's holding the data, so that different JFrames can access it:

public class Main {

  private static Facade oFacade = new Facade();
  public static void main(String[] args) {

  private static void startGUI() {
    new GUI(oFacade);

  private static void startFacade() {

The concept of a facade is a common pattern in Java development (Wikipedia on facade pattern[^]

public class Facade {

  public void init() {
    // holding data 

public class GUI{
  public GUI(Facade oFacade) {
    // controls JFrames

  // needs to trigger end of lifecycle as the Main-class will not figure it otherwise and life happily forever and on.

That is basically also what an application framework does for you - much richer, much more complex.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900