Is it possible to set the underline offset when using Font.UNDERLINED? I am using the following to make the font underlined:
LabelField lf = new LabelField("Forgot your password?");
lf.setFont(Font.getDefault().derive(Font.BOLD | Font.UNDERLINED));
The above code produces
I want the underline to appear at the font's bottommost position. Like this:
Solutions I can think of:
One possible solution would be to extend
LabelField
and override itspaint()
method. Something in the form:paint(Graphics g) { super.paint(g); g.drawLine(...); }
The above code will work fine as long as
LabelField
's contents will occupy a single line. It will become very messy once the contents will occupy multiple lines. Therefore, I am looking for a more appropriate solution.Another solution would be to write a new field similar to
LabelField
from scratch.