Create a new method to provide underline shape (a line under text in the range), similar to Text.underlineShape():
/**
* Returns the shape for the underline in local coordinates.
*
* @param start the beginning character index for the range
* @param end the end character index (non-inclusive) for the range
* @return an array of {@code PathElement} which can be used to create a {@code Shape}
* @since 21
*/
public final PathElement[] underlineShape(int start, int end) {
return getRange(start, end, TextLayout.TYPE_UNDERLINE);
}
FYI.
The shapes being returned is not a line but a rectangle (moveto + lineto segments). There seems to be somewhat complicated logic that constructs a simple line in TextInputControl.createInputMethodAttributes()