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

Label does not provide TextBoundsType as Text does.

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8u51
    • javafx
    • x86
    • windows_8

      FULL PRODUCT VERSION :
      C:\Users\Owner>java -version
      java version "1.8.0_51"
      Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
      Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

      C:\Users\Owner>

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.3.9600]
      (c) 2013 Microsoft Corporation. All rights reserved.

      C:\Users\Owner>ver

      Microsoft Windows [Version 6.3.9600]


      A DESCRIPTION OF THE PROBLEM :
      The Label class does not have any method of changing its TextBoundsType as the Text class allows. This creates permanent padding of 3px above and below the labels actual text. This can not be changed by using any of the padding, margin, or other css properties because the Label class completely lacks TextBoundsType. It is useful for custom controls such as a dock library or custom tab headers to layout labels that have complete control over the padding and margin of the scene nodes.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Simply create a label and observe the 3px padding margin above and below its actual text. It may help to set the -fx-background-color of the label to red to observe this empty space.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      There should be no padding of the text when a TextBoundsType is specified for the label.
      ACTUAL -
      There is a 3px empty margin above and below the label that can not be configured through css and the user has no control over styling of.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Label label = new Label("Hello, world!");
      label.setStyle("-fx-background-color: red;");
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      The current alternative is to use the Text class and set the TextBoundsType to VISUAL to eliminate this padding. However this is not ideal because this class descends from a different root in the JavaFX class hierarchy. There is no common ancestor of Labeled with accessibility roles that provides the desired behavior.

      SUPPORT :
      YES

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: