private VBox addVBox() {
VBox vb1 = new VBox();
vb1.setPadding(new Insets(40, 40, 20, 40));
vb1.setSpacing(20);
vb1.setStyle("-fx-background-color: #333333;");
TextField txt1 = new TextField();
txt1.setPromptText("Class Number");
txt1.setPrefSize(70, 30);
Button b1 = new Button("DELETE");
b1.setFont(Font.font("Calibri", FontWeight.BOLD, 17));
b1.setPrefSize(100, 30);
b1.setStyle(" -fx-base: #ffffff;");
b1.setTextFill(Color.BLACK);
vb1.getChildren().addAll( txt1, b1);
return vb1;
}
This is my code. The setPromptText () function works in it, but the specified text content is not displayed. This is due to the fact that when the program starts, the text field is the first control in it, and when the window opens, the text field will be selected and therefore it does not display the invitation text. How can I make the tooltip text visible when opening a window?
source
share