将标签与textarea对齐

时间:2017-09-17 16:28:04

标签: javafx label textarea javafx-2 gridpane

如何调整我的"描述"的位置?标签使其符合"输入说明"文字(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);,但这对我没有帮助

1 个答案:

答案 0 :(得分:1)

您必须使用Gson约束。 GridPane设置为ValignmentTop设置为HalignmentJava Doc

Right

再次查看你的图片后,我认为你只需要GridPane.setHalignment(descriptionLabel, HPos.RIGHT); GridPane.setValignment(descriptionLabel, VPos.TOP);

相关问题