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 7517019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:18:51+00:00 2026-05-30T01:18:51+00:00

I have a main jFrame with the help of which i press button and

  • 0

I have a main jFrame with the help of which i press button and open new JFrames but the problem is that when i open other JFrame the previous ones still remains there where as what i want is that when i press next button then i move forward to the new JFrame (the previous one should not be there) and when i press previous button i move back to the previous JFrame.

I know there are functions of dispose,they do well like jframe1.dispose() but i dont get it how to hide the very first JFrame whose code in the main is written like this

    public static void main(String args[]) {


    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() 
          {          
           new GraphicalInterface().setVisible(true);
          }
       });
     }

how do i set this as .setVisible(false) in the button code?

  • 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-05-30T01:18:52+00:00Added an answer on May 30, 2026 at 1:18 am

    You need to retain a reference to the JFrame, so you can set it’s visibility later.

    private JFrame myFrame;
    
    public void run() {
      myFrame = new GUI();
      myFrame.setVisible(true);
    }
    
    public void hide() {
      myFrame.setVisible(false);
    }
    

    Note that a JFrame is a top-level container, you are only really supposed to have one per application. It may be better if instead of using multiple JFrames you use just one, and swap in various JPanels instead.

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

Sidebar

Related Questions

I have a main JFrame. There is a button inside the frame. When I
I have a frame on which i have created a main panel. On that
I have main table called 'Employee' and another slave table called 'EmployeeTypes' that has
i have main activity in which i have Four menus. and i have one
I have a JFrame which has 3 JPanels in GridBagLayout .. Now, when I
This is my code I have developed. This is the main program which holds
I have a basic GUI (plain Jframe with a button) and I have changed
I am having a bit of problem regarding Swing. I have a JFrame called
I have created a text field component with an 'x' button inside that will
Ok. I have a mainframe which contains two containers. One contains my wizard-alike buttons

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.