public static void drawStringUnderlineCharAt( JComponent c, Graphics g,
		String text, int underlinedIndex, int x, int y )
	{
		synchronized( JavaCompatibility.class ) {
			if( drawStringUnderlineCharAtMethod == null ) {
				try {
					Class<?> cls = Class.forName( SystemInfo.isJava_9_orLater
						? "javax.swing.plaf.basic.BasicGraphicsUtils"
						: "sun.swing.SwingUtilities2" );
					MethodType mt = MethodType.methodType( void.class, SystemInfo.isJava_9_orLater
						? new Class[] { JComponent.class, Graphics2D.class, String.class, int.class, float.class, float.class }
						: new Class[] { JComponent.class, Graphics.class, String.class, int.class, int.class, int.class } );
					drawStringUnderlineCharAtMethod = MethodHandles.publicLookup().findStatic( cls, "drawStringUnderlineCharAt", mt );
				} catch( Exception ex ) {
					LoggingFacade.INSTANCE.logSevere( null, ex );
					throw new RuntimeException( ex );
				}
			}
		}

		try {
			if( SystemInfo.isJava_9_orLater )
				drawStringUnderlineCharAtMethod.invoke( c, (Graphics2D) g, text, underlinedIndex, (float) x, (float) y );
			else
				drawStringUnderlineCharAtMethod.invoke( c, g, text, underlinedIndex, x, y );
		} catch( Throwable ex ) {
			LoggingFacade.INSTANCE.logSevere( null, ex );
			throw new RuntimeException( ex );
		}
	}
Java 8: sun.swing.SwingUtilities2.drawStringUnderlineCharAt( JComponent c,
				Graphics g, String text, int underlinedIndex, int x, int y )
<br>
Java 9: javax.swing.plaf.basic.BasicGraphicsUtils.drawStringUnderlineCharAt( JComponent c,
				Graphics2D g, String string, int underlinedIndex, float x, float y )
flatlaf-core/src/main/java/com/formdev/flatlaf/util/JavaCompatibility.java