I’m trying to make a monopoly game in java, the thing is i’m very new to programming and this is my first program.
So without knowing about the dimensions of the frame, i made it too big because it was okay for my screen resolution, but when I try to use the game in another computer, it is so big that it doesn’t even fit in the screen.
So my question is how can I make that my game can resize automatically so I can use it in another PC without affecting its dimensions?
Thank you very much 🙂
Assuming that you’re creating a Swing application (you never say), the is to not size any of the components directly but rather to use an appropriate mix of layout managers, and let the layout managers and the preferredSize of your components do the sizing of the GUI for you. Always remember to add the components to the GUI, then call
pack()on the top level Window, and then callsetVisible(true)on the top level window.For more details on just what layouts are available through core Java, please check out the tutorial, Laying out Components in a Container.
If your question does not involve the Swing GUI library, then please let us know which GUI library you’re using. The question details are quite important, and you’ll want to tell them to us from the start if possible.