Reworked window size handling
Window is now resized properly at all times to embed the current frame purrfectly
This commit is contained in:
parent
4f11f60b50
commit
80ff3e4383
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user