# Slick2D: Resizing the Window

I am using Slick2D, and I wanted to know which is the best way to resize, maximize, minimize the window, For example, Resizing all the images or scaling them, or Slick2D has an integrated method, Any help is appreciated.

• What have you tried? Have you tried, for example, reading the documentation? – Josh Apr 10 '14 at 22:04
• @JoshPetrie While you pointed to something that is relevant to the question, I feel you are being a bit harsh... this question is a bit specific to 'common'/'best' practice for this specific library, for window resizing, whether it be for initialization of the window (what you pointed to) or active resizing, which I answered here: stackoverflow.com/questions/22153057/… – Samich Apr 10 '14 at 22:17
• @Samich I tried this but the image its not being resized, I have to make a code to loop for all the images and scale them relative to the Display size? – Zaphyk Apr 10 '14 at 23:35
• Sorry, I didnt saw but I have an Error. Failed to find value mode: 1366x706 fs=true – Zaphyk Apr 10 '14 at 23:46
• Forgot to include the graphics scaling. I've put up an answer, hopefully that will guide you in the right direction :) And the Display resizing code I mentioned in the question I posted above, you would put that code in your update method, and the Display.setResizable(true) in your main method. – Samich Apr 11 '14 at 0:40

If you want to resize your images, scaled to the window size, you will need to scale your Graphics object in your render method.

To do this properly, you will need to make your game with a predetermined resolution (kind of like, the starting resolution of your game, that all users would start with.) Lets say you are writing a game with the window size 640x480.

This would make your base resolution width 640, and your base resolution height 480.

In the top line of your render method, you would type:

graphics.scale(Display.getWidth()/baseWidth, Display.getHeight()/baseHeight);


and then you would just draw your images as you would normally.

• Its not working :S. Images are not scaling, when I press the maximize button. Also when I pressing it the Program goes back to the first State.And then when i try to minimize it after maximazi it the program losts it original display size. any ideas? – Zaphyk Apr 11 '14 at 3:05
• I think your problem might be the way you've setup your game.. Because I use this code personally and I don't have any issues like that :s not knowing what your project looks like doesn't really help me. – Samich Apr 12 '14 at 22:58
• It may be, Could you add your AppGameContainer options, I mean if you use Vsync for example or other things. – Zaphyk Apr 13 '14 at 21:51
• The images are scaling but not completely, it could be my screen? Also its looses its original size. – Zaphyk Apr 15 '14 at 23:09
• What do you mean it loses original display size..? You're going to have to keep track of the original width and height yourself... – Samich Apr 15 '14 at 23:11