Help with dialogs

153 views
Skip to first unread message

Juan Pérez

unread,
Jan 26, 2015, 10:35:51 PM1/26/15
to mvvmf...@googlegroups.com
Hi guys, I was wondering if you have an example or something for using predefined dialogs which may return data. I'm learning JavaFX and i'm using your MVVM framework but I don't know how to do this.

For example, how to use a FileChooser dialog: how and where to construct it, modify it's properties, open it passing the respective Window owner and get the resulting File.

Also other dialogs likes the ones in ControlsFX, which return an Action like OK, Cancel, etc. I imagine it would be the same or almost the same as the FileChooser.

I'd appreciate your help.

Thank you!

Manuel Mauky

unread,
Jan 27, 2015, 4:39:24 AM1/27/15
to mvvmf...@googlegroups.com
Hi Juan,

at the moment we have no example that shows the usage of predefined dialogs or ControlsFX dialogs.
But I will take your request as a suggestion and will add such an example in the near future.

I have used the "openjfx-dialogs" from ControlsFX in one of my pet projects.
You can find it here:
https://github.com/lestard/nonogram/blob/2562d0bd1cb1c8f9cc9b124aaf1bf86a8dfadf15/src/main/java/eu/lestard/nonogram/main/MainView.java#L42

In the example I'm creating a dialog with a ChoiceBox of integer values. The creation of the dialog is done in the View but the List of possible values and the integer that should be preselected is taken from the ViewModel.
The result that the user chooses in the dialog is then passed to the ViewModel afterwards.

In general I would recommend to create the dialog in the View and not in the ViewModel because the ViewModel shouldn't have any dependency on UI controls.
Depending on the used dialog API you may can't avoid some small amount of logic in the View.

I hope this example can help you. If you have any further questions don't hesitate to ask.

Best regards
Manuel
Reply all
Reply to author
Forward
0 new messages