Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8125129

Improper label prefHeight - for dialog messages.

XMLWordPrintable

      A label does not request a proper prefHeight to display the full multiline message as can be seen from the test case below, where "..." is shown. This is a problem when displaying a dialog message to end-users, as dialog messages need to be read in full. I can see why a label which has the labelFor assigned and only contains one or two words would accept to be minimised if other components need the space, but a dialog message should always be displayed in full. The trouble is, we cannot even set a prefHeight because the length of the message may vary depending on the end-user's language. We have worked around the problem by setting a very large prefHeight, but then the UI does not look packed the way it should.



      public class LabelSizeBugTestCase extends Application {

      private Label message = new Label("Please enter the make and model of the car you are searching for in the field below.");
      @Override
      public void start(Stage stage) throws Exception {
      message.setWrapText(true);

      BorderPane borderPane = new BorderPane();
      borderPane.setTop(message);

      stage.setWidth(300);
      stage.setScene(new Scene(borderPane));
      stage.show();
      }

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

            msladecek Martin Sládeček
            risaksen Randahl Isaksen
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: