Created
February 19, 2020 11:08
-
-
Save wcmatthysen/cb107a149e1f6888170a4e3afda15bc8 to your computer and use it in GitHub Desktop.
Set heavyweight tooltip popups for any component in Swing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class ComponentUtils { | |
private ComponentUtils() { } | |
public static void forceHeavyWeightPopups(JComponent component) { | |
try { | |
Class<?> clazz = Class.forName("javax.swing.ClientPropertyKey"); | |
Field field = clazz.getDeclaredField("PopupFactory_FORCE_HEAVYWEIGHT_POPUP"); | |
field.setAccessible(true); | |
component.putClientProperty(field.get(null), Boolean.TRUE); | |
} catch (ClassNotFoundException | IllegalAccessException | IllegalArgumentException | NoSuchFieldException | SecurityException e) { | |
throw new RuntimeException("Couldn't force heavyweight popups on component: " + component, e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment