Vikram
Vikram

Reputation: 4096

JavaFX: Not able to put Label inside of GridPane

I am trying to put a Label inside of GridPane in JavaFX.

I have following code:

@FXML
private Label nameCheck;

@FXML 
private GridPane gridPane;

gridPane.add(nameCheck, 0, 0);

But, when I am trying to do so, it is giving me error saying: The method add(Node, int, int) in the type GridPane is not applicable for the arguments (Label, int, int)

When I tried to put Text inside of GridPane, it happens properly. Why is it giving me problem with Label only?

Isn't Label a Node?

Upvotes: 1

Views: 4185

Answers (1)

Salah Eddine Taouririt
Salah Eddine Taouririt

Reputation: 26405

Are you sure that you are not using java.awt.Label instead of javafx.scene.control.Label ? And yes Label is Node.

enter image description here

Upvotes: 4

Related Questions