File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Default windows font size effects layout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Default windows font size effects layout" Watch "Default windows font size effects layout" New topic

Default windows font size effects layout

Kelly Wiles

Joined: Jan 22, 2013
Posts: 2
I have looked on Google but can not find answer or I can't word it correctly to find it.

When I develop a SWT application my computers desktop font size is set to windows 7 default size.
I mainly use Form layout with Grid layout for some windows.

My problem is that when the program is run on a windows system and the user has increased the font size of the desktop my layouts are all messed up.
If I go into windows settings and reset the font back to the default size everything looks fine again.

I have tried using setFont on all the widgets but it does not effect this problem.

What can I do about desktop font size being changed from the default?
Have attached an example image of the problem.


[Thumbnail for example.jpg]

Tony Docherty

Joined: Aug 07, 2007
Posts: 2830
I've not used SWT and also without seeing the code this is all a bit of a guess but I suspect the problem is because you are specifying the exact dialog size rather than letting the dialog auto calculate the ideal size based on the components preferred sizes. In Swing you would do this using pack(), not sure what the equivalent is for SWT.
Kelly Wiles

Joined: Jan 22, 2013
Posts: 2
I tried what you suggested and here are the results.

I use a simpler screen than the configuration screen shown but still has the same problem.

The first image login1.png is how it should look.
The second image login2.png is after I removed the setSize call.
And the third image login3.png shows what happens after I add the pack() call.

I use Window Builder Pro and that GUI builder does not add pack() calls to the code generated.

If using pack() is part of the answer then I am doing something else wrong.


[Thumbnail for login2.png]


I agree. Here's the link:
subject: Default windows font size effects layout
It's not a secret anymore!