Windows/Linux/Mac GUI?

J

J.M. Joensuu

Hi all,

I am going to start a hobby project, which would be small-scale for
most of you (program that edits text files, following rules in
editable config files, adding user-made content to the existing maps)
but which will probably take most of my summer. As the game works in
Windows, Linux, Mac OS X and Solaris, I would like to support as many
of those OSs as possible.

If I write the GUI using Swing, will the program work on Windows,
Linux and Mac? I don't know what Solaris is or if it has Swing, but
that would be a bonus.

What else should I know about cross-platform developing? What I should
and shouldn't use? I am mostly worried about GUI, but other hints are
welcome and probably needed as well.

Janne Joensuu,
Endoperez
 
A

Andrew Thompson

..As the game works in
Windows, Linux, Mac OS X and Solaris, I would like to support as many
of those OSs as possible.

If I write the GUI using Swing, will the program work on Windows,
Linux and Mac?

Yes. There might be a few quirks with Mac's implementation of Swing,
but otherwise yes.

[ Assuming the end user has Java 1.2+ (or Java 1.1 and the Swing Jar)
installed ]
..I don't know what Solaris is..

Sun's own OS.
..or if it has Swing,

Solaris would come ready with a late model Java installed.
What else should I know about cross-platform developing?

One quick tip. Avoid the system specific path separators for file names
and text file EOL character by calling the appropriate system properties..
<http://java.sun.com/docs/books/tutorial/essential/system/properties.html>
 
P

Paul Tomblin

In a previous article, (e-mail address removed) (J.M. Joensuu) said:
If I write the GUI using Swing, will the program work on Windows,
Linux and Mac? I don't know what Solaris is or if it has Swing, but
that would be a bonus.

Properly written, a Swing GUI should work on all those platforms. But I
would advise you to test it well on all platforms, and if you support
multiple languages, test it with all languages on all platforms.

I would also advise using the "Swing" look and feel, or writing your own,
because the differences between the default Windows look and feel and the
default Mac look and feel and the default Linux look and feel will drive
you batty.

I worked with a guy who did his GUIs using a GUI builder tool (Visual Age
for Java) and never used layout managers, just put everything at an
absolute size and an absolute location on the screen. Consequently, every
time a translation file came in he had to tweak his layout to fit. I, on
the other hand, hand-write my code and use layout managers extensively,
and so my GUIs resized to fit different length language strings, different
fonts and different component sizes on different architectures. Every
gain he made in development speed by using a tool was lost several-fold in
the subsequent revisiting over and over and over again - especially when
we had to add another widget somewhere.
 
T

Thomas Weidenfeller

J.M. Joensuu said:
If I write the GUI using Swing, will the program work on Windows,
Linux and Mac?

Yes, if

1) You don't bend the rules. E.g. trying to circumvent layout managers,
or messing up the repaint mechanism is a very bad idea.

2) You don't hard-code platform specific details. E.g. file name formats
and pathes are different on these platforms.

3) You don't make platform-specific assumptions. E.g. that your
text-file character encoding is always some windows encoding

4) You don't run into platform specific bugs. This happens from time to
time and might require some platform specific workarounds.

I don't know what Solaris is or if it has Swing, but
that would be a bonus.

Solaris is Sun's own Unix SVR4 derived Unix version - of course with a
bunch of BSD extensions. And yes, you get recent JVMs for Sun, which
include Swing.

/Thomas
 
S

Steve W. Jackson

Andrew Thompson said:
..As the game works in
Windows, Linux, Mac OS X and Solaris, I would like to support as many
of those OSs as possible.

If I write the GUI using Swing, will the program work on Windows,
Linux and Mac?

Yes. There might be a few quirks with Mac's implementation of Swing,
but otherwise yes.

[ Assuming the end user has Java 1.2+ (or Java 1.1 and the Swing Jar)
installed ]

I'm not sure what "quirks" Andrew may be referring to...but do NOT
consider the Mac prior to OS X if you don't want a headache. Apple's
support for Java in earlier systems is defunct and the last supported
version of Java was 1.1.8, with no Swing available. The Swing 1.1.1 jar
file could be used with difficulty. If you refer to Mac OS X, however,
every version out included Java pre-installed, beginning with 1.3 or
1.3.1 (I forget which). And the recently released OS X 10.4 (aka Tiger)
shipped with 1.4.2, but 1.5 has been released for it very recently.
Sun's own OS.


Solaris would come ready with a late model Java installed.


One quick tip. Avoid the system specific path separators for file names
and text file EOL character by calling the appropriate system properties..
<http://java.sun.com/docs/books/tutorial/essential/system/properties.html>

Excellent advice, that last...

= Steve =
 
A

Andrew Thompson

I'm not sure what "quirks" Andrew may be referring to...but
(snip actual situation re Swing/Mac)

...ummm. Those ones I was confident that someone like yourself
could clarify. I was hoping you'd pop into this thread. ;-)
 
K

keredil

Every gain he made in development speed by using a tool was lost
several-fold in
the subsequent revisiting over and over and over again - especially when
we had to add another widget somewhere.

Have not used Visual Age for Java, but I guess it supports layout
manager. At least JBuilder supports layout manager very well. So it
really depends on how you use the IDE!
 
