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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:49:43+00:00 2026-06-16T19:49:43+00:00

I am wondering how you can change something in a parent window using a

  • 0

I am wondering how you can change something in a parent window using a child window. So, let’s say I have a window, that opens a pop-up window on the press of a button. That new window contains a JTextArea and another button called Ok. How can I change the title of the parent window based on what’s inside the JTextArea when the Ok button is pressed?

  • 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-16T19:49:44+00:00Added an answer on June 16, 2026 at 7:49 pm

    The way I see it, there are two common ways to do this:

    • The child window could push the information into the parent window when OK is pressed. For this to occur, the child window would need a reference to the parent window and then call a public method of the parent.
    • The parent window could pull the information from the child. This can occur in one of two ways.
      • If the child window is a modal dialog, then the parent could simply query the child window once the dialog has been dealt with and program flow returns to the parent’s code.
      • If the dialog is a non-modal dialog, then the parent window would need to add a listener to the child, say a PropertyChangeListener, and when the appropriate event is triggered by this listener, the parent window would query the dialog window for the information. This would be an example of using the Observer design pattern.

    I much prefer the pull technique since because it is the parent that is the object that has code to display the child window and that needs the information from the child window, it should have the code to extract the information needed, and the child window would need to have no knowledge of or reference to the parent window object. This seems much cleaner to me.

    For an example of this, please check out my code here, here and here.

    Edit: Note that for the example that you described, you could easily solve this by using a JOptionPane. Many don’t know that JOptionPanes can display very complex GUI’s; basically anything that can be put onto a JPanel can be displayed in a JOptionPane (and then some). You would simply display the JOptionPane that shows your JTextField, and when program flow returns to the calling program, simply get the text held by the JTextField that was displayed in the JOptionPane. Nothing could be simpler.

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

Sidebar

Related Questions

Wondering how I can change the php session id from PHPSESSID to something else
I have a class that is generated by some tool, therefore I can't change
I am wondering if I can change the value of io.sort.mb per job? I
I was wondering how does Nike website make the change you can see when
I'm new to JQuery and was wondering how can I have Changes saved! displayed
I was wondering how can I do something similar to Facebook when a link
I was wondering how can I generate the following array using ranges in ruby
i was wondering how i can make my app display that notification number next
I was wondering how I can change the theme of an activity depending on
I've been working a project using isotope and I must have changed something because

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.