displaying messagebox using javafx


Has anyone used the following recently?

I have included the jar file in my netbeans project

and running the following code as mentioned in the documentation here:

"Sample of error dialog.\n\nDialog option is below.\n[MessageBox.ICON_ERROR]",
"Error dialog",

But nothing is happening in my code. At least I was expecting some window to pop up.

I have imported jfx.messagebox.MessageBox; and javafx.stage.Window; in my code.

I am using javafx version : 2.2.50

4/10/2014 9:36:22 PM

Accepted Answer


Java 8u40 added official support for JavaFX dialogs and alerts (message boxes).

The built-in alerts cover most common message box usage scenarios.

The ControlsFX dialog implementation mentioned in the rest of this answer has been re-worked to function with the JavaFX dialog support in the JRE. Usually, it is sufficient to just use the built-in dialogs and alerts without a 3rd party library. However, for special cases such as wizard dialogs, etc., you may still wish to review and use the ControlsFX dialogs as they contain additional functionality over and above what can be found in the standard JavaFX dialogs.

Previous answer

I recommend upgrading to Java 8 and using the ControlsFX dialogs.

IMO the ControlsFX dialogs are better and (unlike the jfxmessagebox library), the ControlsFX library is under active development.

The ControlsFX dialog usage is also much better documented.

Sample code to display a ControlsFX message box:

Action response = Dialogs.create()
  .owner( isOwnerSelected ? stage : null)
  .title("You do want dialogs right?")
  .masthead(isMastheadVisible() ? "Just Checkin'" : null)
  .message( "I was a bit worried that you might not want them, so I wanted to double check.")


Answers to additional questions regarding Java 8

Do you know how should I update to JavaFX 8 ?

On Windows, use the control panel "Add/Remove Programs" to remove your existing JDK installation. Then download the new JDK installed (e.g. jdk-8-windows-x64.exe) and install it.

My old application would not stop working after upgrading from JavaFX 2.2

Java is very good about maintaining compatibility between releases. Your existing application may need some tweaks if you used a lot of custom CSS, but other than that, it will probably work just fine - try it and see.

JavaFX was upgraded to 8 in jdk 8?

Yes. There is a changelog for JavaFX changes for Java 8.

5/23/2017 12:25:48 PM

here are most used javaFX dialogs.It might be helpful to you ....:-)

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow