Skip to content

Commit

Permalink
Search superclasses of JFXPanel in case app has subclassed it
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrushforth committed Jan 5, 2024
1 parent c2cd2c1 commit b84dff2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,25 @@ private void trace(String meth) {
*/
}

private static final String JFXPANEL_CLASS_NAME = "javafx.embed.swing.JFXPanel";
private static final Module desktopModule = Component.class.getModule();

private boolean isJFXPanel(Component component) {
// FIXME: need a more robust way to determine this
return "javafx.embed.swing.JFXPanel".equals(component.getClass().getName());
for (Class<?> clazz = component.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
if (desktopModule.equals(clazz.getModule())) {
// Stop searching once we have a class from the desktop module
return false;
} else if (JFXPANEL_CLASS_NAME.equals(clazz.getName())) {
return true;
}
}
return false;
}

private void invokeAndWaitIME(Runnable runnable, Component component)
throws InvocationTargetException {

if (isJFXPanel(component)) {
System.err.println("Detected JFXPanel...run directly");
runnable.run();
} else {
LWCToolkit.invokeAndWait(runnable, component);
Expand Down

0 comments on commit b84dff2

Please sign in to comment.