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

Label is not wrapping then set to wrap

XMLWordPrintable

    • x86_64
    • linux_ubuntu

      ADDITIONAL SYSTEM INFORMATION :
      Ubuntu 18.04.
      java version "11.0.2" 2019-01-15 LTS
      Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
      Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)


      A DESCRIPTION OF THE PROBLEM :
      Label is not wrapping - instead its ellipsizing.




      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the provided test code. The label is set to wrap.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Text should wrap and not ellipsize.
      ACTUAL -
      Text ellipsizes.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.ButtonType;
      import javafx.scene.control.Dialog;
      import javafx.scene.control.Label;
      import javafx.stage.Modality;
      import javafx.stage.Stage;
      import javafx.stage.Window;

      public class HelloFx extends Application {
          @Override
          public void start(Stage primaryStage) {
              
              Scene scene = new Scene(new Label("Primary Stage"), 640, 480);
              primaryStage.setScene(scene);
              primaryStage.show();
              
              openDialog(primaryStage);
              openTestStage();
          }
          
          void openDialog(Window owner) {
              Dialog dialog = new Dialog();
              dialog.initOwner(owner);
              dialog.setContentText(
                      "The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.The quick brown fox jumped " +
                      "over the lazy dog.The quick brown fox jumped over the lazy dog.");
              dialog.setTitle("Dialog");
              dialog.initModality(Modality.WINDOW_MODAL);
              dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK);
              dialog.show();
          }
          
          void openTestStage() {
              Stage stage = new Stage();
              Label lbl = new Label("The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.The quick brown fox jumped " +
                                    "over the lazy dog.The quick brown fox jumped over the lazy dog.");
              lbl.setWrapText(true);
              Scene scene = new Scene(lbl);
              stage.setScene(scene);
              stage.sizeToScene();
              stage.setMaxWidth(300);
              stage.show();
          }
      }


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

            arapte Ambarish Rapte
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: