I've developed an app in Java Swing which is running absolutely fine in windows but the same when ran in linux (RedHat 64 bit) doesn't open in full screen mode because of which some of the components aren't visible at all and hence inaccessible. I'd appreciate your suggestion.!
..some of the components aren't visible at all and hence inaccessible. I'd appreciate your suggestion!
Java GUIs might have to work on a number of platforms, on different screen resolutions & using different PLAFs. As such they are not conducive to exact placement of components. To organize the components for a robust GUI, instead use layout managers, or combinations of them1, along with layout padding & borders for white space2.
Related
I am making a java program for Windows with GUI using windowbuilder.
I set the sizes of the components so that it would match a screen resolution of 3200x1800.
After I built the program I ran it on a different computer with a screen resolution of 1366x768. All of the components were much bigger than running the program in the high screen resolution screen.
How can I set the components to be in the same size for all screen resolutions (the components will match the screen resolution)?
dear #amitai you must have to use some layout provided by Java like gridBagLayout, BorderLayout and FlowLayout bla bla bla Adjust your components as per Layout recommendation. If you will success to adjust your components in Layout your problem will automatically solved.
These Layouts are developed for the purpose of adjusting components in a sequences for different type of resolutions. Layout are working as a container.
For brief discussion follow reference link below:
http://docs.oracle.com/javase/tutorial/uiswing/layout/using.html
http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html
I have a swing gui which has proper JPanel and JDialog size on windows platform with screen size from 13inch to 15inch. What I refer as proper size is that all the components in JPanel and messages at JDialog are properly shown.
However, when running under Ubuntu linux with Genome/Kde desktop, I find the not all components or messages are fully shown and it appears that either width or height is not enough and the GUI interface is cropped
Anybody has ideas of how to fix it?
To have consistent UIs in multiple platforms you have to use LayoutManagers.
http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html
There are several graphical editors that support creating swing user interfaces using LayoutMaganers. One example is WindowBuilder for Eclipse: http://www.eclipse.org/windowbuilder/
Call Window.pack() for your JDialog before showing it to make the window just big enough to fit all the components in it. This requires that you are using layout managers.
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/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).
When I design my GUI using swing, the Swing Control Buttons are grey and the text easily fits on them. However, when I run the program the buttons become partly blue and the text no longer fits on them. Why does my program look different in the Swing Design than at run-time?
Why does my program look different in the Swing Design than at run-time?
Probably has something to do with your Look and Feel.
However, when I run the program the buttons become partly blue and the text no longer fits on them.
Probably because you are not using layout managers. Layout managers will make sure components are displayed properlly, even when switching between LAF's.
I can't guess what tool you are using to create your GUI but you are doing something wrong with the tool. If you need more help then post your SSCCE that demonstrates the problem.
I suppose you're using some GUI builder. Netbeans gui builder displays preview with native LaF, while program runs with default Metal LaF, which has different margins for components and font size. Either change LaF in your program to the one that works best for your layout, or make your components larger.
I have been developing a program on a windows machine.
All dimensions for the application are based on the default windows font and size.
The default mac font seems to be larger in size, therefore not all text is visible in labels, comboboxes, ...
How can i make sure that the proper font size is used on mac machines?
The correct way to do it is not to hardcode control sizes and use layout managers instead.
Michael is right. Font sizes are not the only thing changing from one L&F to the other. Components like buttons can have different sizes too. So forget about hardcoded sizes. With Apple's control styles, developers now have a chance to choose the size of some components, but there is no guarantee this will work in the future if your layout is not flexible.