Create an 8 pixel margin around a listview in the stackpane
import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.ListView; import javafx.scene.layout.StackPane; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage stage) { Group group = new Group(); Scene scene = new Scene(group); StackPane stackpane = new StackPane(); // Create an 8 pixel margin around a listview in the stackpane ListView list = new ListView(); StackPane.setMargin(list, new Insets(8,8,8,8)); stackpane.getChildren().add(list); group.getChildren().add(stackpane); stage.setTitle("Welcome to JavaFX!"); stage.setScene(scene); stage.sizeToScene(); stage.show(); } public static void main(String[] args) { Application.launch(args); } }