-
Notifications
You must be signed in to change notification settings - Fork 542
8370446: Support dialogs with StageStyle.EXTENDED (Preview) #1943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
👋 Welcome back mstrauss! A progress list of the required criteria for merging this PR into |
|
@mstr2 This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 3 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
modules/javafx.controls/src/main/java/javafx/scene/control/Dialog.java
Outdated
Show resolved
Hide resolved
|
The nature of when and how DialogPane's "scene" is available seems to have changed. For example, consider this (very old) code of mine: Now I get an NPE because getScene() is null even after a dialog pane is set, presumably because of the changes to HeavyweightDialog.setDialogPane(). It might be incorrect to assume a scene is assigned at this point (...?), but it is and has been for a long time... E.g., simply instantiating a Dialog would have created a scene immediately via setDialogPane() previously: ... which is now not the case. Would you consider this a breaking change? |
Yes, and it's probably not useful to introduce a breaking change at this point. I've updated the PR to match the old behavior. |
Great, thanks. It now appears to be working as desired with these tweaks... |
| * @since 26 | ||
| */ | ||
| private ObjectProperty<HeaderBar> headerBar; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a preview feature, it needs to be documented and handled as such.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. This requires documenting all property methods individually, instead of relying on the javadoc tool to do it automatically (as the @deprecated annotation is not carried over). I'll revert this to a property field doc once this feature is finalized.
|
/reviewers 2 |
|
@mstr2 has indicated that a compatibility and specification (CSR) request is needed for this pull request. @mstr2 please create a CSR request for issue JDK-8370446 with the correct fix version. This pull request cannot be integrated until the CSR request is approved. |
Webrevs
|
|
Hi. Another bug, a slightly more serious one this time. Dialogs cannot be re-used. E.g., sequentially calling showAndWait() twice on the same instance, does not work: This works fine on older JFXs: Steps to reproduce: |
Hi @mstr2: any thoughts on this one (in particular)? Seems like a bug... |
|
I've moved the new API from |
|
@mstr2: Thanks. I've been using this build a lot yesterday and today, and haven't noticed any issues re: alerts/dialogs + HeaderBar usage. Great to have HeaderBar support for dialogs now. |
|
This might be a silly question: is there a need for split |
| * or StageStyle.UNIFIED. | ||
| * Specifies the style for this dialog. This must be done prior to making the dialog visible. | ||
| * <p> | ||
| * Note that a dialog with the {@link StageStyle#EXTENDED} style must also specify a {@link HeaderBar} with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
must or should? meaning, is it a requirement, or just a warning?
if the latter, it might be better to say something like "the dialog will not be draggable if the header bar is not set"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, it's more like a warning. I've changed it to "should".
|
|
||
| /** {@inheritDoc} */ | ||
| @Override protected double computeMinWidth(double height) { | ||
| double headerBarMinWidth = getHeaderBar() instanceof HeaderBar hb ? hb.minWidth(height) : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clever! :-)
|
For testing: added the header bar options to the Stage and Dialog pages: |
I don't think that this is very useful for |
andy-goryachev-oracle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, thanks!
kevinrushforth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API changes look good. The code change look good, although I left an inline question about one of the changes (since it would impact all stage styles, not just EXTENDED).
You can create the CSR now.
| headerTextPanel.setVisible(false); | ||
| headerTextPanel.setManaged(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this change needed? At first glance it seems unrelated to supporting an (optional) header bar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was left over from a previous bug-fixing attempt. I've removed the added code.
| contentLabel.setVisible(false); | ||
| contentLabel.setManaged(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question here.
|
I discovered a bug where |
|
@mstr2 this pull request can not be integrated into git checkout feature/extended-dialog
git fetch https://git.openjdk.org/jfx.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
# Conflicts: # modules/javafx.controls/src/test/java/test/javafx/scene/control/DialogPaneTest.java
andy-goryachev-oracle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
added more options to the monkey tester Dialog page
https://github.com/andy-goryachev-oracle/MonkeyTest
kevinrushforth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API and docs looks good.
The code changes look reasonable, but I haven't tested them and also want to take another pass, since these have the potential to impact DialogPane even when not using StageStyle.EXTENDED + HeaderBar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running a simple Dialog test that doesn't try to use HeaderBar or StageStyle.EXTENDED gets a RuntimeException without enabling preview features.
To reproduce, run HelloAlert from apps/toys/Hello or use the MonkeyTester without setting javafx.enablePreview and bring up an alert dialog:
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: HeaderBar is a preview feature of JavaFX 26-internal.
Preview features may be removed in a future release, or upgraded to permanent features of JavaFX.
Programs can only use preview features when the following system property is set: -Djavafx.enablePreview=true
at javafx.base@26-internal/com.sun.javafx.PreviewFeature.checkEnabled(PreviewFeature.java:71)
at javafx.controls@26-internal/javafx.scene.control.DialogPane.getHeaderBar(DialogPane.java:487)
at javafx.controls@26-internal/javafx.scene.control.DialogPane.computePrefWidth(DialogPane.java:1077)
...
I've updated the code to skip the preview feature check internally. It's still active for the public API. |
kevinrushforth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| } | ||
| } | ||
|
|
||
| // This method skips the preview feature check for internal use and can be removed when HeaderBar is finalized. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if a comment should be added to the JBS ticket listing the things that need to be undone, lest we forget.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this specific case it's quite hard to miss, since it's right next to the preview API. But go ahead if you want to add the comment.
|
/integrate |
|
Going to push as commit f87448e.
Your commit was automatically rebased without conflicts. |






Adds the
DialogPane.headerBarproperty, which allows developers to specify a customHeaderBarwhen the dialog uses theEXTENDEDstage style.Progress
Issues
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1943/head:pull/1943$ git checkout pull/1943Update a local copy of the PR:
$ git checkout pull/1943$ git pull https://git.openjdk.org/jfx.git pull/1943/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1943View PR using the GUI difftool:
$ git pr show -t 1943Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1943.diff
Using Webrev
Link to Webrev Comment