我有一个简单的程序,沿着“Hello World”,使用getText()
检索两个textFields的内容并将它们打印到控制台。这很好。
我有一个TextArea定义我想显示输出。我已经尝试了我发现的所有内容,但是我遇到了各种错误,试图让答案适应我的代码,所以请原谅我。
我真正感激的是有人只是为了告诉我如何解释为什么你的答案在我努力学习的过程中取得了成功。
主要方法: -
public class JavaFXApplication2 extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("gui.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}//end start method
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}//end main
}//end class
我的控制器
public class guiController implements Initializable {
//@FXML private Label label;
@FXML private TextField tf1;
@FXML private TextField tf2;
@FXML private TextArea ta; //want to display responses here
@FXML
private void handleButtonAction(ActionEvent event) {
System.out.println("IP Address " + tf1.getText() + " " + "Password: " + tf2.getText());
}//end event handler
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}//end init method
}//end class
简单来说,我希望System.out.println("");
的结果显示在我的文字区域“ta”中。
感谢您的时间。
答案 0 :(得分:0)
使用:
Set rs = Nothing