Cross platform UI spacing/padding
I have written a Java UI using the SWT UI library and the MigLayout layout library.
This page shows screenshots of the UI on Windows, Linux and OSX: http://mchr3k.github.com/org.intrace/开发者_StackOverflow社区screenshots.html
On Linux and OSX my UI has a lot more padding and spacing which I feel wastes a lot of screen space. Is this normal for these platforms? If not, what is the best way to work around this?
EDIT: the linked screenshots have now been updated and no longer show an extra gap on OSX as I have explicitly set the margins on some of my UI elements to 0. The OSX UI is still quite spaced out but I assume that this is correct for the platform.
This is Mikael Grev, the creator of MigLayout.
As someone else mentioned this is a feature of MigLayout. Instead of using x number of pixels (you can of course use that too) by default it is using gaps like related, unrelated and paragraph. These correspond to different sizes in different UI toolkits. For instance on OS X the recommended white space between components is larger than on Windows.
So, yes, this is how it's supposed to look and it will look correct for a native OS X user.
You do seem to have too much white space at the bottom of the Output pane though, in both OS X and Windows.
You can use the PlatformDefaults class in MigLayout to either force a platform or to change the default gaps. Check the source code if you want to know what's happening behind the scenes.
And remember, this is a feature so that every developer won't have to keep track of how to spacing should look like on different platforms, which is kind of hard.
Cheers, Mikael
That's actually a feature of MigLayout, if I recall correctly. If you don't want this I am sure you could so configure MigLayout. Otherwise, you could use a different layout manager (but I still highly recommend a table-based one) which uses constant spacing for all platforms (such as my MatrixLayout).
精彩评论