You are correct, there is no getSource()
like some other listeners but you can use Document class's putProperty()
and getProperty()
to achieve what you are looking for.
you can do
JTextField jTextField = new JTextField("Text 1");
jTextField.getDocument().putProperty("parent", jTextField);
and
later in DocumentListener's events, you can get the parent like this
JTextField textField = (JTextField) e.getDocument().getProperty("parent");
where e is DocumentEvent
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…