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

Alignment.JUSTIFY is not applied in SW rendering.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8
    • 8
    • javafx
    • 8.0b69, win7, x32, sw VS prism.

    Description

      Run the code:

      import javafx.application.Application;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.input.KeyCode;
      import javafx.scene.input.KeyEvent;
      import javafx.scene.layout.Pane;
      import javafx.scene.paint.Color;
      import javafx.scene.text.Font;
      import javafx.scene.text.Text;
      import javafx.stage.Stage;

      public class TextAlignment extends Application {

          public static void main(String[] args) {
              launch(args);
          }
          int counter = 0;

          @Override
          public void start(Stage stage) throws Exception {
              final String content = "The quick brown fox jumps over the lazy dog.\nWoven silk pyjamas exchanged for blue quartz?\nHave a pick: twenty six letters - no forcing a jumbled quiz!\n";
              final ObservableList<javafx.scene.text.TextAlignment> alignments = FXCollections.<javafx.scene.text.TextAlignment>observableArrayList(javafx.scene.text.TextAlignment.LEFT, javafx.scene.text.TextAlignment.CENTER, javafx.scene.text.TextAlignment.RIGHT, javafx.scene.text.TextAlignment.JUSTIFY);

              double fontSize = 15.0;
              double space = 10.0;

              final Text Text_b = new Text(space, 3 * space, content);
              Text_b.setFont(new Font(fontSize));
              Text_b.setFill(Color.BLACK);
              Text_b.setWrappingWidth(200);
              Text_b.setTextAlignment(alignments.get(counter));
              Text_b.setFocusTraversable(true);
              Text_b.setOnKeyPressed(new EventHandler<KeyEvent>() {
                  @Override
                  public void handle(KeyEvent e) {
                      if (e.getCode().equals(KeyCode.LEFT)) {
                          if (counter < alignments.size() - 1) {
                              counter++;
                          } else {
                              counter = 0;
                          }
                      }

                      Text_b.setTextAlignment(alignments.get(counter));
                      System.out.println(alignments.get(counter));
                  }
              });

              Pane pane = new Pane();
              pane.getChildren().add(Text_b);
              Scene scene = new Scene(pane, 300, 300);
              stage.setScene(scene);
              stage.show();
          }
      }

      In SW and prism rendering. JUSTIFY alignment is the same as LEFT alignment.

      Attachments

        Activity

          People

            msoch Martin Ĺ och
            akirov Alexander Kirov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: