Skip to content

Commit 0a98a72

Browse files
committed
allows for getting the HTML5 applet using Thread instead of a component
1 parent 2adae6f commit 0a98a72

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

sources/net.sf.j2s.java.core/src/swingjs/JSToolkit.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,17 @@ public static void setIsDispatchThread(boolean b) {
468468
// // NO LONGER NECESSARY :)
469469
// }
470470

471+
/**
472+
* Get the applet associated with the specified component or, if that is null,
473+
* the current thread. This could be an important issue if one applet is running
474+
* code in a different applet.
475+
*
476+
* @param c
477+
* @return
478+
*/
471479
public static HTML5Applet getHTML5Applet(Component c) {
472-
return ((JSThreadGroup) c.getAppContext().getThreadGroup()).getHtmlApplet();
480+
ThreadGroup g = (c == null ? Thread.currentThread().getThreadGroup() : c.getAppContext().getThreadGroup());
481+
return ((JSThreadGroup) g).getHtmlApplet();
473482
}
474483

475484
public static void taintUI(Component c) {

0 commit comments

Comments
 (0)