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

The default alignment of graphics in buttons changed in build 2.1b10



      In 2.1b10 the content display a graphic in a button with both a graphic and text defaults to centered behind the text rather than to the left of the text.
      In 2.0.2 the graphics appeared to the left of the text.

      In an app I had to add button.setContentDisplay(ContentDisplay.LEFT) so that buttons with text and graphics rendered as they had before.

      It was only a minor issue for me - so this is logged more as an FYI - perhaps I should have been setting the content display explicitly earlier, but just didn't need to.
      Attached is a demo screenshot from 2.1b10 with half the buttons converted to use button.setContentDisplay(ContentDisplay.LEFT)
      Here is the utility method in my code which I use to create the a button with text and an icon:

        // create a button with an icon
        static public Button createIconButton(String buttonText, String imageLoc, String tooltipText, EventHandler<ActionEvent> actionEventHandler) {
          final Button button = new Button(buttonText);
          button.setTooltip(new Tooltip(tooltipText));
          final ImageView imageView = new ImageView(new Image(getResource(imageLoc)));
          button.setContentDisplay(ContentDisplay.LEFT); // added to keep the display in 2.1b10 compatible with the display in previous versions.
          VBox.setMargin(button, new Insets(0, 5, 0, 5));
          return button;

        // get a resource relative to the application class.
        static String getResource(String path) {
          return Willow.class.getResource(path).toExternalForm();


          Issue Links



              • Assignee:
                dgrieve David Grieve
                josmithjfx John Smith (Inactive)
              • Votes:
                0 Vote for this issue
                4 Start watching this issue


                • Created: