Mercurial > hg > ristipolku
diff Ristipolku.java @ 197:f3302a2d7815
Convert to a Java application, instead of browser applet,
as no browser supports Java applets anymore.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 24 Apr 2019 12:55:54 +0300 |
parents | 64b04c0eccce |
children |
line wrap: on
line diff
--- a/Ristipolku.java Wed Apr 24 12:37:59 2019 +0300 +++ b/Ristipolku.java Wed Apr 24 12:55:54 2019 +0300 @@ -5,25 +5,70 @@ * Ohjelmointiprojekti 2010-2011 Java-kurssille T740306. */ import javax.swing.*; +import java.awt.event.WindowListener; +import java.awt.event.WindowEvent; import game.*; -public class Ristipolku extends JApplet + +public class Ristipolku extends JFrame implements WindowListener { Engine panel; - - public void init() + + public Ristipolku() { + addWindowListener(this); + panel = new Engine(); - getContentPane().add(panel); + + setSize(1024, 768); + add(panel); + setTitle("Ristipolku v"+ G.version); + setVisible(true); } - public void start() + public static void main(String[] args) + { + G.debug("main()\n"); + new Ristipolku(); + G.debug("main() end\n"); + } + + public void windowClosing(WindowEvent e) { + G.debug("windowClosing()\n"); + panel.stopThreads(); + dispose(); + System.exit(0); + } + + public void windowOpened(WindowEvent e) + { + G.debug("windowOpened()\n"); panel.startThreads(); } - public void stop() + public void windowIconified(WindowEvent e) + { + G.debug("windowIconified()\n"); + } + + public void windowClosed(WindowEvent e) + { + G.debug("windowClosed()\n"); + } + + public void windowDeiconified(WindowEvent e) { - panel.stopThreads(); + G.debug("windowDeiconified()\n"); + } + + public void windowActivated(WindowEvent e) + { + G.debug("windowActivated()\n"); + } + + public void windowDeactivated(WindowEvent e) + { + G.debug("windowDeactivated()\n"); } }