import javafx.application.Application; import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.*; import javafx.scene.control.*; import javafx.scene.layout.*; import javafx.stage.Stage; public class CSSBackgroundRenderingBug extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { final EventHandler EXIT_HANDLER = new EventHandler() { @Override public void handle(ActionEvent event) { Platform.exit(); } }; HBox layout = new HBox(10); layout.getChildren().addAll( closeButton(EXIT_HANDLER), closeButton(EXIT_HANDLER), closeButton(EXIT_HANDLER) ); layout.getStylesheets().add(this.getClass().getResource("roundbutton.css").toExternalForm()); primaryStage.setScene(new Scene(layout)); primaryStage.show(); } private Node closeButton(EventHandler actionHandler) { Button button = new Button(); button.getStyleClass().add("closebutton"); button.setOnAction(actionHandler); button.setMinSize(StackPane.USE_PREF_SIZE, StackPane.USE_PREF_SIZE); button.setPrefSize(30, 30); return button; } }