5 Replies Latest reply: Dec 7, 2012 9:49 AM by async RSS

    Label will not display single character...

    async
      I discovered an issue with Label where a single character is not displayed if -fx-text-overrun is set to ellipsis and -fx-wrap-text is set to true.

      The Label has no problem displaying its text if the text string is more than one character long.

      Has anyone else encountered this issue? Is this a known JavaFX bug?

      I can create/post some sample code if necessary.
        • 1. Re: Label will not display single character...
          bouye
          You should have a look there to see if it is already posted and it not, create a new issue: http://javafx-jira.kenai.com/
          • 2. Re: Label will not display single character...
            973901
            I'm not able to reproduce your problem. It might be helpful to post some source code...it might have to do with the bounds or another setting of the parent container.
            • 3. Re: Label will not display single character...
              async
              Here is some sample code that is able to reproduce the issue on my setup. I'm running with JRE 1.7.0_09.
              package labelBug;
              
              import javafx.application.Application;
              import javafx.geometry.Pos;
              import javafx.scene.Scene;
              import javafx.scene.control.Label;
              import javafx.scene.layout.StackPane;
              import javafx.stage.Stage;
              
              public class App extends Application
              {
                  public static void main( String[] args )
                  {
                      Application.launch(args);
                  }
              
                  @Override
                  public void start(Stage stage) throws Exception {
                      Label lbl = new Label("a");
                      lbl.setStyle("-fx-text-fill: white; -fx-text-overrun: ellipsis; " +
                                     "-fx-wrap-text: true; -fx-background-color: green;");
                      StackPane.setAlignment(lbl, Pos.CENTER);
                      
                      StackPane root = new StackPane();
                      Scene scene = new Scene(root, 300, 150);
                      root.getChildren().add(lbl);
                      
                      stage.setTitle("Label Bug Example");
                      stage.setScene(scene);
                      stage.show();
                  }
              }
              • 4. Re: Label will not display single character...
                jsmith
                Yep, that reproduces for me - win7+jdk7u9 - you really should file a bug a bouye suggests.

                It's the -fx-wrap-text style which makes the character disappear.
                • 5. Re: Label will not display single character...
                  async
                  It looks like this is a bug that presents itself in a few ways. I have found a Jira ticket that addresses the setWrapText() bug and have added a comment with my example code to it.

                  For future reference, and if anyone else discovers a similar issue with setWrapText(), the Jira ticket can be found at http://javafx-jira.kenai.com/browse/RT-22047