I use PropertyChangeListener
for JTextFields
to listen for value change, and it works normally, and when I use it with JTextArea
; no errors in the code and it is compiled normally. However this method shows response when some change occur in a JTextField
text value but no response when it comes to JTextArea
.
This is how I wrote the code
Inside the constructor:
textField_1.addPropertyChangeListener("value", new ChangeListener());
textField_2.addPropertyChangeListener("value", new ChangeListener());
textArea.addPropertyChangeListener("value", new ChangeListener());
And somewhere inside the class:
private class ChangeListener implements PropertyChangeListener
{
@Override
public void propertyChange(PropertyChangeEvent e)
{
Object source = e.getSource();
if ((source == textField_1) || (source == textField_2) || (source == textArea))
{
System.out.println("some value changed "+ source.getClass());
}
}
}
I use new value each time I make a change to these compomemts text value.
THanks
use DocumentListener for listening of changes in JTextArea
from this Listener you can to fire a new event to PropertyChangeListener
fire a new event to PropertyChangeListener
only in the case thats required, no idea from this description, for better help sooner post an SSCCE
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.