java with native GUI appearance?

  • Thread starter nooneinparticular314159
  • Start date
N

nooneinparticular314159

I have a Java program that I would like to make appear to be a Windows
application on Windows, a Mac application on MacOS, and a Linux
application on Linux. Is there a way to do this?

Also, is there a way to compile the code as Windows/Mac/Linux native?
I am interested in maximizing performance. I also do not want to
require the user to have Java installed, so running native would be
preferable.

Thanks!
 
C

Chris Smith

Also, is there a way to compile the code as Windows/Mac/Linux native?
I am interested in maximizing performance. I also do not want to
require the user to have Java installed, so running native would be
preferable.

As for the former, search the API doc index for
getSystemLookAndFeelClassName.

As for the second, you could look into Excelsior Jet or gcj, but you
won't be able to avoid having to either distribute some kind of an
implementation of the standard library, or require that the user already
have such an implementation available. Since you can't legally
distribute only part of the standard library, you're pretty much stuck
with the whole thing.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
A

Andrew McDonagh

I have a Java program that I would like to make appear to be a Windows
application on Windows, a Mac application on MacOS, and a Linux
application on Linux. Is there a way to do this?

Google SetLookAndFeel - first entries.
Also, is there a way to compile the code as Windows/Mac/Linux native?

No - well not from one tool.
I am interested in maximizing performance.

You should be sure that the app running in a JVM is the performance
bottleneck before going this road - often it isn't.
I also do not want to
require the user to have Java installed, so running native would be
preferable.

Then why bother with Java?

Seriously, develop it in C++ and just build against your target platform.

When ever you try and work against a fundamental concept of a language,
you have to give up some of that languages benefits.
 
N

nooneinparticular314159

Well, I developed it in Java initially because I was familiar with the
language, and sure that I could build a proof of concept in it. My
concern is that if I let other people run it, I want it to appear to
them to behave exactly as a program should in their native environment,
including installing the way that native programs install. I don't
want them to say "what is JRE?" and get confused.

It looks to me that SetLookAndFeel generates a GUI appearance that is
similar to, but not the same as, the native GUI. For example, you have
a java logo in the corner, and widgets don't look quite right. Is
there a way around this?

It actually runs fine on an older machine in Java. It's a user
experience issue more than anything else...
 
N

nooneinparticular314159

Ok. I tried it, and it does indeed produce the appearance of being
Windows native (mostly). But is there any way to make the icon the
correct icon, and not a Java coffee cup?

Thanks!
 
A

Alun Harford

Well, I developed it in Java initially because I was familiar with the
language, and sure that I could build a proof of concept in it. My
concern is that if I let other people run it, I want it to appear to
them to behave exactly as a program should in their native environment,
including installing the way that native programs install. I don't
want them to say "what is JRE?" and get confused.

Distribute an installer. It deals with that.
If you don't, they're going to say "what is DLL?", "what is the registry?",
etc.

Alun Harford
 
S

Simon

Ok. I tried it, and it does indeed produce the appearance of being
Windows native (mostly). But is there any way to make the icon the
correct icon, and not a

Frame.setIconImage(Image)

I think there is no method getDefaultIconImageForPlatform() but I guess your
application will have an icon of its own. Otherwise, that is a good reason to
design one now :)

Cheers,
Simon
 
C

Chris Smith

Well, I developed it in Java initially because I was familiar with the
language, and sure that I could build a proof of concept in it. My
concern is that if I let other people run it, I want it to appear to
them to behave exactly as a program should in their native environment,
including installing the way that native programs install. I don't
want them to say "what is JRE?" and get confused.

They don't need to. You can distribute the JRE with your application.
The JRE (Sun's, anyway) does not need to be "installed" in any special
way. You can just extract it to a subdirectory of your application, and
set up a shortcut / shell script / Start menu entry, or whatever else is
appropriate for the platform, that runs it with a full path. Using
executable JARs for your own application helps here, too, since it makes
the JRE less dependent on environment variables and the like.

I've done that for years, and our customers don't have any clue what a
JRE is.
It looks to me that SetLookAndFeel generates a GUI appearance that is
similar to, but not the same as, the native GUI. For example, you have
a java logo in the corner, and widgets don't look quite right. Is
there a way around this?

Those are not native controls. If they look subtly different from
native controls, there's nothing to be done about it. My experience is
that Sun's look and feels are close enough that customers don't tend to
care about the remaining differences... assuming, of course, that your
application actually does unique and interesting things besides just
having a user interface.

For native controls that are usable, see SWT, but you'll pay a price in
working with a relatively impoverished programming model. The AWT also
has native controls, but they are well-nigh unusable and don't include
things that are considered fundamental these days, like tree and table
controls.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

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

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top