I have created a custom color picker control for JavaFX 8. It consists of six Sliders in a GridPane with respective Labels above them.
<GridPane vgap="10" hgap="10">
<Label labelFor="${redSlider}" text="Red"
GridPane.rowIndex="0" GridPane.columnIndex="0" GridPane.halignment="CENTER"/>
<!-- 5 more labels -->
<Slider max="255" orientation="VERTICAL" fx:id="redSlider" id="redSlider"
GridPane.rowIndex="1" GridPane.columnIndex="0" GridPane.vgrow="ALWAYS"
GridPane.hgrow="ALWAYS" GridPane.halignment="CENTER"/>
<!-- 5 more Sliders -->
</GridPane>
Now, when I narrow the picker, the labels' texts overflow.
What I'd like to happen here is that the texts would change to their first letters R, G, B, H, S, L instead of the clipped version with the ellipses.
Label's textOverrun property allows setting the overflow mode to the seven values defined in OverrunStyle, but none of those match what I'm looking for.
Looking inside the Label class, the displayed text is calculated by the Skin. In my JDK, this goes straight to com.sun.javafx.scene.control.skin.LabeledSkinBase.updateDisplayedText() which then calls com.sun.javafx.scene.control.skin.Utils.computeClippedText(). There's really no easy way to modify this stuff by extending Label since it's non-portable; one would have to reimplement the entire Skin, which is basically the full implementation of the Label's UI.
Is there a portable way to make the Labels' texts contract to a single character when overflowing other than implementing your own Skin?
UPDATE: I implemented @VGR's answer as a reusable class. You can get it here: https://bitbucket.org/snippets/Pietu1998/LEqXo

