1つのJTextAreaにファイルパスを含む入力文字列を取得し、そのコンテンツを2番目のJTextAreaにロードするプログラムがあります。問題は、JTextAreaを使用しているときに、このフィールドを離れるときに2番目のJTextAreaにコンテンツをロードするactionListenerを追加できないことです。この問題を回避する方法は?
protected JTextArea inputField, outputField;
public Main(){
super(new BorderLayout());
inputField = new JTextArea(5, 20);
outputField = new JTextArea(2, 20);
//inputField.addActionListener(this);
inputField.setEditable(false);
JScrollPane scroller2 = new JScrollPane(inputField);
JScrollPane scroller1 = new JScrollPane(outputField);
this.add(scroller1, BorderLayout.WEST);
this.add(scroller2, BorderLayout.EAST);
}
public void actionPerformed(ActionEvent evt) {
String text = inputField.getText();
(loading contents of file)
}