File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Linux / UNIX and the fly likes Java GUI program looks different on Linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Java GUI program looks different on Linux" Watch "Java GUI program looks different on Linux" New topic

Java GUI program looks different on Linux

Rohan Baweja
Ranch Hand

Joined: Aug 19, 2001
Posts: 31
I am working on a Java program with a GUI. I installed Redhat 7.2 and Kde and tried to run my java program just to check if it java is actually Platform independent. Though it worked but it looked so different from what it looked on Win2k. The fonts were the main problem. Placement of other GUI objects were also a problem in the interface. and it also cave me this long error message on the command line something Does anyone have any clue whats can be dont to solve this problem.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

Several. It's not just a difference in OS's - even under Windows, different machines may have different display resolutions, different font sets, etc. that can cause your carefully-planned display to look horrible even to the point where it's unreadable.
And that's just as true whether the app's written in C++, VB or Java.
#1 - don't assume specfic fonts or sizes. Some say it's rude to specify even the font heights, since this can interfere with people who require large-type display. If you code font control, it's a good idea to set up a few basic font objects and reference those so that eveything changes together instead of creating a font object for each display object (which is inefficient anyway)
#2 - don't do the easy thing and use pixel-absolute layouts. The various Java layout managers were designed to help avoid many of the problems you're seeing. The most powerful of them is the GridBagLayout manager. It's a royal pain to set up. Some IDE's will help and there are a few tools out there of greater or lesser worth. Once accomplished, however, it works quite well.
You may want to look around for some books/websites on the general subject of GUI layout and Java GUI layout, as there are more things that can be done as well.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Java GUI program looks different on Linux
It's not a secret anymore!