Java-Gaming.org
Java4K - to go         Javadoc:
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources or peek at the official java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  Alternatives to Swing  (Read 1335 times)
0 Members and 1 Guest are viewing this topic.
Offline Marvin Fröhlich

JGO Wizard
****

Posts: 1435


May the 4th, be with you...


« on: 2010-09-02 11:27:20 »

Hey,

I have googled for this a little and found results here and there, but nothing, that truely satisfies me.

I am looking for a GUI library for Java, that offers two main requirements.
1. It should have a nice and modern API design
2. It should not be implemented in software all along, but make use of platform specific native GUI calls as much as possible.

Theming is one thing, but in 99% of all cases you will want to make your application look like any other app on your platform. So a button should look like a button on KDE or Win 7 or what ever you're running the application on. So by default the GUI should look and behave like any other app on your platform and optionally and less importantly there COULD be the ability to theme it.

Controls like JTable or JTree are very powerful, but simply suck. I love the model approach and you can easily implement a default table with default renderers/editors and event handling. But when you want something more complex, it starts to stress you with unexplainable malfunction, which costs a lot of time to fix or to workaround.

A modern API should make use of enums instead of static int constants. This is much easier and intuitive to use.

Of course the API must be platform independent. So there have to be native libraries for all supported platforms, so that as much of the drawing as possible can be done by the windowing system natively. When a button is created, this shouldn't mean to let Java paint a button, that looks like a platform specific one, but this should ask the platform to create a native button. This applies to all controls, that are supported by the platform. The unsupport ones would have to be rendered in software mode. This makes sure, that the GUI is as responsive as any other app on your platform, but doesn't suffer from slower software mode.

Of course a library like this would have to replace AWT/Swing as a default in the JRE/JDK, so that all the needed natives can be shipped with it and it would be usable in an applet or Java web start.

What do you say? Is there something like this out there?

Marvin
Offline CaptainJester

JGO Neuromancer
****

Posts: 1127
Medals: 6


Make it work; make it better.


« Reply #1 on: 2010-09-02 11:54:18 »

SWT http://www.eclipse.org/swt/docs.php

Quote
Portability and platform integration
SWT defines a common portable API that is provided on all supported platforms, and implements the API on each platform using native widgets wherever possible. This allows the toolkit to immediately reflect any changes in the underlying OS GUI look and feel while maintaining a consistent programming model on all platforms.

Online kappa
« League of Dukes »

JGO Kernel
*****

Posts: 2268
Medals: 50


★★★★★


« Reply #2 on: 2010-09-02 12:10:27 »

Theres also QTJambi http://qtjambi.sourceforge.net/ , doesn't get more native looking then this toolkit (Even integrates nicely with KDE). Also has a host of really powerful tools and editors.
Games published by our own members! Go get 'em!
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 7800
Medals: 77


Eh? Who? What? ... Me?


« Reply #3 on: 2010-09-02 13:21:29 »

JTable and JTree aren't half bad when you figure out the bits of voodoo you need to do to make them work nicely.

Cas Smiley

Offline CaptainJester

JGO Neuromancer
****

Posts: 1127
Medals: 6


Make it work; make it better.


« Reply #4 on: 2010-09-02 13:55:41 »

JTable and JTree aren't half bad when you figure out the bits of voodoo you need to do to make them work nicely.

Cas Smiley

Yeah, the MVC makes these controls delgate everything.  It just takes a bit of hunting to find the correct delegator to override to make them do what you want.

Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 7800
Medals: 77


Eh? Who? What? ... Me?


« Reply #5 on: 2010-09-02 15:13:09 »

And a few hacks and tweaks and overrides and putClientPropertys. But it's all good in the end.

Cas Smiley

Offline gouessej

JGO Kernel
*****

Posts: 3429
Medals: 26


TUER


« Reply #6 on: 2010-09-02 15:59:24 »

Yes. Actually, it has some nice platform-specific bugs especially in the drag and drop gesture on Linux  Grin

Julien Gouesse
Offline dime

JGO n00b
*

Posts: 40



« Reply #7 on: 2010-09-02 18:44:54 »


For desktop apps I really like SWT: http://www.eclipse.org/swt/
SWT calls the native api so it looks/feels/works like a native app


For games (open gl base), TWL is really nice: http://twl.l33tlabs.org/
TWL is themeable, you can do just about anything with it.
It'll look/feel the same on all platforms (which is probably want you want for a video game)
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 7800
Medals: 77


Eh? Who? What? ... Me?


« Reply #8 on: 2010-09-02 21:54:31 »

TWL does look very good.
Also consider PureSwing.

Cas Smiley

Offline zammbi

JGO Strike Force
***

Posts: 963
Medals: 9



« Reply #9 on: 2010-09-02 23:56:23 »

Could do a front end in JavaFX to build the GUI.
But of course it will look the same on every OS, but who know's there could be theme libraries to solve this.

Current project - Rename and Sort
Games published by our own members! Go get 'em!
Offline kaffiene

Sr. Member
**

Posts: 387
Medals: 1



« Reply #10 on: 2010-09-03 00:03:35 »

Yeah, the MVC makes these controls delgate everything.  It just takes a bit of hunting to find the correct delegator to override to make them do what you want.

'zactly.  Those are incredibly flexible classes - it just takes a wee while to figure out how they work internally when you want to do custom cell editors or renderers.
Offline gouessej

JGO Kernel
*****

Posts: 3429
Medals: 26


TUER


« Reply #11 on: 2010-09-03 07:21:39 »

The last line crashes the JVM on Linux because SWT calls the win32 native method instead of calling the Linux method in ImageTransfer.nativeToJava(TransferData data):
1  
2  
3  
4  
5  
final PaletteData palette =  new PaletteData(0x0000FF, 0x00FF00, 0xFF0000);
final ImageData imgData = new ImageData(256,256, 24, palette);
final Clipboard cb = new Clipboard(getDisplay());
ImageTransfer imageTransfer = ImageTransfer.getInstance();
cb.setContents(new Object[]{imgData}, new Transfer[]{imageTransfer});

It is not serious! calling a native method for Windows on Linux!
This is an example of bugs that shows SWT is not reliable especially on Linux. This bug has already been reported and has never been fixed... I know some other bugs of this kind (I have to close Klipper on some Linux machines otherwise the drag and drop of text does not work in Eclipse, do you want some more?). That is why I don't advise SWT. Maybe have a look at PureSwing.

I'm sorry to insist on this but Marvin Fröhlich seems to be looking for a cross-platform library.

Julien Gouesse
Offline Nate

JGO Neuromancer
****

Posts: 1033
Medals: 26


mooooo


« Reply #12 on: 2010-09-05 01:19:36 »

It's a bit much to eliminate SWT because it has a bug or two. Better to eliminate it because it is difficult to extend if you want functionality beyond what is provided out of the box.

Offline gouessej

JGO Kernel
*****

Posts: 3429
Medals: 26


TUER


« Reply #13 on: 2010-09-05 05:51:02 »

It's a bit much to eliminate SWT because it has a bug or two.
No, there are more than 2 bugs that are specific to Linux in SWT and the most used workaround often consists in mixing SWT with AWT... which might cause some other problems.

Better to eliminate it because it is difficult to extend if you want functionality beyond what is provided out of the box.
I agree with you.

Julien Gouesse
Offline Marvin Fröhlich

JGO Wizard
****

Posts: 1435


May the 4th, be with you...


« Reply #14 on: 2010-09-06 11:58:45 »

Thanks a lot, guys, for these very detailed answers.

Yes, I am looking for a cross platform library, that doesn't look the same on all platforms, but makes use of native components and hence looks like a native app with the locally selected theme or what ever.

I am not a big fan of SWT neither. It has an ugly API and doesn't work too well on Linux. I once ranted the Eclipse devs, that they don't care for Linux too much and Eclipse works a lot better on Windows. Maybe it wasn't fair, but it was  and is true.

Perfect would be something like SWT with a nice and modern API and with less platform specific bugs.

I will have a look at PureSwing. I didn't know that one.

Marvin
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.154 seconds with 20 queries.