List of usage examples for com.badlogic.gdx.backends.lwjgl LwjglApplication LwjglApplication
public LwjglApplication(ApplicationListener listener, LwjglApplicationConfiguration config,
LwjglGraphics graphics)
From source file:es.eucm.ead.guitools.exportergui.AndroidExporterGUI.java
License:Open Source License
public AndroidExporterGUI(AndroidExporterGUI.ExportListener listener) { LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration(); cfg.title = ""; cfg.useGL20 = true;/* ww w . ja va 2s. co m*/ cfg.width = 400; cfg.height = 320; cfg.fullscreen = false; cfg.forceExit = true; Canvas c = new Canvas(); c.setSize(cfg.width, cfg.height); this.add(c); this.pack(); this.setResizable(false); this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); final ExporterApplicationListener app = new ExporterApplicationListener(this, listener); new LwjglApplication(app, cfg, c); this.addComponentListener(new ComponentAdapter() { @Override public void componentHidden(ComponentEvent e) { app.saveProperties(); } }); }
From source file:org.ah.gcode.preview.desktop.GCodePreviewLauncher.java
License:Open Source License
public static boolean startApp(File gcodeFile, boolean forceExit) { GCodePreview gCodePreview = new GCodePreview(); // FileHandle gcodeFile = Gdx.files.internal(fileName); try {//from w w w. ja v a 2s .co m InputStream gcodeStream = new FileInputStream(gcodeFile); try { List<String> lines = Files.readLines(gcodeStream); gCodePreview.setLines(lines); } finally { gcodeStream.close(); } } catch (IOException e) { System.err.println("There is a problem loading file " + gcodeFile.getAbsolutePath()); e.printStackTrace(); System.exit(1); } final BooleanBox res = new BooleanBox(); // TODO 1.8 gCodePreview.setExitCallback(new ExitCallback() { @Override public void exit(boolean success) { res.set(success); app.exit(); } }); // () -> app.exit() // ); LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.forceExit = forceExit; config.width = 1024; config.height = 768; config.disableAudio = true; Canvas canvas = new Canvas(); final JFrame frame = new JFrame(); frame.setSize(1024, 768); if (forceExit) { frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } frame.setLocationRelativeTo(null); frame.add(canvas); frame.setVisible(true); frame.addWindowListener(new WindowListener() { @Override public void windowOpened(WindowEvent e) { } @Override public void windowIconified(WindowEvent e) { } @Override public void windowDeiconified(WindowEvent e) { } @Override public void windowDeactivated(WindowEvent e) { } @Override public void windowClosing(WindowEvent e) { } @Override public void windowClosed(WindowEvent e) { res.set(true); app.exit(); } @Override public void windowActivated(WindowEvent e) { } }); app = new LwjglApplication(gCodePreview, config, canvas); Thread threadKeepToFront = new Thread(new Runnable() { @Override public void run() { long startedAt = System.currentTimeMillis(); sleep(3000); while (!res.received && System.currentTimeMillis() - startedAt < 5100) { sleep(500); if (!res.received) { frame.setAlwaysOnTop(true); frame.toFront(); frame.requestFocus(); frame.setAlwaysOnTop(false); } } } }); threadKeepToFront.start(); boolean r = res.get(); frame.setVisible(false); frame.dispose(); return r; }
From source file:org.oscim.theme.comparator.vtm.VtmPanel.java
License:Open Source License
public VtmPanel(MapApplicationAdapter.MapReadyCallback callback) { this.setLayout(null); LwjglApplicationConfiguration.disableAudio = true; LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.width = 300;// w w w.j a v a2s .co m config.height = 300; appListener = new MapApplicationAdapter(callback); new LwjglApplication(appListener, config, vtmCanvas); this.add(vtmCanvas); this.setSize(350, 350); this.setBorder(BorderFactory.createTitledBorder("VTM-Map")); this.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { super.componentResized(e); boundsChanged(); } @Override public void componentMoved(ComponentEvent e) { super.componentMoved(e); boundsChanged(); } }); boundsChanged(); }