Thoughts on Dialogs and Lightboxes
Kevin Rushforth
kevin.rushforth at oracle.com
Mon Apr 2 13:55:56 PDT 2012
Note that a public method to allow a blocking modal dialog is planned
for 2.2:
http://javafx-jira.kenai.com/browse/RT-19783
-- Kevin
Jonathan Giles wrote:
> I'm coming to this discussion late as I've been travelling - sorry
> about that. As Dan mentions, I have a JOptionPane-esque API already.
> For those with access to rt-closed, it is in toys/dialogs. It is
> basically a fork of the JavaFX security dialog you may have seen
> elsewhere, with API similar to what you'd see in JOptionPane, and a
> whole lot of unnecessary code ripped out. It is fairly well developed
> and quite a long way along, and certainly usable. I have been pushing
> the relevant people to include this in a release, or at least the same
> concept of this, but as of yet I have not had success. This is most
> probably just due to the fact that there are more important fish to
> fry, and as Artem notes, the API is all there to make a modal window,
> and there is impl_ API (which you should never use!) to make a stage
> blocking.
>
> I have not done any work along the sheet approach, as this requires
> further support in the glass API, and this is where Artem would step in.
>
> -- Jonathan
>
>
> On 2/04/2012 8:03 p.m., Artem Ananiev wrote:
>> Hi, Daniel,
>>
>> On 3/31/2012 7:50 AM, Daniel Zwolenski wrote:
>>> I'm curious what the plans are for Dialogs in JavaFX. I assume they
>>> are on the roadmap?
>>
>> both dialogs (owned windows) and modality are already there:
>>
>> javafx.stage.Stage#initOwner()
>> javafx.stage.Stage#initModality()
>>
>>> I notice hints of this from Jonathon here:
>>> http://javafx-jira.kenai.com/browse/RT-12643
>>
>> This issue is about having the Alert class, which is similar to
>> Swing's JOptionPane, Windows' MessageBox and similar dialogs in other
>> UI toolkits. You can implement it yourself, however this
>> functionality is common enough to be a standard JFX class.
>>
>>> But I see the request is as yet unresolved.
>>>
>>> The reason I ask is because I've had to implement my own 'Lightbox'
>>> framework for my last project and I'm wondering if some part of this
>>> or something similar should be in JFX. I know a lot of people on the
>>> forums have been looking for classic dialog support from JFX.
>>>
>>> If you don't know already, a Lightbox is the web's answer to
>>> Dialogs, where a dialog-like pane is layered on top of the main
>>> content with a semi-transparent glass pane making it basically
>>> modal. The dialog is still within the main browser window, so it's
>>> not a true Popup but to the user is much the same.
>>>
>>> The end result looks like this:
>>>
>>> http://okonet.ru/projects/modalbox/images/screenshot.jpg
>>
>> This is a screenshot with Mac OS X "sheet", which is not what is
>> usually referred to as "Dialog". It's not a separate top-level
>> window. Other platforms don't have built-in support for such UI
>> elements.
>>
>>> It is quite easy to implement this in JFX using a StackPane as the
>>> base. The simple API is just to have some kind of LightboxPane (or
>>> RootPane, etc) that extends StackPane and includes a method like:
>>>
>>> showInLightbox(Node node)
>>>
>>> This then adds a 'glass pane' to the top of the Stack to dim out the
>>> content, and then adds the node to this glass pane. The node's
>>> visibility could be tracked to determine when to remove the glass
>>> pane, etc.
>>>
>>> The API can be extended beyond this simple setup quite drastically
>>> to include things like decorated boxes (title bar, close button,
>>> resize edges, etc), animated entry/exit, and 'dialog options' such
>>> as ok, cancel (ie JOptionPane like functions).
>>>
>>> My stuff needs cleaning up but I was planning to eventually roll my
>>> framework into JFX Flow. If it's on the JFX roadmap anyway, better
>>> not to, or at least I'd like the API to mirror JFX Dialogs if possible.
>>>
>>> Thoughts and comments?
>>
>> If you're asking about support for Mac OS X "sheets", please, file a
>> separate JIRA issue about this (I don't know if we already have this
>> request in FX bug database), as it is completely separate from RT-12643.
>>
>> Thanks,
>>
>> Artem
More information about the openjfx-dev
mailing list