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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:45:19+00:00 2026-05-29T05:45:19+00:00

I do accept that this is a dumb question to many of you! First

  • 0

I do accept that this is a dumb question to many of you! First of all i want to say that my java knowledge is low as far as graphical user interface is concerned! I have a problem with textFields. I want to get the value of one JTextField object and display it in another JTextField object!This is what i tried but it is not working!

       textField2.setText(textField1.getText());

The problem is that i have two frames objects and each has a textField object and i want to copy one value from jTextField1 of jFrame1 to jTextField2 of jFrame2 .

  • 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-29T05:45:20+00:00Added an answer on May 29, 2026 at 5:45 am

    The question is valid, the amount of information that you provide is not. There’s no way to help you til you tell enough details so that we can understand what’s wrong.

    Putting my mind-reading hat on though, I am going to guess that your problem is that you make this method call above on program start up, and expect that if you update one JTextField, the other will be updated automatically, but that’s not so. When you make this call:

    textField2.setText(textField1.getText());
    

    All you’re doing is placing the String held in the first field into the second field. On program start up, this may be null, but even if it contained text, the String is immutable and will never change, even if the 1st field’s text changes.

    If you want one field to always hold the same text as the other, have them share the same model:

    textField2.setDocument(textField1.getDocument()); // * edited per mKorbel's rec
    

    If your goal on the other hand is to get the text from one JTextField and put it into another but only when the user chooses to do this, then use an ActionListener that is added to either a JButton or to the first JTextfield itself (which is activated by pressing enter while the caret is in the field), and in that listener, place your line of code:

    textField2.setText(textField1.getText());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to Java programming language so this is probably dumb question but
This seems like a bug to me... I accept that automatic properties, defined as
In *nix many command line applications that accept file names as arguments accept pipes
In Java is there anyway to have one constructor that will accept an array
hi I found on the Internet that this regexp accept positive number ^\d+$ and
I want to create a method that will accept a UIButton, UIImageView, or any
Sorry, but I know nothing at all about fonts, so I hope that this
So I have this calculator I'm building that accepts user variable inputs like let
(r'^/(?P<the_param>[a-zA-z0-9_-]+)/$','myproject.myapp.views.myview'), How can I change this so that the_param accepts a URL(encoded) as a
On Linux, the readlink utility accepts an option -f that follows additional links. This

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.