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

[HBox] Text is out of bounds.

    Details

      Description

      Compare two screenshots.

      To reproduce:


      import java.util.ArrayList;
      import javafx.application.Application;
      import javafx.scene.Node;
      import javafx.scene.Scene;
      import javafx.scene.control.Hyperlink;
      import javafx.scene.control.HyperlinkBuilder;
      import javafx.scene.control.PasswordField;
      import javafx.scene.control.PasswordFieldBuilder;
      import javafx.scene.control.RadioButton;
      import javafx.scene.control.RadioButtonBuilder;
      import javafx.scene.control.Slider;
      import javafx.scene.control.SliderBuilder;
      import javafx.scene.control.TextField;
      import javafx.scene.control.TextFieldBuilder;
      import javafx.scene.layout.HBox;
      import javafx.scene.paint.Color;
      import javafx.scene.shape.Circle;
      import javafx.scene.shape.Rectangle;
      import javafx.scene.text.TextAlignment;
      import javafx.stage.Stage;

      public class JavaApplication28 extends Application
      {

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

          @Override
          public void start(Stage stage) throws Exception
          {
              HBox root = new HBox(10d);
              
              HBox hbox = new HBox(10d);
              for (Node node : getNodes()) {
                  hbox.getChildren().add(node);
              }
              hbox.setPrefSize(450, 140);
              hbox.setStyle("-fx-border-color: darkgray;");
              
              HBox hb2 = new HBox(10d);
              for (Node node : getNodes()) {
                  hb2.getChildren().add(node);
              }
              hb2.setPrefSize(450, 140);
              hb2.setStyle("-fx-border-color: darkgray;");

              root.getChildren().addAll(hbox, hb2);
              
              Scene scene = new Scene(root, 1000, 800);
              stage.setScene(scene);
              stage.show();
          }

          private ArrayList<Node> getNodes()
          {
              ArrayList<Node> nodes = new ArrayList<>();
              
              Hyperlink hyperlink = HyperlinkBuilder.create()
                      .text("Hyperlink the first line" + "\nthe sec long line" + "\nthe third line")
                      .focusTraversable(false)
                      .graphic(new Circle(10, Color.BLUE))
                      .build();
              nodes.add(hyperlink);
              
              Slider slider = SliderBuilder.create()
                      .min(0)
                      .max(100)
                      .value(20)
                      .focusTraversable(false)
                      .build();
              nodes.add(slider);
              
              PasswordField passwordField = PasswordFieldBuilder.create()
                      .promptText("Password box the first line" + "\nthe sec long line" + "\nthe third line")
                      .focusTraversable(false)
                      .build();
              nodes.add(passwordField);
              
              TextField textField = TextFieldBuilder.create()
                      .text("Text box the first line" + "\nthe sec long line" + "\nthe third line")
                      .focusTraversable(false)
                      .build();
              nodes.add(textField);
              
              RadioButton radioButton= RadioButtonBuilder.create()
                      .text("Radio the first line" + "\nthe sec long line" + "\nthe third line")
                      .graphic(new Rectangle(20, 20, Color.web("lightblue")))
                      .focusTraversable(false)
                      .textAlignment(TextAlignment.RIGHT)
                      .build();
              nodes.add(radioButton);
              
              return nodes;
          }
      }

        Attachments

          Activity

            People

            • Assignee:
              msladecek Martin Sládeček
              Reporter:
              dzinkevi Dmitry Zinkevich (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: