Search in sources :

Example 1 with AwtPanelsContext

use of com.jme3.system.awt.AwtPanelsContext in project jmonkeyengine by jMonkeyEngine.

the class TestAwtPanels method main.

public static void main(String[] args) {
    Logger.getLogger("com.jme3").setLevel(Level.WARNING);
    app = new TestAwtPanels();
    app.setShowSettings(false);
    AppSettings settings = new AppSettings(true);
    settings.setCustomRenderer(AwtPanelsContext.class);
    settings.setFrameRate(60);
    app.setSettings(settings);
    app.start();
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            /*
                 * Sleep 2 seconds to ensure there's no race condition.
                 * The sleep is not required for correctness.
                 */
            try {
                Thread.sleep(2000);
            } catch (InterruptedException exception) {
                return;
            }
            final AwtPanelsContext ctx = (AwtPanelsContext) app.getContext();
            panel = ctx.createPanel(PaintMode.Accelerated);
            panel.setPreferredSize(new Dimension(400, 300));
            ctx.setInputSource(panel);
            panel2 = ctx.createPanel(PaintMode.Accelerated);
            panel2.setPreferredSize(new Dimension(400, 300));
            createWindowForPanel(panel, 300);
            createWindowForPanel(panel2, 700);
            /*
                 * Both panels are ready.
                 */
            panelsAreReady.countDown();
        }
    });
}
Also used : AppSettings(com.jme3.system.AppSettings) Dimension(java.awt.Dimension) AwtPanelsContext(com.jme3.system.awt.AwtPanelsContext)

Aggregations

AppSettings (com.jme3.system.AppSettings)1 AwtPanelsContext (com.jme3.system.awt.AwtPanelsContext)1 Dimension (java.awt.Dimension)1