Attach JTextField with String property

O

oziris

Hi,

I would like to bind a JTextField with a String in such a way that an
update of JTextField content results in a modification of the String.

Actually it's no more no less than ui-model relation. I searched
around JTextField(Document) constructor, PlainDocument...

Thanks a lot.

-o
 
V

visionset

oziris said:
Hi,

I would like to bind a JTextField with a String in such a way that an
update of JTextField content results in a modification of the String.

Actually it's no more no less than ui-model relation. I searched
around JTextField(Document) constructor, PlainDocument...

Since Strings are immutable that would be impossible.
Perhaps if you elaborate on your end goal, an alternative solution could be
suggested.
You probably just need to add a DocumentListener to the JTextFields
Document.
 
K

~kurt

oziris said:
I would like to bind a JTextField with a String in such a way that an
update of JTextField content results in a modification of the String.

Actually it's no more no less than ui-model relation. I searched
around JTextField(Document) constructor, PlainDocument...

Would overriding the JTextField's createDefaultModel() method to
return your own version of a PlainDocument object work? The PlainDocument
could be initialized with a class that contains whatever needs to be
modified (say, what the String points to).

- Kurt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top