【问题标题】:How to create textAreas in javaFX如何在 javaFX 中创建 textAreas
【发布时间】:2019-11-08 22:52:16
【问题描述】:

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

【问题讨论】:

  • 你在尝试时遇到了什么问题?

标签: java javafx text restriction


【解决方案1】:

于是我又进行了一些挖掘,结果发现,我正在寻找的东西被称为“文本区域”

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

【讨论】:

    【解决方案2】:

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

    Label label1 = new Label("Name:");
    
    TextField textField = new TextField ();
    
    HBox hb = new HBox();
    
    hb.getChildren().addAll(label1, textField);
    
    hb.setSpacing(10);
    

    【讨论】:

      猜你喜欢
      • 2017-10-07
      • 1970-01-01
      • 2013-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-23
      • 2014-11-05
      • 1970-01-01
      相关资源
      最近更新 更多