diff --git a/cicaprojekt/ApplicationFrame.java b/cicaprojekt/ApplicationFrame.java index 2365b66..e7e7f84 100644 --- a/cicaprojekt/ApplicationFrame.java +++ b/cicaprojekt/ApplicationFrame.java @@ -36,20 +36,21 @@ public class ApplicationFrame implements Runnable } jframe.add(gamepanel); - jframe.revalidate(); + jframe.pack(); + //jframe.revalidate(); //TODO check if needed } } public void init(){ jframe = new JFrame(); jframe.setFocusable(true); - jframe.setMinimumSize(new Dimension(menuDimension)); jframe.setLocationRelativeTo(null); jframe.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); initMapselector(); jframe.add(mapselectorpanel); + jframe.pack(); } public void backToMapSelection() { @@ -57,7 +58,6 @@ public class ApplicationFrame implements Runnable jframe.removeKeyListener(keyHandler); initMapselector(); jframe.add(mapselectorpanel); - jframe.setMinimumSize(menuDimension); jframe.pack(); jframe.revalidate(); } @@ -81,6 +81,7 @@ public class ApplicationFrame implements Runnable Control.ioErrorMessage(); } } + }; DefaultListModel dungeonslist = new DefaultListModel<>(); @@ -99,6 +100,9 @@ public class ApplicationFrame implements Runnable filelist.addMouseListener(new ListMouseHandler()); filelist.setMaximumSize(new Dimension(400, 80)); + mapselectorpanel.setMinimumSize(menuDimension); + mapselectorpanel.setPreferredSize(menuDimension); + mapselectorpanel.setLayout(new BorderLayout()); mapselectorpanel.addMouseListener(new MouseAdapter() { @Override @@ -115,11 +119,11 @@ public class ApplicationFrame implements Runnable private void setGameParams(File dungeonFile) throws IOException { gamepanel = new Display(); - jframe.setMinimumSize(gamepanel.getDimension()); - jframe.pack(); - jframe.addKeyListener(keyHandler); + Game.instance.setDisplay(gamepanel); Game.instance.setDungeon(new Dungeon()); Game.instance.startGame(dungeonFile); + + jframe.addKeyListener(keyHandler); } }