External Publication
Visit Post

Swing(jFrame) can not initialize

jMonkeyEngine Hub May 29, 2026
Source

I think this is a good opportunity to test lwjglx-awt’s compatibility with jme on macOS, as I’m only certain that the awt backend works on Linux (x11/XWayland) and Windows.

Therefore, I would like to ask the following question:

  1. How did you integrate JME3 with AWT?
  2. Does the JVM fail when running JME3 with LWJGL3 using AWT (break)?
  3. Does the canvas remain blank?
  4. Does the screen or canvas reach a point where it turns black?
  5. Is AWT frozen (not allowing interaction)?
  6. What logs does JME3 generate? (very important)
  7. Have you tried version 3.10.0-alpha5? That version improved the integration of lwjgl3 (lwjgl3-awt) with awt.

Because if you use lwjgl3, jme3 uses lwjgl3-awt as a means to create the GL context.

To isolate the problem, ideally you would test jme3 with awt using a simple example, and lwjgl3-awt in an isolated environment, to determine where the problem lies (whether it is in jme3 or in lwjgl3-awt).


For example (JME3 - lwjgl3):

import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.system.AppSettings;
import com.jme3.system.JmeCanvasContext;

import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class SimpleAWT extends SimpleApplication {

    public static void main(String[] args) {
        SimpleAWT app = new SimpleAWT();

        AppSettings settings = new AppSettings(true);
        settings.setTitle("AWT - Simple");
        settings.setRenderer(AppSettings.LWJGL_OPENGL45);


        app.setSettings(settings);
        app.createCanvas();
        app.startCanvas();

        JmeCanvasContext ctx = (JmeCanvasContext) app.getContext();
        Canvas canvas = ctx.getCanvas();

        final JFrame window = new JFrame();
        window.setTitle("OpenGL Triangle");
        window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        window.setLayout(new BorderLayout());
        window.setPreferredSize(new Dimension(640, 480));

        window.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosed(WindowEvent e) {
                app.stop();
            }
        });

        window.add(canvas);
        window.pack();

        KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(e -> {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE && e.getID() == KeyEvent.KEY_PRESSED) {
                window.dispose();
                return true;
            }
            return false;
        });

        EventQueue.invokeLater(() -> {
            window.setVisible(true);
        });
    }

    private Geometry geom;

    @Override
    public void simpleInitApp() {
        flyCam.setEnabled(false);

        Box b = new Box(1, 1, 1);
        geom = new Geometry("Box", b);

        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setColor("Color", ColorRGBA.Blue);
        geom.setMaterial(mat);

        rootNode.attachChild(geom);

    }

    @Override
    public void simpleUpdate(float tpf) {
        geom.rotate(new Quaternion().fromAngleAxis(0.6f * tpf, Vector3f.UNIT_XYZ));
    }
}

When you run it, it should generate messages:

may 29, 2026 1:50:10 P.�M. com.jme3.system.JmeDesktopSystem initialize
INFORMACI�N: Running on jMonkeyEngine 3.10.0-SNAPSHOT
 * Branch: master
 * Git Hash: b00c824
 * Build Date: 2026-05-29
...
may 29, 2026 1:50:11 P.�M. com.jme3.system.lwjgl.LwjglCanvas createContext
ADVERTENCIA: LWJGLX and AWT/Swing only work with X11, so XWayland will be used for GLX.
may 29, 2026 1:50:11 P.�M. com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFORMACI�N: LWJGL 3.4.1+2 context running on thread jME3 Main
 * Video backend: AWT|Swing (LWJGLX) GLv4.5 Linux (XWayland|X11) GLX
may 29, 2026 1:50:11 P.�M. com.jme3.system.lwjgl.LwjglCanvas printContextInitInfo
INFORMACI�N: Initializing LWJGL3-AWT with jMonkeyEngine
 *  Double Buffer: true
 *  Stereo: false
 *  Red Size: 8
 *  Green Size: 8
 *  Blue Size: 8
 *  Alpha Size: 0
 *  Depth Size: 24
 *  Stencil Size: 0
 *  Accum Red Size: 0
 *  Accum Green Size: 0
 *  Accum Blue Size: 0
 *  Accum Alpha Size: 0
 *  Sample Buffers: 0
 *  Share Context: null
 *  Major Version: 4
 *  Minor Version: 5
 *  Forward Compatible: false
 *  Profile: COMPATIBILITY
 *  API: GL
 *  Debug: false
 *  Swap Interval: 1
 *  SRGB (Gamma Correction): true
 *  Pixel Format Float: false
 *  Context Release Behavior: null
 *  Color Samples NV: 0
 *  Swap Group NV: 0
 *  Swap Barrier NV: 0
 *  Robustness: false
 *  Lose Context On Reset: false
 *  Context Reset Isolation: false
...

If the JVM fails, it typically generates a .log file containing information that can help determine where the corruption occurred (for example, a native - JNI call).

Discussion in the ATmosphere

Loading comments...