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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:28:29+00:00 2026-06-10T13:28:29+00:00

I have been using the function getText() to read user Input in MyJTextField Until

  • 0

I have been using the function getText() to read user Input in MyJTextField Until I have noticed that this does Not Look Possible with Disabled JTextField.

JTextField jtx = new JTextField();
jtx.setText("TEST");
jtx.setEnabled(false);
String str = jtx.getText();
System.out.println(str);

This does not return Anything and I am begining to think that it is because of the Disabled JTextField. Is there a Way to get Text From a Disabled JTextField or Should I just:

jtx.setEditable(false);

I do not want to do this. I want the field to be disabled.

  • 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-10T13:28:30+00:00Added an answer on June 10, 2026 at 1:28 pm

    The code below works as expected (prints TEST whether the text field is enabled or disabled) – are you running your code in the EDT?

    public static void main(String[] args) throws InterruptedException {
        Runnable r = new Runnable() {
            @Override
            public void run() {
                JTextField jtx = new JTextField();
                jtx.setText("TEST");
                System.out.println("Before: " + jtx.getText());
                jtx.setEnabled(false);
                System.out.println("After: " + jtx.getText());
            }
        };
        SwingUtilities.invokeLater(r);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have been using this function in Delphi 2006, but now with D2010
I have been using for a long time a C function that calculates the
I have been using this function for a while without a problem, although I
I have been using this: http://blog.leahculver.com/2010/12/iphone-pull-to-refresh.html to make the pull to refresh function in
I have some strings that have been encrypted using the PHP function crypt() .
I am porting an Oracle function into Postgres PGPLSQL.. I have been using this
Basically I have been using this function to achieve cross domain JSONP but part
I have been using this method for a while now having initially not put
Hey, so i have been using this function in every project or page i
I have been using this code here: $(document).ready(function(){ $('a[href*=#]').bind('click', function(){ var $href = $(this).attr('href')

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.