List of usage examples for javax.swing.plaf.basic BasicGraphicsUtils drawStringUnderlineCharAt
public static void drawStringUnderlineCharAt(Graphics g, String text, int underlinedIndex, int x, int y)
g
at location (x
, y
) just like g.drawString
would. From source file:RenderingUtils.java
/** * Draws the string at the specified location underlining the specified * character./*from w w w. j av a 2 s .c o m*/ * * @param c JComponent that will display the string, may be null * @param g Graphics to draw the text to * @param text String to display * @param underlinedIndex Index of a character in the string to underline * @param x X coordinate to draw the text at * @param y Y coordinate to draw the text at */ public static void drawStringUnderlineCharAt(JComponent c, Graphics g, String text, int underlinedIndex, int x, int y) { if (drawStringUnderlineCharAtMethod != null) { try { drawStringUnderlineCharAtMethod.invoke(null, new Object[] { c, g, text, new Integer(underlinedIndex), new Integer(x), new Integer(y) }); return; } catch (IllegalArgumentException e) { // Use the BasicGraphicsUtils as fallback } catch (IllegalAccessException e) { // Use the BasicGraphicsUtils as fallback } catch (InvocationTargetException e) { // Use the BasicGraphicsUtils as fallback } } Graphics2D g2 = (Graphics2D) g; Map oldRenderingHints = installDesktopHints(g2); BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, underlinedIndex, x, y); if (oldRenderingHints != null) { g2.addRenderingHints(oldRenderingHints); } return; BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, underlinedIndex, x, y); }