import com.sun.javafx.runtime.VersionInfo; import javafx.application.Application; import javafx.application.Platform; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.VBox; import javafx.scene.text.Font; import javafx.stage.Stage; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; public class ButtonTestWithInsets extends Application { private ScheduledExecutorService service = Executors.newScheduledThreadPool(1); @Override public void start(Stage stage) throws Exception { final VBox root = new VBox(20); root.getStyleClass().add("root"); Scene scene = new Scene(root, 400, 500); scene.getStylesheets().add(getClass().getResource("custom_font.css").toExternalForm()); Font.loadFont(getClass().getResourceAsStream("arialw7.ttf"), 12); Button b1 = new Button("First line\nSecond line\nThird line"); b1.setStyle("-fx-border-color:red blue green black;-fx-border-width:1 3 5 1;-fx-border-style:dotted;-fx-border-insets: 5;"); root.getChildren().addAll(new Button("First line\nSecond line\nThird line"), b1); service.schedule(new Runnable() { @Override public void run() { Platform.runLater(new Runnable() { @Override public void run() { Button b2 = new Button("First line\nSecond line\nThird line"); root.getChildren().add(b2); } }); } }, 5, TimeUnit.SECONDS); service.schedule(new Runnable() { @Override public void run() { Platform.runLater(new Runnable() { @Override public void run() { Button b2 = (Button) root.getChildren().get(2); b2.setStyle("-fx-border-color:red blue green black;-fx-border-width:1 5 5 10;-fx-border-style:dotted;-fx-border-insets: 5;"); } }); } }, 6, TimeUnit.SECONDS); stage.setScene(scene); stage.show(); stage.setTitle(VersionInfo.getRuntimeVersion()); } public static void main(String[] args) { launch(args); } }