小编Imp*_*ion的帖子

文本字段中的新行

我试图在我的 TextField 中有一些预定义的文本,但我不知道如何在单词之间添加新行。我试过\n,但它不起作用。

代码:

    package view;

import javafx.scene.text.Text;

public class Overview extends VBox{

    private TextField info;

    public Overview() {

        //Adds a little border around the app so the text field doesn't go to the edges
        this.setPadding(new Insets(30, 30, 30, 30));

        //----- Initialising text field --------
        info = new TextField("Name:\n" + "PNumber:\n"+ "Email:\n"+ "Date:\n"+ "Course:\n"+ ""+ "Selected Modules:\n"+ "==============");
        info.setAlignment(Pos.TOP_LEFT);
        info.setMinHeight(850);
        info.setEditable(false);


        //------ Adding the text to the Text Field --------


        //-------- Putting it into VBox so that it stretches with …
Run Code Online (Sandbox Code Playgroud)

java javafx javafx-8

2
推荐指数
1
解决办法
4130
查看次数

标签 统计

java ×1

javafx ×1

javafx-8 ×1