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

TextField reports zero preferred height from computePrefHeight()



    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Incomplete
    • Affects Version/s: 7u6
    • Fix Version/s: 8u20
    • Component/s: javafx
    • Labels:
    • Environment:

      Win 7


      I have a TabPane with multiple tabs. When the user interacts with the tab A, then tab B's content may change. On tab B is a Region which contains a Pane, and in that Pane is a TextField. The first time tab B becomes selected, the TextField is shown, and all is well. Then, with Tab A selected, the Region's children are swapped a few times, and flipping back to Tab B the TextField is not shown. That's because the TextField reports a zero pref height to the layout manager when the content of the region is swapped, and nothing calls for a new layout pass when the tab is shown again. A new layout pass is called for the first time the tab is shown, which is why the first showing looks fine, but not on subsequent showings.

      My problem is not with when a layout pass is called for, as this behavior is probably correct. My problem is that the TextField is reporting a zero pref height. I can understand that this happens the very first time, because the Stage has not been shown. However, when replacing the Pane within the Region on Tab B, while Tab A is selected, a layout pass is called for on Tab B, and the TextField reports a zero pref height, even though it's part of a currently showing scene graph, on a currently showing Stage. The tab the TextField is on may not be currently showing, but it should have a valid Font and all the info it needs to know what it's pref height should be. But it reports zero, and then, when selected, no re-layout occurs and I get no TextField (or a zero height field in any case).

      TextField should report a non-zero pref height when part of a shown graph, whether or not it's portion of the graph is currently painted.




            jgiles Jonathan Giles
            dberkmanjfx David Berkman (Inactive)
            0 Vote for this issue
            2 Start watching this issue