I am trying to display the gridlines of a GridPane Scene in JavaFX, but they aren't being displayed despite calling setGridLinesVisible(true)
. What am I doing wrong?
I want to display the gridlines on my program's main menu, so I can tell where to place nodes on it. Unfortunately, when I run the program all that is displayed is a blank screen with a single button.
My MainMenu Class:
package screens;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
/**
* Creates the main menu Pane object and returns it.
* @author LuminousNutria
*/
public class MainMenu {
public MainMenu() {}
public Pane getPane() {
GridPane grid = new GridPane();
grid.setGridLinesVisible(true);
Button bttn = new Button("button");
grid.add(bttn, 2, 2);
return grid;
}
}
My Main Class:
package mainPackage;
import screens.*;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
/**
* Displays the Pane.
* @author LuminousNutria
*/
public class Main extends Application {
// create main menu Pane
private Pane mainMenu = new MainMenu().getPane();
// create Scene
private Scene scene = new Scene(mainMenu, 1600, 900);
@Override
public void start(Stage stage) {
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}