JFXPanel

Scott Palmer swpalmer at gmail.com
Thu Jan 3 10:44:16 PST 2013


Interesting, I'm not ready to try 8.0 yet, but I looked over the web page of the 2.x port.
One thing that is needed and would be simple but important improvement over JOptionPane is a custom dialog with standard chic buttons (yes/no/ok/cancel) where the custom code can easily get access to the choice buttons in order to disable them, add tooltips etc.  There are many cases where you want a standard Ok/Cancel dialog but you want to disable the OK button until the user has made some valid input in your custom content.  You may also wish to place a tooltip on the disabled OK button to explain why it is disabled.
I think a dialog that takes a Parent instead of Strings is important.  Or perhaps a dialog that takes a URL to the fxml for the main content and returns an instance of the controller after the selection has been made so that the controller can be queried for information from the form.

Rather than placing this stuff in an unsupported, likely-to-be-removed, package of Java 8, why not add it to JFXtras?

Scott

On 2013-01-03, at 12:51 PM, Jonathan Giles <jonathan.giles at oracle.com> wrote:

> I've been wanting to do a JOptionPane-esque feature for JavaFX since at least 2.0 :-) As it happens I tend to include it in developer previews in the hope it'll be accepted, but I never seem to get any traction on it :-) So, for JavaFX 8.0 developer previews, refer to com.preview.javafx.scene.control.Dialogs for your JOptionPane-esque requirements. I must warn that I've not got permission to make this into public API, so it will more than likely be removed from JavaFX 8.0 before it ships, unfortunately.
> 
> If you're using JavaFX 2.x, then you'll want to use the backport of my Dialogs class that has been done by Marco Jakob here:
> http://edu.makery.ch/blog/2012/10/30/javafx-2-dialogs/
> 
> -- Jonathan
> 
> On 4/01/2013 5:58 a.m., Scott Palmer wrote:
>> Yes.. I have to look again at JFXtras, to see what they already offer, but I see a need for something like a JavaFX version of JOptionPane.  That way you get those default OK/Cancel buttons, the dialog result, etc.
>> So far I'm implementing tiny bits on demand, but I need to revisit the whole problem and refactor the code.  Dealing with Swing and JavaFX simultaneously can get messy which is why I'm trying got migrate my entire application as soon as practical.  There still isn't a 1:1 match in JavaFX for things we are using in Swing, and JavaFX is young enough that there are still many rough edges.
>> 
>> Scott
>> 
>> On 2013-01-03, at 5:28 AM, Werner Lehmann <lehmann at media-interactive.de> wrote:
>> 
>>> Hi Scott,
>>> 
>>> makes sense. I have to keep that in mind for next time. I guess there also has to be some code for common dialog tasks, e.g.
>>> 
>>> - show dialog centered on app or on parent window
>>> - modal or modeless
>>> - standard handling of ok/cancel/etc buttons (e.g. know when to close the dialog)
>>> - data validation before close
>>> - pass a dialog result to the caller
>>> 
>>> This is not rocket science but I very much would like to see some standard API for that. Maybe it even makes sense to have skeleton JDialog/Stage classes which bring their own set of buttons. Otherwise you have this ok button in the JFXPanel node but the JDialog does not know when it was clicked.
>>> 
>>> Werner
>>> 
>>> On 02.01.2013 20:06, Scott Palmer wrote:
>>>> I intend to pursue this by creating some helper methods to show a
>>>> dialog containing a single Parent node.  Depending on the parent
>>>> object for the dialog it would automatically wrap the node in a
>>>> JFXPanel and use a JDialog, or use a Stage.  That way I keep the ugly
>>>> stuff in one place and don't have to revisit all those dialogs.
> 



More information about the openjfx-dev mailing list