changeset 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 76322f932276
children b88440f4431a
files Makefile Ristipolku.html Ristipolku.java
diffstat 3 files changed, 54 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Wed Apr 24 12:37:59 2019 +0300
+++ b/Makefile	Wed Apr 24 12:55:54 2019 +0300
@@ -66,8 +66,8 @@
 	$(COMPILE_OBJ)
 
 
-run: $(RUN)
-	$(APPLETVIEWER) $(patsubst %.class,%.html,$<)
+run: $(MAINCLASS)
+	@$(JAVA) $(JAVA_FLAGS) $(patsubst %.class,%,$<)
 
 
 ###
--- a/Ristipolku.html	Wed Apr 24 12:37:59 2019 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Ristipolku</title>
- <style type="text/css">
-  body { background: black; color: white; font-family: Arial, Verdana, sans-serif; }
-  h1 { color: white; font-size: 14pt; }
-  div.applet { text-align: center; vertical-align: center; width: 100%; height: 100%; }
-  p.copyright { font-size: 8pt; text-align: center; }
- </style>
-</head>
-<body>
-<div class="applet">
-<applet code="Ristipolku.class" archive="Ristipolku.jar" width="1024" height="768"></applet>
-</div>
-<p class="copyright">&copy; Copyright 2011 Matti 'ccr' H&auml;m&auml;l&auml;inen</p>
-</body>
-</html>
--- 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");
     }
 }