I have a JTextField. If I type something in it, I need to save that instantaneously. I have an addActionListener event linked to it, which saves the changes only if I press "ENTER" after typing something to it.
After the suggestions, I made the following changes in my code. I need to call addActionListener, but I am not sure how would I
mMaxLabelLength = new JTextField();
mMaxLabelLength.getDocument().addDocumentListener(this);
public void changedUpdate(DocumentEvent e)
{
System.out.println("1");
mMaxLabelLength.addActionListener(this);
}
public void removeUpdate(DocumentEvent e)
{
System.out.println("2");
mMaxLabelLength.addActionListener(this);
}
public void insertUpdate(DocumentEvent e)
{
System.out.println("3");
mMaxLabelLength.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
// do something
}