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

-1

I developed a client-server chat and I'm adding some functions to make it more presentable and complete. One thing I still do not know how to do is display a string inside a text field.

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

Iwouldlikethisstringtobedisplayedinatextfield(belowthechatphotoanditsfieldwhereIwanttheStringnametobeshown).

    
asked by anonymous 16.09.2018 / 22:22

1 answer

0

You did not provide a Minimum, Full and Verifiable example , but in the tests I did, there was no problem using < a href="https://docs.oracle.com/javase/9/docs/api/javax/swing/text/JTextComponent.html#setText-java.lang.String-"> settext() for set the text of JTextField , even if it is locked for editing:

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

    
16.09.2018 / 22:55