【问题标题】:Align a label with textarea将标签与 textarea 对齐
【发布时间】:2017-09-17 16:28:03
【问题描述】:

如何对齐“说明”标签的位置,使其与“输入说明”文本 (Label - TextArea) 一致。这些组件位于 gridPane 中并在 javaFX 中编码(因此这里没有 Scene Builder 提示可以帮助我)。 代码:

Label descriptionLabel = new Label("Description:");
descriptionLabel.setPadding(new Insets(5, 5, 5, 5));
JFXTextArea descriptionTextArea = new JFXTextArea();
descriptionTextArea.setPadding(new Insets(5, 0, 5, 0));
descriptionTextArea.setPromptText("Enter description...");
gridPane.add(descriptionLabel, 0, 2);
gridPane.add(descriptionTextArea, 1, 2);

我试过descriptionLabel.setAlignment(Pos.TOP_LEFT);,但都没有帮助我

【问题讨论】:

    标签: javafx label textarea javafx-2 gridpane


    【解决方案1】:

    您必须使用GridPane 约束。 Valignment 设置为 TopHalignment 设置为 RightJava Doc

    GridPane.setHalignment(descriptionLabel, HPos.RIGHT);
    GridPane.setValignment(descriptionLabel, VPos.TOP);
    

    再看你的照片,我想你只需要setValignment

    【讨论】:

      猜你喜欢
      • 2013-10-31
      • 1970-01-01
      • 1970-01-01
      • 2021-11-02
      • 2018-03-11
      • 1970-01-01
      • 1970-01-01
      • 2016-10-08
      • 2013-01-05
      相关资源
      最近更新 更多