Hi I am making a football stratedgy game and I have it the game working. I was playing prison architect and minecraft in fullscreen and noticed there was no windows it was covering the whole screen. So I looked up how to do this and I got



and this works its just that all the images are (I don't know how to put this) the same size as when the game was in 600 * 500 window and I was wondering if there was a way to have them in the right place according to the size of the screen, so for example if the computer screen is 1000 * 1000 pixels the image whould be 100 pixels from the left of the screen but if someone played it on a 500 * 500 pixel screen it would be 50 pixels form the left of the screen. Keep in mind that they way I draw my images are

ImageIcon i2 = new ImageIcon("res/BackGrounds/titlescreen.png");
    img = i2.getImage();
g.drawImage(img, 10, 10, null);

I tried doing it this way:

    ImageIcon i2 = new ImageIcon("res/BackGrounds/titlescreen.png");
    img = i2.getImage();
    g.drawImage(img, 100, 10,Toolkit.getDefaultToolkit().getScreenSize().width / 5 -100,Toolkit.getDefaultToolkit().getScreenSize().height / 5 - 100, null);

but I when I tested it on a different computer whith a different sized screen the images where more squashed together because the screen is smaller and I had set the toolkit to be

Toolkit.getDefaultToolkit().getScreenSize().width / 5 -100

Pleas if u can help me, help me cause I really need help. THX in advance

  • \$\begingroup\$ I think an screenshot or diagram would help understand this problem. \$\endgroup\$
    – House
    Jun 27, 2014 at 19:51
  • \$\begingroup\$ How do I add a screen shot \$\endgroup\$ Jun 27, 2014 at 20:00
  • \$\begingroup\$ Edit the question and use the editing tools to insert an image. The image can come from your computer and doesn't need to be uploaded first. \$\endgroup\$
    – House
    Jun 27, 2014 at 20:01
  • \$\begingroup\$ is there a program I should download to take a screenshot or I there a way on windows \$\endgroup\$ Jun 27, 2014 at 20:04
  • \$\begingroup\$ Google it. I think explaining it in a comment is silly. \$\endgroup\$
    – House
    Jun 27, 2014 at 21:49

1 Answer 1


The easiest way to achieve this is to draw your game to an image buffer first, instead of directly to the window. Then you draw that image scaled up according to the resolution of your window. This way you don't have to worry about scaling and positioning the indiviual elements of your display.

However, it might be advisable to only scale to the nearest integer multiple of your buffer size in order to avoid interpolation artifacts.

Look into java.awt.Canvas and buffer strategies for hardware-accelerated off-screen buffers.

Besides that, you might be interested in fullscreen exlusive mode as an alternative to windows without decoration: http://docs.oracle.com/javase/tutorial/extra/fullscreen/


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .