List of usage examples for javax.swing.text Highlighter.HighlightPainter getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:Main.java
/** * Determines whether the SelectedTextColor should be used for painting text * foreground for the specified highlight. * * Returns true only if the highlight painter for the specified highlight * is the swing painter (whether inner class of javax.swing.text.DefaultHighlighter * or com.sun.java.swing.plaf.windows.WindowsTextUI) and its background color * is null or equals to the selection color of the text component. * * This is a hack for fixing both bugs 4761990 and 5003294 *//*from w ww . j av a 2s.c o m*/ public static boolean useSelectedTextColor(Highlighter.Highlight h, JTextComponent c) { Highlighter.HighlightPainter painter = h.getPainter(); String painterClass = painter.getClass().getName(); if (painterClass.indexOf("javax.swing.text.DefaultHighlighter") != 0 && painterClass.indexOf("com.sun.java.swing.plaf.windows.WindowsTextUI") != 0) { return false; } try { DefaultHighlighter.DefaultHighlightPainter defPainter = (DefaultHighlighter.DefaultHighlightPainter) painter; if (defPainter.getColor() != null && !defPainter.getColor().equals(c.getSelectionColor())) { return false; } } catch (ClassCastException e) { return false; } return true; }