I am trying to set the padding for my GridPane, but every time I set the padding it gives me the error message:
incompatible types: java.awt.Insets cannot be converted to javafx.geometry.insets
Every website I go to and every search states to implement it like this:
grid.setPadding(new Insets(10, 10, 10, 10));
And in my code I have it set exactly the same just for testing purposes :
grid.setPadding(new Insets(10, 10, 10, 10));
So I don't understand why it won't allow me to write that, I have also tried to research the error message but nothing comes up.
Here is my code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package myrectangle2d;
import java.awt.Insets;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
/**
*
* @author macuser
*/
public class Exercise18_29 extends Application {
Stage window;
Label label1, label2, centerXL, centerXR;
TextField textCenterXL, textCenterXR;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
window = primaryStage;
window.setTitle("Triangles");
GridPane grid = new GridPane();
grid.setPadding(new Insets(10, 10, 10, 10));
label1 = new Label("Do the Triangles match");
GridPane.setConstraints(label1, 0, 0);
label2 = new Label("Yes or no");
GridPane.setConstraints(label2, 1, 0);
centerXL = new Label("Center X LEFT");
GridPane.setConstraints(centerXL, 0, 5);
textCenterXL = new TextField();
GridPane.setConstraints(textCenterXL, 1, 5);
centerXR = new Label("Center X RIGHT");
GridPane.setConstraints(centerXL, 0, 5);
textCenterXR = new TextField();
GridPane.setConstraints(textCenterXR, 3, 5);
grid.getChildren().addAll(label1, label2, centerXL, textCenterXL, centerXR, textCenterXR);
Scene scene = new Scene(grid, 400, 600);
window.setScene(scene);
window.show();
}
}