Java Code Examples for sun.awt.SunToolkit#createNewAppContext()

The following examples show how to use sun.awt.SunToolkit#createNewAppContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DisplayChangesException.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private void test() throws Exception {
    SunToolkit.createNewAppContext();
    EventQueue.invokeAndWait(() -> {
        frame = new JFrame();
        final JButton b = new JButton();
        b.addPropertyChangeListener(evt -> {
            if (!SunToolkit.isDispatchThreadForAppContext(b)) {
                System.err.println("Wrong thread:" + currentThread());
                fail = true;
            }
        });
        frame.add(b);
        frame.setSize(100, 100);
        frame.setLocationRelativeTo(null);
        frame.pack();
    });
    go.await();
    EventQueue.invokeAndWait(() -> {
        frame.dispose();
    });
}
 
Example 2
Source File: Test6588003.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    SunToolkit.createNewAppContext();

    if (LayoutQueue.getDefaultQueue() == DEFAULT) {
        throw new RuntimeException("Sharing detected");
    }

    LayoutQueue.setDefaultQueue(new LayoutQueue());
}
 
Example 3
Source File: Test6657026.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    SunToolkit.createNewAppContext();
    if (new JSplitPane().getFocusTraversalKeys(0).isEmpty()) {
        throw new Error("shared traversal keys");
    }
    JSplitPane pane = new JSplitPane();
    pane.setUI(this);

    createFocusListener().focusGained(null); // allows actions
    test(pane, "positiveIncrement", 3);
    test(pane, "negativeIncrement", 0);
}
 
Example 4
Source File: AppletClassLoader.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void run()  {
    appContext = SunToolkit.createNewAppContext();
    created = true;
    synchronized(syncObject) {
        syncObject.notifyAll();
    }
}
 
Example 5
Source File: Test8012933.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void createAppContext() {
    isCreated = false;
    final Runnable runnable = new Runnable() {
            public void run() {
                appContext = SunToolkit.createNewAppContext();
                synchronized (lock) {
                    isCreated = true;
                    lock.notifyAll();
                }
            }
        };

    final Thread thread = new Thread(threadGroup, runnable, "creates app context");
    synchronized (lock) {
        thread.start();
        while (!isCreated) {
            try {
                lock.wait();
            } catch (InterruptedException ie) {
                ie.printStackTrace();
            }
        }
    }

    if (appContext == null) {
        throw new RuntimeException("failed to create app context.");
    } else {
        System.out.println("app context was created.");
    }
}
 
Example 6
Source File: Test8012933.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void createAppContext() {
    isCreated = false;
    final Runnable runnable = new Runnable() {
            public void run() {
                appContext = SunToolkit.createNewAppContext();
                synchronized (lock) {
                    isCreated = true;
                    lock.notifyAll();
                }
            }
        };

    final Thread thread = new Thread(threadGroup, runnable, "creates app context");
    synchronized (lock) {
        thread.start();
        while (!isCreated) {
            try {
                lock.wait();
            } catch (InterruptedException ie) {
                ie.printStackTrace();
            }
        }
    }

    if (appContext == null) {
        throw new RuntimeException("failed to create app context.");
    } else {
        System.out.println("app context was created.");
    }
}
 
Example 7
Source File: bug6938813.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    SunToolkit.createNewAppContext();

    try {
        validate();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example 8
Source File: bug6657138.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    SunToolkit.createNewAppContext();
    try {
        testUIMap();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example 9
Source File: bug6938813.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    SunToolkit.createNewAppContext();

    try {
        validate();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example 10
Source File: Test6657026.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    SunToolkit.createNewAppContext();
    if (new JSplitPane().getFocusTraversalKeys(0).isEmpty()) {
        throw new Error("shared traversal keys");
    }
    JSplitPane pane = new JSplitPane();
    pane.setUI(this);

    createFocusListener().focusGained(null); // allows actions
    test(pane, "positiveIncrement", 3);
    test(pane, "negativeIncrement", 0);
}
 
Example 11
Source File: Test6657026.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    SunToolkit.createNewAppContext();
    if (UIManager.getInstalledLookAndFeels().length == 0) {
        throw new Error("shared look&feels");
    }
}
 
Example 12
Source File: Test8012933.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    SunToolkit.createNewAppContext();
    new Test8012933().test();
}
 
Example 13
Source File: Test6657026.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    SunToolkit.createNewAppContext();
    if (UIManager.getInstalledLookAndFeels().length == 0) {
        throw new Error("shared look&feels");
    }
}
 
Example 14
Source File: TestMainAppContext.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String... args) throws Exception {
    ThreadGroup rootTG = Thread.currentThread().getThreadGroup();
    while (rootTG.getParent() != null) {
        rootTG = rootTG.getParent();
    }

    ThreadGroup tg = new ThreadGroup(rootTG, "FakeApplet");
    final Thread t1 = new Thread(tg, "createNewAppContext") {
        @Override
        public void run() {
            try {
                AppContext context = SunToolkit.createNewAppContext();
            } catch(Throwable t) {
                thrown = t;
            }
        }
    };
    t1.start();
    t1.join();
    if (thrown != null) {
        throw new RuntimeException("Unexpected exception: " + thrown, thrown);
    }
    Thread t2 = new Thread(tg, "BugDetector") {

        @Override
        public void run() {
            try {
                Logger.getLogger("foo").info("Done");
            } catch (Throwable x) {
                thrown = x;
            }
        }

    };

    System.setSecurityManager(new SecurityManager());
    t2.start();
    t2.join();
    if (thrown != null) {
        throw new RuntimeException("Test failed: " + thrown, thrown);
    }

}
 
Example 15
Source File: TestMainAppContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String... args) throws Exception {
    ThreadGroup rootTG = Thread.currentThread().getThreadGroup();
    while (rootTG.getParent() != null) {
        rootTG = rootTG.getParent();
    }

    ThreadGroup tg = new ThreadGroup(rootTG, "FakeApplet");
    final Thread t1 = new Thread(tg, "createNewAppContext") {
        @Override
        public void run() {
            try {
                AppContext context = SunToolkit.createNewAppContext();
            } catch(Throwable t) {
                thrown = t;
            }
        }
    };
    t1.start();
    t1.join();
    if (thrown != null) {
        throw new RuntimeException("Unexpected exception: " + thrown, thrown);
    }
    Thread t2 = new Thread(tg, "BugDetector") {

        @Override
        public void run() {
            try {
                Logger.getLogger("foo").info("Done");
            } catch (Throwable x) {
                thrown = x;
            }
        }

    };

    System.setSecurityManager(new SecurityManager());
    t2.start();
    t2.join();
    if (thrown != null) {
        throw new RuntimeException("Test failed: " + thrown, thrown);
    }

}
 
Example 16
Source File: Test6657026.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    SunToolkit.createNewAppContext();
    IS_PALETTE = JInternalFrame.CONTENT_PANE_PROPERTY;
}
 
Example 17
Source File: Test8012933.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    SunToolkit.createNewAppContext();
    new Test8012933().test();
}
 
Example 18
Source File: MultipleContextsUnitTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static Thread testThread(int index) {
    final ThreadGroup group = new ThreadGroup("TG " + index);
    return new Thread(group, () -> {
        apps[index] = SunToolkit.createNewAppContext();
    });
}
 
Example 19
Source File: Test6657026.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    SunToolkit.createNewAppContext();
    if (UIManager.getInstalledLookAndFeels().length == 0) {
        throw new Error("shared look&feels");
    }
}
 
Example 20
Source File: Test8012933.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    SunToolkit.createNewAppContext();
    new Test8012933().test();
}