Display a string in a text field that is locked for editing

Asked

Viewed 64 times

-1

I have developed a client-server chat and I am incrementing some functions to make it more presentable and complete. One thing I still don’t know how to do is display a string within a text field.

As soon as I run the program, I ask the user to enter his name in the dialog field and store it in a string.

inserir a descrição da imagem aqui

I would like this string to be shown in a text field (below the chat photo and the respective field where I want the String name to be shown).

inserir a descrição da imagem aqui

  • Provide a code that is a [mcve], so it will be possible for anyone to run and test.

  • I just want to know how to display a string in a Text Field. No need to post all the code as the rest is functional.

1 answer

0


You did not provide a Minimum, Complete and Verifiable Example, but in the tests I did, there was no problem using settext() to define the text of JTextField, even if it’s blocked for editing:

inserir a descrição da imagem aqui

The fact that the field is locked for editing or even disabled does not prevent it from being inserted/changed/deleted text in it, as long as it is done programmatically.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.