Planet JFX

Using built-in Dialogs

118pages on
this wiki
Add New Page
Talk0 Share

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;

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki