How do I get screen coordinates of String of JButton or JLabel

42 Views Asked by At

When I underlined a custom font it used the default single line underline. However, I want the underline to be the same style as the font which cannot be done. Then I noticed that underscore character can be used as an underline by drawing a string of underscores on top of the text I want underlined.

Now when trying to draw string, I'am having hard time to find the coordinates and I don't want to hardcode coordinates, so I need get the coordinates of the text I want to draw onto.

Apparently the text I'am drawing onto is of JButton and JLabel, and there is no way to get the coordinates of its text.

Any help on getting the coordinates or help on using the style of font on underline would be appreciated.

Edit: By style of the font for the underline, I mean this:

this

0

There are 0 best solutions below