# HG changeset patch # User Matti Hamalainen # Date 1489653878 -7200 # Node ID 9d3ff9605555bf60e761efb70df7cceec09aaaa9 # Parent 55ea5821c802289569246ad9f57a904d9fbf61d7 Change AboutBox to a "dialog" and implement Ok/close button for closing it. diff -r 55ea5821c802 -r 9d3ff9605555 game/Engine.java --- 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(); + } + } }