Reworked window size handling

Window is now resized properly at all times to embed the current frame purrfectly
This commit is contained in:
Bokros Bálint 2016-05-14 02:51:34 +02:00 committed by Kjistóf
parent 4f11f60b50
commit 80ff3e4383

View File

@ -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<File> 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);
}
}