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

  • Home
  • SEARCH
  • 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 6849717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:01:40+00:00 2026-05-27T01:01:40+00:00

Well, I’m having this newbie problem right now. I have 3 JFrames. JFrame1 opens

  • 0

Well, I’m having this newbie problem right now.

I have 3 JFrames. JFrame1 opens JFrame2; JFrame2 gets the words and then re-opens JFrame1; JFrame1 opens JFrame3 with the words taken in JFrame2.

The problem I’m having is about the creation of JFrame3. I mean, I know how to go from JFrame2 directly to JFrame3 (via constructor, passing by parameters the words I found). What I’m trying to do is taking the words from JFrame2, putting it in JFrame3, but making this last one invisible (this.setVisible(false)). And then, when I go back to JFrame1, and when I click on a button, it redirects me to JFrame3 with the words from JFrame2. Which I think it’d be something like […].setVisible(true).

What I don’t wanna do is to create a new JFrame3() when I click on the button on JFrame1. Because doing so, I’d lose all the things I got in JFrame2. So, basically, I just want to make the JFrame3 visible again. Without having to create a new one and losing all my stuff.

I hope someone can understand what I’m trying to say and can help me somehow.
Thanks in advance, guys. Sorry for the bad English.

By the way, I’m using Netbeans-Java.

  • 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-27T01:01:41+00:00Added an answer on May 27, 2026 at 1:01 am

    JFrame1 opens JFrame2; JFrame2 gets the words and then re-opens
    JFrame1; JFrame1 opens JFrame3 with the words taken in JFrame2.

    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    
    import javax.swing.*;
    
    public class MultiFrames implements ActionListener
    {
        private JFrame frame1, frame2, frame3;
        private String message;
        private JTextField txtFiled;
        private JButton btn1, btn2;
        private JLabel lbl;
        private boolean flag = false;
    
        private static final String BUTTON1_COMMAND = "btn1";
        private static final String BUTTON2_COMMAND = "btn2";
    
        public MultiFrames()
        {
            frame1 = new JFrame("JFrame #1");
            frame2 = new JFrame("JFrame #2");
            frame3 = new JFrame("JFrame #3");
    
            frame1.setLayout(new FlowLayout());
            frame2.setLayout(new FlowLayout());
            frame3.setLayout(new FlowLayout());
    
            frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame1.setSize(200, 100);
            frame1.setLocationRelativeTo(null);
    
            frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame2.setSize(200, 100);
            frame2.setLocationRelativeTo(null);
    
            frame3.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame3.setSize(200, 100);
            frame3.setLocationRelativeTo(null);
    
            txtFiled = new JTextField(10);
            frame2.add(txtFiled);
    
            lbl = new JLabel();
            frame3.add(lbl);
    
            btn1 = new JButton("Open JFrame #2");
            btn2 = new JButton("Re-Open JFrame #1");
    
            btn1.addActionListener(this);
            btn1.setActionCommand(BUTTON1_COMMAND);
            btn2.addActionListener(this);
            btn2.setActionCommand(BUTTON2_COMMAND);
    
            frame1.add(btn1);
            frame2.add(btn2);
    
            frame1.setVisible(true);
        }
    
        @Override
        public void actionPerformed(ActionEvent e)
        {
            String s = e.getActionCommand();
    
            if(s.equals(BUTTON1_COMMAND))
            {
                if(!flag)
                {
                    frame1.setVisible(false);
                    frame2.setVisible(true);
                    flag = true;
                }
                else
                {
                    frame1.setVisible(false);
                    frame3.setVisible(true);
                    lbl.setText("The word is: " + message);
                }
            }
            else if(s.equals(BUTTON2_COMMAND))
            {
                frame2.setVisible(false);
                frame1.setVisible(true);
                message = txtFiled.getText();
                btn1.setText("Open JFrame #3");
            }
        }
    
        public static void main(String[] args)
        {
            SwingUtilities.invokeLater(new Runnable()
            {
                @Override
                public void run()
                {
                    new MultiFrames();
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well I have a view of this type of hierarchy Main View (having some
Well, this is an interesting problem. I have an ASP.NET MVC3 Intranet application running
Well, this is my first post here and really enjoying the site. I have
well i have this messages table with sample values like these: msg_id recipient_id read
Well..I am learning java now and I am curious to know will this yield
Well, I have this bit of code that is slowing down the program hugely
Well friends, I have got this query which works but is very long for
Well, I have website with such structure of pages: domain.com/group-1/page/ and now I need
Well im here because i have a problem. i have code that was created
Well, I didn't really know how to call this... I have been surfing PayPal's

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.