Hi, I have a small problem - my Java applcation is supposed to run (and look good) both on 640x480 and on 1024x768 resolutions. So I wondered if there's a way to scale gui programmatically, so that it'll take the same amount of screen space on both? Thanks, hope somebody will answer KathyS
Well, you can use getScreenSize() in Toolkit (an instance of which can be obtained from Toolkit.getDefaultToolkit()). Once your program knows the dimensions of the screen, you can use that info to decide on the outer dimensions of your window(s). The inner dimensions of other components within the windows will then be managed by your layout managers.
hi kathy, there is one more method in Toolkit class getScreenResolution().that returns the screen resolution in dots-per-inch. may be u can make use of it. regards deekasha
Joined: Nov 22, 2008
Thank you Jim and Deekasha. I remember trying to set frame size dependent on screen resolution, but it doesn't seem to change size of the font. So buttons, for example, will drop some text instead of resizing it. Certainly I could keep going and parameterize everything... I just hoped there was an easy way out KathyS
Hi Carl, Could you please elaborate on 'right combination' of layout managers? I tried Grid Layout with no success. KathyS
Joined: Jun 13, 2000
Without seeing your code, or what your screen design looks like I can only speculate. What I've done in the past is used the BorderLayout in my frame, put a panel in the north position, set the panels layout manager to flow. this allowed the Components that I added to the panel to be the default size of the component. If your doing a gridbag, you can do something similar an add a panel to each location an set the layoutmanager to something that will give the appearance that you need. If your design is elabarate, this might not be any less work than what you proposed above.