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!

有帮助吗?

解决方案

"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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top