JDK-8114225 : A Labeled graphic node bounds can extend outside the bounds of the labeled control
  • Type: Bug
  • Component: javafx
  • Sub-Component: scenegraph
  • Affected Version: fx2.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Not an Issue
  • Submitted: 2011-08-04
  • Updated: 2015-06-16
  • Resolved: 2013-12-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Resolved
Related Reports
Blocks :  
Description
In some cases (I don't know all possible cases) setting max or preferable sizes of control don't make any effect:

Text tx = new Text();
tx.setText("fgggggggggggggggggggggggggggggggggggggggggggggggggg");
Label label = new Label("ee", tx);
label.setMaxWidth(40);
label.setPrefWidth(40);

HBox hb = new HBox();
hb.setMaxWidth(50);
hb.setPrefWidth(50);
hb.getChildren().add(label);

root.getChildren().add(hb);
...

text "fgg...." will be as wide as it need. Text "ee" will not be printed at all. That doesn't seem a proper behavior
Comments
I think this behaviour is correct. The min width should be respected even though max width is smaller. It's already documented in 8.0 in minWidth/minHeight etc.. so we cannot afford to change that in future versions.
11-12-2013

There are two issues at play here. First, the max width on the Label is ignored in this example, since the computed min width is larger. This is described in RT-18309. Second, the graphic node on Label is not expected to be resizable, and should be clipped if it doesn't fit within a Label's set size. Note however, that the text part of a Label is resizable (by truncation) so it will always be reduced to an ellipsis or empty string if the graphic node needs the available space.
30-12-2011

The issue is that a Text node is not resizable, so the Label cannot resize it smaller to fit within it's tighter width bounds. So the label's layoutBounds will be clamped at the 40 max width value, but the internal text node will spill out its edges. The only possible solution would be to set a clip on the Label so at least the text node would be clipped.
19-08-2011

Assigning to Amy for initial review, although it might be a scenegraph issue, or just an individual controls / layout issue.
04-08-2011