Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Zitat von »"Mordrak"«
Die "Loesung", eine Batchdatei fuer den Programmstart zu schreiben, klingt nicht so recht, als waere sie im Sinne des Erfinders...
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
import java.awt.event.*; import java.awt.Color; import java.awt.DisplayMode; import java.awt.Frame; import java.awt.Graphics; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Rectangle; import java.awt.image.BufferStrategy; import java.lang.*; import java.util.Date; public class Main implements Runnable, KeyListener { protected Frame frame; protected GraphicsDevice graphicsdevice; protected Thread animation; public static void main( String[] Args ) { new Main(); } Main() { animation = new Thread( this ); graphicsdevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); frame = new Frame( graphicsdevice.getDefaultConfiguration() ); frame.setUndecorated( true ); frame.setIgnoreRepaint( true ); frame.setResizable( false ); frame.addKeyListener( this ); graphicsdevice.setFullScreenWindow( frame ); if (graphicsdevice.isDisplayChangeSupported()) { try { graphicsdevice.setDisplayMode( new DisplayMode( 1280, 1024, 32, DisplayMode.REFRESH_RATE_UNKNOWN ) ); } catch (Exception e) { System.out.println( "Display mode error" ); System.exit( 0 ); } } animation.start(); } public void run() { Thread t = Thread.currentThread(); frame.createBufferStrategy( 2 ); while (t == animation) { BufferStrategy bufferstrategy = frame.getBufferStrategy(); do { Graphics2D g2d = (Graphics2D) bufferstrategy.getDrawGraphics(); paintFrame( g2d ); bufferstrategy.show(); g2d.dispose(); } while (bufferstrategy.contentsLost()); try { Thread.sleep( 33 ); } catch (Exception e) { } } } public void paintFrame( Graphics2D g ) { // ... Zeichnen } public void keyPressed( KeyEvent e ) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { animation = null; System.out.println( "bye" ); System.exit( 0 ); } } public void keyReleased( KeyEvent e ) { } public void keyTyped( KeyEvent e ) { } } |
Zitat von »"MasterK"«
Zitat von »"Mordrak"«
Die "Loesung", eine Batchdatei fuer den Programmstart zu schreiben, klingt nicht so recht, als waere sie im Sinne des Erfinders...
Warum nicht?
Quellcode |
|
1 2 3 4 5 6 |
frame = new JFrame("Title"); console = new IOConsole(); frame.getContentPane().add(BorderLayout.CENTER, console); frame.setVisible(true); console.print("Hello"); |
Werbeanzeige