Skip to content

Instantly share code, notes, and snippets.

@Vaysman
Created January 31, 2016 13:48
Show Gist options
  • Select an option

  • Save Vaysman/dcd4fd53a6a90d7c6c15 to your computer and use it in GitHub Desktop.

Select an option

Save Vaysman/dcd4fd53a6a90d7c6c15 to your computer and use it in GitHub Desktop.
How to create round button on java script
/*
Code imported from
http://stackoverflow.com/a/26851888
*/
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class RoundButton extends Application {
public static final int SIZE = 30;
@Override
public void start(Stage stage) throws Exception {
Button roundButton = new Button();
roundButton.setOnAction(event -> System.out.println("clicked"));
roundButton.setStyle(
"-fx-background-radius: 5em; " +
"-fx-min-width: " + SIZE + "px; " +
"-fx-min-height: " + SIZE + "px; " +
"-fx-max-width: " + SIZE + "px; " +
"-fx-max-height: " + SIZE + "px;"
);
StackPane layout = new StackPane(
roundButton
);
layout.setPadding(new Insets(10));
stage.setScene(new Scene(layout));
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment