Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9223149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:00:23+00:00 2026-06-18T04:00:23+00:00

I am making a Java gui project and it consists of two frames. The

  • 0

I am making a Java gui project and it consists of two frames.

The problem is that when I call the secondframe from the firstframe, I have set it such that the firstframe visibility is set to false. The problem is how do I make the firstframe visible again by using a button from the second frame.

should i ditch this method and create a new jpanel instead??? Does jpanel have similar capabilities as jframe?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:00:24+00:00Added an answer on June 18, 2026 at 4:00 am

    Consider using CardLayout. This way you can switch via multiple UIs without needing another frame. Here’s how to use it.

    Edit: As Guillaume posted in his comment, this answer from Andrew also covers how to use the layout.

    Edit2:
    As you requested a little more information about my latest post, here’s how such a class may look like:

    import javax.swing.JFrame;
    
    
    public abstract class MyFrameManager {
        static private JFrame   startFrame,
                            anotherFrame,
                            justAnotherFrame;
    
    static public synchronized JFrame getStartFrame()
    {
        if(startFrame == null)
        {
            //frame isnt initialized, lets do it
            startFrame = new JFrame();
            startFrame.setSize(42, 42);
            //...
        }
    
        return startFrame;
    }
    
    static public synchronized JFrame getAnotherFrame()
    {
        if(anotherFrame == null)
        {
            //same as above, init it
        }
    
        return anotherFrame;
    }
    
    static public synchronized JFrame getJustAnotherFrame()
    {
        //same again
        return justAnotherFrame;
    }
    
    public static void main(String[] args) {
        //let's test!
    
        JFrame start = MyFrameManager.getStartFrame();
            start.setVisible(true);
    
        //want another window
        JFrame another = MyFrameManager.getAnotherFrame();
            another.setVisible(true);
    
        //oh, doenst want start anymore
        start.setVisible(false);
    }
    }
    

    This way you would only instantiate every JFrame once, but you could always access them via your manager class. What you do with them after that is your decision.
    I also just made it thread-safe, which is crucial for singletons.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a program in Java, using Swing, with a GUI that contains arrow
My problem is that at the moment I am making a GUI for a
Possible Duplicate: Java, GUI builder or hand coding? I have been making GUI hand-coded
I have two designs for an instant message program that I'm writting in Java
I currently have a java file that has buttons to create new GUI windows.
I have a problem on a program I'm making that I honestly can't find
I'm trying to restructure some specific GUI code in a Java project, let's call
I am using Java Netbeans GUI Builder for making GUI. I want to give
I am making a GUI of Stack using Java. Here is my code private
I am making a GUI for a Java application. What I am trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.