繁体   English   中英

如何在javaFX中创建textAreas

[英]How to create textAreas in javaFX

我正在处理一个文本框,它将提供有关其中一个主题的信息,但我希望 1 个长字符串将所有信息存储在其中。 我希望将此字符串返回到该框中的“下一行”,我实际上是在尝试在 JavaFX 中创建一个文本框

如果您基本上是想创建一个TextField尝试以下操作:

Label label1 = new Label("Name:");

TextField textField = new TextField ();

HBox hb = new HBox();

hb.getChildren().addAll(label1, textField);

hb.setSpacing(10);

所以我做了更多的挖掘,结果我正在寻找的东西叫做“文本区域”

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);
    }
}

来源: http : //tutorials.jenkov.com/javafx/textarea.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM