changeset 176:9d3ff9605555

Change AboutBox to a "dialog" and implement Ok/close button for closing it.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 16 Mar 2017 10:44:38 +0200
parents 55ea5821c802
children 9f04e8ab180a
files game/Engine.java
diffstat 1 files changed, 19 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/game/Engine.java	Thu Mar 16 10:42:54 2017 +0200
+++ b/game/Engine.java	Thu Mar 16 10:44:38 2017 +0200
@@ -20,14 +20,17 @@
 import javax.sound.sampled.*;
 
 
-class AboutBox extends IDMWidget
+class AboutBox extends IDMContainer
 {
     BufferedImage aboutImg;
 
     public AboutBox()
     {
         setPos(150f, 150f);
-        setSize(720f, 420f);
+        setSize(720f, 470f);
+        setModal(true);
+
+        add(new BtnOK(500f, 390f));
     }
 
     public void paint(Graphics2D g)
@@ -74,18 +77,26 @@
         "and placing pieces. More points will be awarded for\n"+
         "advancing the path by several segments per turn."
         );
-    }
-
-    public boolean keyPressed(KeyEvent e)
-    {
-        clicked();
-        return true;
+        super.paint(g);
     }
 
     public void clicked()
     {
         parent.remove(this);
     }
+
+    class BtnOK extends IDMButton
+    {
+        public BtnOK(float x, float y)
+        {
+            super(x, y, KeyEvent.VK_ESCAPE, G.fonts[1], "OK");
+        }
+
+        public void clicked()
+        {
+            parent.clicked();
+        }
+    }
 }