ジャマイカからのご挨拶、
NetBeansJavaプロジェクトで問題が発生しています。MainJFrame.javaというGUIクラスとmain.javaという別のクラスの2つの別々のクラスがあります。
MainJFrameフォームには、jTextFieldとjbuttonがあります。jbuttonをクリックしてjtextfield値をmain.javaクラスに渡すにはどうすればよいですか?
ありがとう。
ジャマイカからのご挨拶、
NetBeansJavaプロジェクトで問題が発生しています。MainJFrame.javaというGUIクラスとmain.javaという別のクラスの2つの別々のクラスがあります。
MainJFrameフォームには、jTextFieldとjbuttonがあります。jbuttonをクリックしてjtextfield値をmain.javaクラスに渡すにはどうすればよいですか?
ありがとう。
one possible solution would be to create a third class which handles the communication.
There you would have to register the main.java and pass it to MainJFrame.java.
For Example
public class handler {
public static main myClass = new main;
public static main getClass() {
retunr myClass;
}
}
Your JFrameMain should containt a new variable
private main mainClass = handler.getClass();
Your onClicklistener should now voi dthe method from your mainClass which gets the text.
mainClass.setText(textFromJText);
Hope i could help you.
ActionListener
JButton に を定義します。JTextField.getText()