Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
クラス A 内にリスナーがあり、クラス A をリスナー内のクラス B に渡したいと考えています。通常はこれを使用しますが、リスナーをトリガーしたイベントを取得します。
A.this.
A.this
(内部クラスthisが有用であることはめったにありません。実際、間違った使い方をするとバグが発生することは比較的一般的thisです。したがって、それがデフォルトであることは残念です。12 年後に変更されることはありません。)
this
リスナーのコンストラクターでクラス A への参照を追加できます。
class_a_obj.addActionLister(new ActionListener(class_a_obj) { ...