home *** CD-ROM | disk | FTP | other *** search
- package opera;
-
- import java.awt.Frame;
- import java.lang.reflect.Method;
-
- class AppContextAdapter {
- Object appContext = null;
- ThreadGroup threadGroup = null;
- boolean isDisposed = false;
-
- public void create() {
- this.threadGroup = Thread.currentThread().getThreadGroup();
-
- try {
- Class var1 = Class.forName("sun.awt.SunToolkit");
- if (var1 != null) {
- Method var2 = var1.getMethod("createNewAppContext", (Class[])null);
- this.appContext = var2.invoke((Object)null, (Object[])null);
- }
- } catch (Exception var3) {
- }
-
- }
-
- public void dispose() throws IllegalThreadStateException {
- try {
- if (this.appContext != null) {
- Method var1 = this.appContext.getClass().getMethod("dispose", (Class[])null);
- var1.invoke(this.appContext, (Object[])null);
- } else {
- if (this.threadGroup.parentOf(Thread.currentThread().getThreadGroup())) {
- throw new IllegalThreadStateException("Current Thread is contained within AppContext to be disposed.");
- }
-
- synchronized(this) {
- if (this.isDisposed) {
- return;
- }
-
- this.isDisposed = true;
- }
-
- this.disposeFrames();
- this.interruptThreads();
- }
- } catch (Exception var4) {
- var4.printStackTrace(System.err);
- }
-
- }
-
- private void disposeFrames() {
- Frame[] var1 = Frame.getFrames();
-
- for(int var2 = var1.length - 1; var2 >= 0; --var2) {
- var1[var2].dispose();
- }
-
- }
-
- private void interruptThreads() {
- this.threadGroup.interrupt();
- }
- }
-