I have 2 lists displayed vertically in a JFrame. Lets say list A is an ArrayList<CustomTexField>
and list B is an ArrayList<JLabel>
.
I want to "update" the elements of list B that matches the same index of elements inside list A with the value from the CustomTextField
.
I've tried adding document listener, but don't know how to calculate the index.
@Override
public void insertUpdate(DocumentEvent e) {
try {
listB().get(INDEX).setText(e.getDocument().getText(0, e.getDocument().getLength()) + "");
} catch (BadLocationException e1) {
e1.printStackTrace();
}
}
I have also created a method inside CustomTexField
class that saves the index when its created but don't know how to 'read' it from e.getDocument()
EDIT: UPDATED TITLE