import java.nio.file.Files; import java.nio.file.Path; import javafx.application.Application; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.effect.Bloom; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCodeCombination; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class Main extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) throws Exception { Path p = Files.createTempFile("prefix", "suffix"); p.toFile().deleteOnExit(); setUserAgentStylesheet(p.toUri().toURL().toString()); // remove default stylesheet Button b = new Button("Neon button"); b.setEffect(new Bloom()); VBox root = new VBox(20, b); root.setAlignment(Pos.CENTER); Scene scene = new Scene(root, 300, 300); stage.setScene(scene); scene.getStylesheets().add("style.css"); stage.getScene().getAccelerators().put(new KeyCodeCombination(KeyCode.ESCAPE), () -> System.exit(0)); stage.show(); } }
.root { -fx-background-color: darkblue; } .button { -fx-font-size:2em; -fx-font-family: "Eras Medium ITC"; -fx-padding:15px 20px; -fx-text-alignment: center; -fx-border-width: 2px; -fx-border-color: cyan; -fx-text-fill:cyan; -fx-border-radius: 50%; -fx-padding:1em 2em 0.9em 2em; } .button:hover { -fx-border-color: derive(cyan, -20%); -fx-text-fill:derive(cyan, -20%); }
styled using hilite.me
No comments:
Post a Comment