我正在处理一个文本框,该文本框将提供有关主题的信息,但是我希望1个长字符串将所有信息存储在其中。我希望将此字符串返回到该框中的“下一行”,我实际上是在尝试在JavaFX中创建一个文本框
答案 0 :(得分:0)
如果您基本上想创建一个TextField
,请尝试以下操作:
Label label1 = new Label("Name:");
TextField textField = new TextField ();
HBox hb = new HBox();
hb.getChildren().addAll(label1, textField);
hb.setSpacing(10);
答案 1 :(得分:0)
所以我做了一些进一步的挖掘,结果发现,我要找的东西叫做“文本区域”
package com.jenkov.javafx.controls;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.TextArea;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class TextAreaExperiments extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("TextArea Experiment 1");
TextArea textArea = new TextArea();
VBox vbox = new VBox(textArea);
Scene scene = new Scene(vbox, 200, 100);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}
的来源