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

MenuButton label padding is not ignored for ignored labels

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 10
    • 8, 9
    • javafx

      I noticed that when setting a menu button's content-display to graphic-only, the label padding still affects the layout of the button. Specifically, I noticed that the icon I wanted to show on the button was moved enough right to look out of center.

      There may be a technical reason for this, but it sure is counter intuitive that when you explicitly state "graphic-only" you still have to set the -fx-padding of the label to 0. It is this sort of thing which makes JavaFX harder to learn.

      Here is the styling I used

      .my-button, .my-button:focused {
      -fx-content-display: graphic-only;
      }

      This shows a MenuButton with my icon slightly moved right. To avoid that I added this css.

      .my-button .label {
      -fx-padding: 0;
      }

      which works.

            aghaisas Ajit Ghaisas
            risaksen Randahl Isaksen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: