JavaFX Dialog Material Design
Jfoenix is a library to build JavaFX application using Material design principal. One of my favorite library and always use it whenever i program desktop application. You can get the library from this official website www.jfoenix.com, read the documentation for further use, or just put this to your Maven pom.xml :
<dependency>
<groupId>com.jfoenix</groupId>
<artifactId>jfoenix</artifactId>
<version>8.0.9</version>
</dependency>
<dependency>
<groupId>com.jfoenix</groupId>
<artifactId>jfoenix</artifactId>
<version>8.0.9</version>
</dependency>
And this is about showing dialog in JavaFX, it has modern look with shadowing and animation when it showing and closing. This is full example on how to create a dialog with Jfoenix JfxDialog:
import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXDialog; import com.jfoenix.controls.JFXDialogLayout; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class PlayGround extends Application { public static void main(String[] args) { launch(); } @Override public void start(Stage primaryStage) throws Exception { StackPane root = new StackPane(); JFXButton jfxButton=new JFXButton("SHOW!"); jfxButton.setStyle("-fx-background-color: green; -fx-text-fill: white"); BorderPane borderPane = new BorderPane(); borderPane.setCenter(jfxButton); root.getChildren().addAll(borderPane); JFXDialog jfxDialog = new JFXDialog(); JFXDialogLayout content= new JFXDialogLayout(); VBox vBox = new VBox(); vBox.setSpacing(10); HBox hBox = new HBox(); Label label = new Label("Are you sure want to delete!"); hBox.getChildren().addAll(label); HBox hBox2 = new HBox(); JFXButton jfxButton1 = new JFXButton("Cancel"); jfxButton1.setStyle("-fx-background-color: #eee; -fx-text-fill: #333"); JFXButton jfxButton2 = new JFXButton("Yes"); jfxButton2.setStyle("-fx-background-color: red; -fx-text-fill: white"); hBox2.getChildren().addAll(jfxButton1,jfxButton2); vBox.getChildren().addAll(hBox, hBox2); content.setBody(vBox); jfxDialog.setContent(content); jfxDialog.setDialogContainer(root); Scene scene = new Scene(root, 700,600); // primaryStage.setMaximized(true); jfxButton.setOnAction(act->{ jfxDialog.show(); }); primaryStage.setScene(scene); primaryStage.setTitle("JavaFX dialog Material Design"); primaryStage.show(); } }