私は2つのクラスを持っています:
- クラス
X
にはメソッドが含まれていますlistObjects();
- class
Y
は GUI クラスで、ボタン リストが含まれています。
私が欲しいのは、クラスのボタンリストがクリックされるたびに、クラスのY
メソッドが実行され、出力が という txtfield に表示されることです。listObjects();
X
txtfieldList
ボタンリストの下のクラスに次のコードを含めました
X x = new X (); // create an instance of the class X in the GUI class
txtfieldList.setText(x.list()); // execute the method list from class X and display the output in the tstfield
しかし、私が得ているエラーは次のとおりです。
タイプ JTextComponent のメソッド setText(string) は、引数 (void) には適用できません
間違いがどこにあるかを理解するのに役立つ人はいますか?