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

Bound Label text not displayed when a graphic node is set.


    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: fx2.0
    • Fix Version/s: fx2.0.2
    • Component/s: javafx
    • Labels:
    • Environment:

      Mac OS X Lion, Mac beta - build 42.


      A Label control will not display both its text and its graphic if the text is bound to a string property and is not updated before the Scene is shown. The example code below illustrates the issue. When using setText and setGraphic, everything works fine.

      If the Label's textProperty is bound to a StringProperty AND a graphic is set, then the text will not be shown unless the StringProperty is initialized before the Scene is shown. If no graphic is set, then the text is updated properly regardless of when the update takes place.

      If the following code is run as-is, then no text will show up on the label.

      public class ProgressLabelTest extends Application {
          private SimpleStringProperty message = new SimpleStringProperty();

          public void start(Stage stage) throws Exception {
              Rectangle r = new Rectangle(20, 20);
              Label l = new Label();

              // This shows both text and graphic - order doesn't matter.
      // l.setText("Hello, world");
      // l.setGraphic(r);

              // This shows both text and graphic as long as the text is
              // updated before the scene is shown
              l.setGraphic(r); // Comment this out and "Hello, world again" will show regardless of the next line
              //message.set("Hello, world (bound)"); // Uncomment this and "Hello, world again" will show

              Scene s = new Scene(new Group(l), 200, 200);

              message.set("Hello, world again (bound)");

          public static void main(String[] args) {


          Issue Links



              • Assignee:
                leifs Leif Samuelsson (Inactive)
                diversonjfx Dean Iverson (Inactive)
              • Votes:
                0 Vote for this issue
                1 Start watching this issue


                • Created: