Fog Creek Software
Discussion Board




Java GUI's

I think there are some pretty nice Swing GUI's out
there these days.  Take a look at the "Swing Sightings"
section of the Swing Connection:

  http://java.sun.com/products/jfc/tsc/sightings/S12.html

In fact, check out the first entry there, the Alloy L&F
demo (use the Web start button to actually play around with
it).

As you said, nobody can keep up on all the developments
in more than a few programming worlds, and Swing has
grown up a bit since many people last looked at it.

(Which isn't to say it doesn't still have problems.  For
example, I really wish it had parent modal dialogs right
about now ...)

-David 

David Eisner
Wednesday, December 11, 2002

I agree. 

Swing, while not being the best GUI toolkit on the block is quite capable of building some good GUIs (provided you have a lot of RAM :-) ). It is a vast improvement on AWT.

Note you can do the Tab buttons like you have in Excel using Swing. You have to use the Java primitives to draw them, which of course is not as effeciant as using GDI directly but it can be done. You can then wrap it up as a component and use it on any GUI screen you like.

JB
Wednesday, December 11, 2002

Also note, that you can get the HWND of a window, just do a Google search and you will find it here for example:
http://forum.java.sun.com/thread.jsp?thread=95720&forum=52&message=249099.  You have to do some C integration for it, but it's more or less the same if you want to get a HWND from VB... And there are so many Windows apps with keyboard thingies and other GUI strangeness out there that you just can't put it on the language alone.

But that's completely besides the point of course. I do think that you can create good GUI's in Swing, it has made great leaps from 1.1 to 1.4 and it will continue to do so in the future. The platform is still very young.

Also, the whole Java platform is just a dream to program for and it has very good documentation. Take the Java API or the Java look and feel design guidelines. And I'm simply more productive in Java than in C++.

Rogier
Wednesday, December 11, 2002

Looking at that "Alloy L&F" demo, I immediately found 5 annoyances in about 3 minutes:

* It doesn't look like windows. It has all kinds of skins but none of them are native looking. People notice this.
* Alt doesn't go to the menu
* Alt + Space doesn't pop up the control menu
* Keyboard up/down can't be used to select from a radio groupbox
* Ctrl+Shift+Home/End don't work in text boxes

OK, they are all keyboard things, but with real Java applications like LimeWire there are dozens of other problems. Space doesn't dismiss dialog boxes. Setup is weird. Icons are wrong. Help doesn't look like help.

This is exactly what I meant when I said that Java knows what food is supposed to look like but it tastes like cardboard. Java has been out for 7 years now, enough excuses about how it's too young. How long does it take to make Alt work like Alt?

Joel Spolsky
Wednesday, December 11, 2002

"How long does it take to make Alt work like Alt? "

Frankly, looks more like never!

Prakash S
Wednesday, December 11, 2002

http://www.javalobby.org/threadMode2.jsp?forum=17&thread=6081&start=0
"Sun is about to publish a Windows XP look and feel in the 1.4.2 Mantis release".

Another issue holding back Java-based GUI apps is that each app runs inside its own VM - running IDEA + Tomcat + ArgoUML really didn't happen for me when I tried it last week (then again, just running ArgoUML didn't happen - it's a memory hog). VM sharing is one of the more common features people seem to want to see in the Javalobby forums.

Also, I heard that Swing has been dropped from the JCP exam - can anyone confirm this?

Walter Rumsby
Wednesday, December 11, 2002

I think these are fair criticisms, but these aren't (all) problems with Swing itself.  For example, the focus
traversal keys can be modified using the KeyboardFocusManger.  The folks at Incors
failed (or decided not) to add the arrow keys to the
focus forward/reverse Sets, but they could have.

Swing isn't  food -- it's a set of cooking utensils and ingredients.  You happen to like Italian food.  Cooks
who use Swing tend to make all kinds of different cuisine.
They're not cardboard, but they're also not Italian.

Variety is great when you're hungry, but I accept that
it's not great for UI usability.  This is a failure of
Swing programmers, though, not of Swing. 

David Eisner
Wednesday, December 11, 2002

| Variety is great when you're hungry, but I accept that
| it's not great for UI usability.  This is a failure of
| Swing programmers, though, not of Swing.

It's largely the fault of Sun.

Making a toolkit infinitely configurable is Good.
Forcing developers to infinitely configure the toolkit is Bad.

Swing doesn't make it sufficiently easy to do "The Right Thing" - and the blame for that has to lie at the feet of Sun.
If they want developers to be productive, and produce high quality applications in Java, then they need to make it easy to get it right.

To quote Ken Arnold (from Sun)
| designing tools for programmers, including languages,
| APIs, and compilers, is a human factors problem. And so
| we should ask the same kinds of questions that
| people ask about GUIs [graphical user interfaces].
| Is it easy to do what you need to do? Is it natural?
| Are simple things simple? Are complicated things
| complicated? Are dangerous things hard to do?
| Are common things easy to do? Are similar things
| done in a way that is naturally similar to the person?
http://www.artima.com/intv/perfect3.html

Swing is not designed to make it easy for developers to produce well behaved GUIs. Each development team has
to go through the effort of configuring the GUI to do the
things that every good GUI should do.
That's Sun's job.
If there is a toolkit behaviour that is desired by the majority of developers (and making your app feel "natural" is desired by most developers) then that behaviour should be simple
to achieve (and it should probably be on by default)

If it isn't (and I don't do enough Swing work to know that, but I think the results speak for themselves) then Swing is deficient.

Tim Vernum
Wednesday, December 11, 2002

I seem to remember that that Swing has a place where you can plug in stuff like the configuration info.  If you have a list of keyboard shortcuts, you should be able to load them as part of the configuration.

But Joel, remeber that Java/Swing is designed by Sun.  I happen to be sitting at Sun right now.  Sun people do not use windows.  Oh, sure, some do, but not the developers.  Windows shortcuts like you just listed qare One way to do things, and not everyone knows them, uses them, or wants them.

My personal favorite shortcut come from X.  Highlight text anbd it is copied.  Middle click and it is pasted.  When ever I go back to Windows, It takes me a few tries before I realize I have to do ctrl-c ctrl-v.  I can use Emacs and Vi, and I usually hit the shortcut from one while using the other.

In awt, the Java guys tried to make it so you got the configs from the local system.  They got feedback (either right or wrong) that instead of making apps look like Windows apps, they should look like Java Apps.    They decided it was more important for an Application to perfomr consistantly across platforms than for the platform to perform consistantly across applications. 

Note that I neither espouse nor deny this position, merely restating it.

If you want to make an application that runs across multiple platforms with a minimum of effort, use Straight HTML and push it outvia the web.  Of course you'll sacrafice usablility.

I'd recommend Mozilla as the cross platform toolkit, becasue you already have a lot of web expreience in house.  XUL is not necessary, and probably not even recommended to do mozilla development.  Instead, do web development, store everything on the server, and use DHTML/CSS/JavaScript to give you the dynamic content.  Target Mozilla as the browser  first, and then port to IE.  Why?  Because you know MS already, but learning Mozilla will cause you to think about stuff in a portable way.  Plus, if you decide you do want to put everything on the desktop, the distance you will have to go to make a XUL app will be that much shorter.


Best of luck

Adam Young
Wednesday, December 11, 2002

David, I don't think it's possible to create a Java UI in which Alt lights up the menu bar in the same way it works in Windows. I have come to believe that this is technically impossible, because I have yet to see ONE java application that gets it right. (Eclipse/SWT excluded, they are using the native API.) I don't think it's a matter of just setting the right keybindings.

Why am I making such a big deal about Alt? Because when I try to minimize a Java app, I use Alt+Space,N like I always do, but the app doesn't go away. This makes me feel like I'm not in control of my environment. It is human nature to be unhappy when you are not in control of your environment. So using Java applications makes me unhappy. I don't want my customers, who use my applications, to be unhappy, so I can't write them in Java.

And don't get me started about DHTML/HTML/DOM programming. Ten thousand times worse than Java for all but the most trivial of user interfaces. Please don't show me Oddpost or I will have to take the time to list 200 ways in which Oddpost doesn't quite conform to what you expect from a Windows application, either, making it not do what I expect, making me unhappy when I use it.

Joel Spolsky
Wednesday, December 11, 2002

I've been reading abit about the SWT, and it really seems a logical way to do GUI - using the native APIs rather than emulated ones - like Swing.

It really is quite irritating for me now - although the app I'm developing is just a research project - cos I'm doing this Swing UI, and it's just different.

I need to admit that there's been alot of improvements in the Windows L&F (since SDK 1.3) but there's still alot of catching up.

Perhaps the SWT is the way to go...

Wei
Wednesday, December 11, 2002

Swing is fine if you don't constantly fall for marketing.  (And if you do,  you're also screwed with Microsoft.)  Especially on MacOS X -- Apple programmers did a lot of work to ensure that Swing looks natural.  Microsoft didn't.  So it looks cheap on Windows and great on Mac.

If I'm mainly targetting Windows users with a conventional app, then no Swing.  If it were actually opensource then maybe, but it isn't.

Realistically, Swing is one of those things that will probably bloom after a couple generations of computers.  Very clean api, and you get sourcecode so you know what's going on.  Of course, XUL and SWT are even more opensource, so it'll be interesting to see what will emerge.

Tj
Thursday, December 12, 2002

Adam wrote:
> My personal favorite shortcut come from X.
> Highlight text anbd it is copied.  Middle click and it
> is pasted.

Apart from "focus follows mouse" this is the thing I hate second most with X. Consider the following use case: Copy an URL which is not marked up, into the address line of the browser.

Select the URL using the mouse, select the address line so that the old address is to be overwritten and then press the middle button.

And nothing happens, because when the old address line was selected, *it* got selected. I do that all the time, because I am used to Windows. And that is why all programs should native to the platform on which they are running.

Roland Kaufmann
Thursday, December 12, 2002

Wei wrote:
> I've been reading abit about the SWT, and it really
> seems a logical way to do GUI - using the native
> APIs rather than emulated ones - like Swing.

Emulating GUI toolkits is about as sensible as emulating file systems and doing raw reads/writes to the device, i.e. not sensible at all.

The reason why this was done is probably because Sun engineers are used to a system where nearly every damned program statically links the window toolkit.

If they were sensible, a version of SWT with Swing's data models would be released. The best we can hope for however, is that the 1.4.2 at least use the theme functions in Windows and Gnome so that Java programs no longer look alien.

Roland Kaufmann
Thursday, December 12, 2002

Is it okay to do a Swing GUI in an app that is targeted towards non-techie users? Most people I know that just use Word, etc. never touch the keyboard unless they are actually entering text, so they do not care if the Alt behaviour isn't exactly correct.

I've shown the Swing apps I have developed to a few 'normal' users and none of them have realized that it wasn't a native windows app.

However, I do realize that the results Swing produces are far from perfect. The reason I like using Swing is because it only takes minutes to get a GUI up and running (+ a few hours to perfect it) and the API is a joy to use.

Daniel Searson
Thursday, December 12, 2002

I've only played with SWT for a little while, but I've done a fair amount of Swing.  I have to say that Swing puts FAR too much work on the programmer. 

But most of its "run-time" faults are implementation faults, not problems with Swing per-se.  For example, the Swing implementation on my Mac (using Duality) automatically picks up the current theme and looks and acts fully native (because under the hood it actually is native while remaining cross-platform).  Whereas the implementation on my Win2k box looks awful (actually 1.4.1 isn't TOO bad but still nowhere near perfect). 

However, Alt/Space/N works fine for minimising in Java on windows - however Alt/F/N doesn't work, you need Alt-F/N

To see what is possible with Swing check out Karsten Lentsch's site at http://www.jgoodies.com/ .  In particular Metamorphosis shows what is possible with a couple of tweaks to the defaults. 

Zealot
Friday, December 13, 2002

you're right about Alt-Space/N though ... that's an annoying inconsistency!

Zealot
Friday, December 13, 2002

There are not a hell of a lot of people who really care about shortcuts, as a percentage of users.  So Joel's needs are just a tiny issue.  However, it's clear that Sun is just not committed to making a great desktop experience for Windows; they're a server company.  If they ever show this commitment, then Swing will be more valid for end-user products.

Still, I do like Swing.  It's very configurable.  I've customized things like scrollbars so that users can use jpegs to customize them.  (Yes, I know that sounds almost perverted, but it was what was wanted, and I found it fun.)  The api is clean and the sourcecode is out there.

Tj
Friday, December 13, 2002

I was really surprised by Joel's dislike for Swing because I remember reading his ideas about User Interface in general and thinking how many of them Swing implemented.  Swing performance is pretty decent these days if you know what you are doing, but one must admit that they, and Java programs in general, tend to take up much more memory than native apps.

As for his complaint about Swing not implementing expected windows shortcuts by default, I must admit I didn't even know that alt space whatever even did that.  I don't think that's how things work on other OS's.  Maybe Swing should add these defaults on a per platform basis.

BTW- I've never done this but if Joel wants pressing a key sequence to minimize a frame, I am fairly certain this can be done in Swing.  It has extensive facilities for key mapping.  Maybe in my spare time I'll give it a try and get back to you.

Erik Lickerman
Sunday, December 15, 2002

*  Recent Topics

*  Fog Creek Home