Click here to Skip to main content
12,404,895 members (70,063 online)
Rate this:
Please Sign up or sign in to vote.
See more: Java Swing
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.
Posted 9-Sep-12 7:44am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 10 Sep 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100