S

Steve W. Jackson

Andrew Thompson said:
(snip actual situation re Swing/Mac)

..ummm. Those ones I was confident that someone like yourself
could clarify. I was hoping you'd pop into this thread. ;-)

I've been so busy, I haven't even installed my copy of OS X 10.4 over
two weeks after purchasing it...

As soon as I can make the time for that, I'm also planning on installing
the new Java 1.5 release they've got ready and then looking for some
time to learn some of the things my own application would need to do
differently in order to get a Mac version out the door.

As for quirks...the main ones have to do with things like the OS X dock,
the "grow box" area of windows that are used for resizing (which tend to
intrude on the internal area of windows), etc. And then there's the
fact that OS X automatically provides every application with its own
app-named menu item, About menu item, Quit menu item, etc., so that
there are some things to learn in order to connect existing methods to
those rather than forcing Mac users to use File/Exit and some other
things that tend to chafe us. :)

= Steve =
 
S

Steve W. Jackson

Every gain he made in development speed by using a tool was lost several-fold in
the subsequent revisiting over and over and over again - especially when
we had to add another widget somewhere.

Have not used Visual Age for Java, but I guess it supports layout
manager. At least JBuilder supports layout manager very well. So it
really depends on how you use the IDE![/QUOTE]

It supports the entire standard API, but IIRC it has never been updated
past 1.2.2 -- or maybe to 1.3 but not beyond. I believe I recall that
IBM has dropped support for it.

= Steve =
 
P

Paul Tomblin

In a previous article, (e-mail address removed) said:
Have not used Visual Age for Java, but I guess it supports layout
manager. At least JBuilder supports layout manager very well. So it
really depends on how you use the IDE!

Oh, I'm quite sure it does. The blame lay entirely with him, not with his
choice of tools. Well, except for the fact that my Java 1.4 specific code
didn't work in VAJ so he couldn't run my components in VAJ's debugger.
 
M

Mark 'Kamikaze' Hughes

Paul Tomblin said:
In a previous article, (e-mail address removed) (J.M. Joensuu) said:
Properly written, a Swing GUI should work on all those platforms. But I
would advise you to test it well on all platforms, and if you support
multiple languages, test it with all languages on all platforms.

In particular, get someone who understands a right-to-left language
(Arabic, Hebrew, etc.) to test it out.
I would also advise using the "Swing" look and feel, or writing your own,
because the differences between the default Windows look and feel and the
default Mac look and feel and the default Linux look and feel will drive
you batty.

Customers almost always want their platform-native look-and-feel,
whether it's with AWT (ugly, but fast and functional) or Swing (pretty,
but slow and not always functional). With Swing, you can let them
change the look-and-feel with a command-line parameter if they don't
like the default. This does mean more testing, but at least you can do
most of it on your own system.
I worked with a guy who did his GUIs using a GUI builder tool (Visual Age
for Java) and never used layout managers, just put everything at an
absolute size and an absolute location on the screen. Consequently, every
time a translation file came in he had to tweak his layout to fit. I, on
the other hand, hand-write my code and use layout managers extensively,
and so my GUIs resized to fit different length language strings, different
fonts and different component sizes on different architectures. Every
gain he made in development speed by using a tool was lost several-fold in
the subsequent revisiting over and over and over again - especially when
we had to add another widget somewhere.

How very 1990. I take it he also didn't test cross-platform, because
every look-and-feel has different widget sizes and fonts.

The layout managers are certainly the way to go. Everyone should
learn at least how to use FlowLayout, BorderLayout, and GridBagLayout
(no, it's not as hard as some people claim, especially if you make a
helper method to work with it).
 
T

Thomas Weidenfeller

Steve said:
It supports the entire standard API, but IIRC it has never been updated
past 1.2.2 -- or maybe to 1.3 but not beyond. I believe I recall that
IBM has dropped support for it.

It became the foundation for Eclipse. IBM founded the Eclipse
organization and donated the code to get Eclipse started.

/Thomas
 
K

keredil

Everyone should learn at least how to use FlowLayout, BorderLayout, and
GridBagLayout

Recently I tried QtDesigner (C++, not java). It's so powerful. Don't
need to put the widgets in its accurate position. QTDesigner will
choose the appropriate layout. It's also cross-platform.
 
K

keredil

Well, except for the fact that my Java 1.4 specific code
didn't work in VAJ so he couldn't run my components in VAJ's debugger

Then it must be an old VAJ. I'm not good at gdb or jdb. Don't know
other debug technique except the print statement.
 
M

Mark 'Kamikaze' Hughes

Recently I tried QtDesigner (C++, not java). It's so powerful. Don't
need to put the widgets in its accurate position. QTDesigner will
choose the appropriate layout. It's also cross-platform.

Eh. Under the graphical shell, it's just a layout manager,
effectively equivalent to GridBagLayout. There are Java tools to let
you play with GBL dynamically, if you like that kind of thing.

IMO, graphical tools don't really help the GUI layout process.
They're very useful if you don't know the language, but once you're able
to express yourself through the phrases of your programming language,
they don't offer anything. I used to use them back in the early '90s,
when all layout was by absolute position, but stopped as soon as layout
managers became usable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top