Planet JFX

Using built-in Dialogs

118pages on
this wiki
Add New Page
Add New Page Talk0

Here is a quick example of how to use simple dialogs in JavaFX. Works in the interpreted version of JavaFXPad.

import javafx.ui.*;
import javafx.ui.canvas.*;
import javafx.ui.filter.*;

var f = Frame {
    menubar: MenuBar {
        [Menu {
            text: "Menu here!"
            [MenuItem {
                text: "Menu Item to start a confirm dialog"
                action: operation() {
                    var dlg = ConfirmDialog {
                        confirmType: YES_NO_CANCEL
                        title: "Yes / No / Cancel dialog"
                        message: "See?  A dialog is possible"
                        messageType: INFORMATION
                        onCancel: operation() {
                            println("cancel pressed");
                        onNo: operation() {
                            println("no pressed");
                        onYes: operation() {
                            println("yes pressed");
                    dlg.visible = true;
    content: Button {
        text: "Button to start a dialog"
        action: operation() {
            var otherDlg = MessageDialog {
                message: "This is a message dialog"
                title: "The message dialog title"
                messageType: ERROR
            otherDlg.visible = true;

return f;

Also on Fandom

Random Wiki