Skip to content

Instantly share code, notes, and snippets.

@Blunderchips
Created January 5, 2018 15:50
Show Gist options
  • Save Blunderchips/04c6f38d2eb7151e88f69870f7d24646 to your computer and use it in GitHub Desktop.
Save Blunderchips/04c6f38d2eb7151e88f69870f7d24646 to your computer and use it in GitHub Desktop.
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.badlogic.gdx.backends.lwjgl.LwjglCanvas;
import java.awt.Canvas;
import javax.swing.JFrame;
import javax.swing.JPanel;
public final class SwingWindow extends JFrame {
public SwingWindow() {
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
cfg.width = 800;
cfg.height = 60;
super.setSize(cfg.width, cfg.height);
super.setTitle(cfg.title);
JPanel panel = new JPanel();
Canvas canvas = new LwjglCanvas(new ApplicationAdapter() {}, cfg).getCanvas();
canvas.setBounds(0, 0, super.getWidth(), super.getHeight());
panel.add(canvas);
super.add(panel);
super.setLocationRelativeTo(null);
super.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
super.setUndecorated(true);
super.setLocationRelativeTo(null);
}
@Override
public void dispose() {
super.dispose();
Gdx.app.exit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment