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

WrapText doesn't work properly in ButtonBase

    XMLWordPrintable

Details

    Description

      To reproduce run following code

      public class Test extends Application {

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

          private Parent getContent() {
              VBox list = new VBox(10);
               
              Button but = new Button("Button button buttton button button long long long long line");
              but.setWrapText(true);
      // but.setStyle("-fx-wrap-text:true");
              but.setMaxWidth(50);
               
              list.getChildren().add(but);
              return list;
          }

          public void start(Stage stage) {
              stage.setX(100);
              stage.setY(100);
              stage.setWidth(200);
              stage.setHeight(200);
              Scene scene = new Scene(getContent());
              stage.setScene(scene);
              stage.show();
          }
      }

      import javafx.application.Application;
      import javafx.scene.Parent;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.layout.Pane;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class ButtonWrap extends Application {

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

          private Parent getContent() {
              VBox list = new VBox(10);
              
              Button but = new Button("Button button buttton button button\n long long long long line");
              but.setWrapText(true);
              but.setMaxWidth(10);
              
              list.getChildren().add(but);
              return list;
          }

          public void start(Stage stage) {
              stage.setX(100);
              stage.setY(100);
              stage.setWidth(200);
              stage.setHeight(200);
              Scene scene = new Scene(getContent());
              stage.setScene(scene);
              stage.setVisible(true);
          }
      }

      Attachments

        1. screenshot-1.jpg
          screenshot-1.jpg
          8 kB
        2. screenshot-2.jpg
          screenshot-2.jpg
          23 kB
        3. wrap.png
          wrap.png
          27 kB

        Activity

          People

            leifs Leif Samuelsson (Inactive)
            anazarov Andrey Nazarov (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: