1

I found this article JavaFX 2 Dialogs and I am using it. But this dialog accepts only Stage Object. Is there any option to display dialog box which will accept AnchorPane as its parent. That Is similar to JoptionPane where we can pass any object which are derived from Component for example JPanel, JTitlePane, etc. And the dialog box I am using it is bieng display on task bar of windows also (passing null as parent). I want show a message like this

enter image description here

Is it possible to display an AnchorPane to the top of the other AnchorPane or TableView like the attached picture which will be modal as well?

Biswadip Dey
  • 509
  • 2
  • 7
  • 20
  • If you type `javafx dialog` into the search dialog box you will see many answers to your question. I recommend reviewing: [Block program execution until user clicks button](http://stackoverflow.com/questions/23121580/block-program-execution-until-user-clicks-button), and [How to create and show common dialog (Error, Warning, Confirmation) in JavaFX 2.0?](http://stackoverflow.com/questions/8309981/how-to-create-and-show-common-dialog-error-warning-confirmation-in-javafx-2). – jewelsea Jan 09 '15 at 19:06
  • You are probably looking for something like a [ControlsFX lightweight dialog](http://controlsfx.bitbucket.org/org/controlsfx/dialog/Dialogs.html) – jewelsea Jan 09 '15 at 19:07

1 Answers1

2

JavaFX does not have a pre-defined dialog api like swing's JOptionPane.

Take a look at ControlsFX: http://fxexperience.com/controlsfx/

They have a set of Dialogs fit for most situations: http://fxexperience.com/controlsfx/features/dialogs/

You can call a dialog using:

Dialogs.create().message("Hi!").showInformation();

Otherwise, if you don't want to use third party libraries, you will have to create your own set of dialogs.

------- UPDATE -------

There is now a built in API for dialogs in JavaFX since jre8u60 (Alert, ChoiceDialog, TextInputDialog, etc.), check it out: controlsfx Dialogs deprecated for what?

Community
  • 1
  • 1
Mateus Viccari
  • 7,389
  • 14
  • 65
  • 101
  • A lot of the ControlsFX dialog functionality is now included in JavaFX, as of version 8u40 (which at the time of writing is in early access). The Javadocs for them are included in the [JavaFX 9 Javadocs](http://download.java.net/jdk9/jfxdocs/index.html?javafx/scene/control/Dialog.html) (though you only need Java 8u40 for this functionality). – James_D Jan 09 '15 at 19:09
  • @James_D could you possibly provide some info on where this stuff is to be found in the Javadocs? I have compiled the Javadocs for Java 8.91 source and its accompanying JavaFX source... but I can't find a "Dialogs" class... nor could I find a "create" method in the index which creates a dialog of any kind... – mike rodent Oct 14 '16 at 17:48
  • @mikerodent Just in the [usual place](http://docs.oracle.com/javase/8/javafx/api/index.html?javafx/scene/control/Dialog.html). Note the *functionality* is there, but the API is a little different. – James_D Oct 14 '16 at 17:56
  • Thanks... OK it all makes sense: `Alert`, `ChoiceDialog`, `TextInputDialog`. "JavaFX For Dummies", obviously written prior to 8.40, from which I'm learning JavaFX, gets you making your own message boxes, and remarks on the oddity of there being no `JOptionPane` class... – mike rodent Oct 16 '16 at 09:39
  • There is now a dialogs api on javafx. Check it out: http://stackoverflow.com/questions/26341152/controlsfx-dialogs-deprecated-for-what/32618003#32618003 – Mateus Viccari Oct 16 '16 at 23:27