Pergunta

I'm coming from .net world, but I have to make a small GUI application in Java. I would like to achieve that I have a class with some properties and I want to bind the properties to swing components (textfield, combo box) on a JDialog, JFrame.

There are many threads in the net talking about this, but I was not able to achieve the stuff to be working on my case. I have a class with a property PropertyChangeSupport, and addPropertyChangeListener and removePropertyChangeListener methods. In the GUI I could bind the JTextField text attribute to the class instance property. the JDialog is implementing the PropertyChangeListener

but if I write something to the text box nothing is updating in the class property.

Can you point me a complete tutorial about this issue?

thanks!

Foi útil?

Solução

"but if I write something to the text box nothing is updating in the class property."

You're probably going to want to implement a DocumentListener to listen for changes in the underlying document of the text field. Every time the document changes, for instance the typing in of a letter, a DocumentEvent will be fired. You can see How to Write a DocumentListener

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top