How to set padding between columns of a JavaFX GridPane?
java, javafx
Solution
For better appearance you can use a mix of:
grid.setHgap(10); //horizontal gap in pixels => that's what you are asking for
grid.setVgap(10); //vertical gap in pixels
grid.setPadding(new Insets(10, 10, 10, 10)); //margins around the whole grid
//(top/right/bottom/left)
Problem
I'm trying to show a 2-column grid in a javaFx program. This is how I'm setting up the grid: ``` GridPane grid = new GridPane(); ColumnConstraints column1 = new ColumnConstraints(); column1.setPercentWidth(50); ColumnConstraints column2 = new ColumnConstraints(); column2.setPercentWidth(50); grid.getColumnConstraints().addAll(column1, column2); ``` Here's the problem. I want to show a small space between where one column ends, and the other starts. However, the columns are showing up as glued to one another. Here's a screenshot: Here each column contains the 'item name' and 'process, edit, delete' buttons. You can see how the columns are glued together. I want them to instead have some space between them. How can I solve this? The hierarchy of my overall UI is this: Scene > ScrollPane > BorderPane > Vbox (Center) > GridPane