JDK-8232811 : Dialog's preferred size no longer accommodates multi-line strings
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8u202,openjfx13
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64
  • Submitted: 2019-10-08
  • Updated: 2020-07-02
  • Resolved: 2020-01-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 Other
8u261Fixed openjfx11.0.8Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
$ uname -a
Linux orion 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2 (2019-08-28) x86_64 GNU/Linux

$ java -version
openjdk version "13" 2019-09-17
OpenJDK Runtime Environment AdoptOpenJDK (build 13+33)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.16.0, JRE 13 Linux amd64-64-Bit Compressed References 20190916_75 (JIT enabled, AOT enabled)
OpenJ9   - 867dab457
OMR      - d4c85c31
JCL      - 2858e3f001 based on jdk-13+33)


A DESCRIPTION OF THE PROBLEM :
As of JavaFX 13, a Dialog is only tall enough to display a single line of content text.  If the content text contains one or more newline characters, the content area is still tall enough to accommodate only the first line of text, followed by an ellipsis.

In JavaFX 12, Dialogs properly accommodated multi-line text.


REGRESSION : Last worked in version 12.0.2

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a Dialog, and call its setContentText method with an argument that contains at least one newline character.  Then show the Dialog.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The Dialog should be tall enough to show all lines of the content text.  In JavaFX 12, this was the case.
ACTUAL -
In JavaFX 13, the Dialog only shows the first line of content text, followed by an ellipsis.

---------- BEGIN SOURCE ----------
import javafx.application.Application;

import javafx.stage.Stage;

import javafx.scene.Scene;

import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;

import javafx.scene.layout.BorderPane;

public class MultilineDialogTest
extends Application {
    @Override
    public void start(Stage stage) {
        Scene scene = new Scene(new BorderPane(), 500, 500);
        stage.setScene(scene);
        stage.setTitle("Multi-line Dialog Test");
        stage.show();

        Dialog<ButtonType> dialog = new Dialog<>();
        dialog.initOwner(stage);
        dialog.setTitle("Multi-line Dialog");
        dialog.setContentText("This\nis\na\ntest");
        dialog.getDialogPane().getButtonTypes().add(ButtonType.CLOSE);
        dialog.showAndWait();

        stage.hide();
    }

    public static class Main {
        public static void main(String[] args) {
            Application.launch(MultilineDialogTest.class, args);
        }
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Obtain the parent Window from the DialogPane's Scene, and size it manually.

FREQUENCY : always



Comments
Changeset: 1952606a Author: Thiago Milczarek Sayao <tsayao@openjdk.org> Committer: Kevin Rushforth <kcr@openjdk.org> Date: 2020-01-02 17:01:13 +0000 URL: https://git.openjdk.java.net/jfx/commit/1952606a
06-01-2020

Fixed by the following commit: https://github.com/openjdk/jfx/commit/1952606a7b7f7fa87b77c33295077778be234ee8 The resolution of this issue by the Skara bot is pending.
02-01-2020

Review: https://github.com/openjdk/jfx/pull/63
12-12-2019

That seems a reasonable explanation. We can review the code in the PR.
12-12-2019

Found the problem: HeavyweightDialog sets resizable to false which ends up setting geometry constraints on glass side. So when the dialog is resized to the correct size, gtk_window_resize() does not resize because it respects the constraints (resizeable=false). This is caused because when the Dialog has an owner it pre-calls layout to have a size to center the dialog on it's owner. The calculation is wrong (probably because it's missing information that will be later available). So the dialog is set to the wrong size and later corrected. But when the correction comes, it's unresizeable. Setting resizeable to true will work-around the bug. The reason it worked before JDK-8212060 is that it was showing the window before it should, so when dialog calculation occurred, all the size information was available. [~kcr] ping.
04-12-2019

Did some investigation. The problem lies somewhere inside HeavyweightDialog.positionStage() that is called when the Dialog has an owner and does size calculation. Not sure if on Java side.
03-12-2019

I also believe that the fix for JDK-8212060 is correct. It looks like that fix has exposed a problem elsewhere in the Linux glass implementation. We should fix this for openjfx14 and backport it (both to openjfx11 and JDK 8u) to fix the regression.
05-11-2019

Another note: The bug only happens when the Dialog calls initOwner
04-11-2019

[ ~kcr] JDK-8212060 Reverting this fix makes it work again. The fix is correct tho, so I suspect it's a event order thing.
04-11-2019

Also checked with JDK-8227366 - not this one either.
30-10-2019

[~tsayao] Thanks for checking. So this is some other problem then.
30-10-2019

[ ~kcr] I have restored the way it was before JDK-8193502 and the problem is still reproducible - so not a regression of this fix.
30-10-2019

[~tsayao] Would you be willing to take a look at this and see whether it is a regression caused by the earlier fix for JDK-8193502?
30-10-2019

A possibly relevant bug was fixed in JavaFX 13, JDK-8193502, which may have caused this regression.
24-10-2019

If this only happens on Linux then it might be a window-toolkit bug.
22-10-2019