GUI creation in Scala but WITHOUT Swing/AWT
Asked Answered
L

3

7

I'm going to write a new application which shall have a GUI. As I recently crossed a book about Scala (and became really choked-up) I decided to learn that language first and then try to build the program.

What I was wondering: Is there any decent way to build a GUI in Scala without being forced to make use of the Swing/AWT toolkits? I don't like Swing/AWT as they seem immature in comparison to Qt & Co. Unfortunately I could not find much information about building a GUI in Scala without depending on those.

As I am quite new to Scala and don't know too much about it, yet, I'm also wondering if the Java-binding of a specific toolkit could be used in Scala in a way that didn't sacrifice any of Scala's pleasant features (e.g. pattern matching).

One further note: The toolkit should support Linux and Windows and the Look-and-Feel should equal the native one on each platform.

UPDATE: This is my current ranking of toolkits (feel free to comment on this):
1. SWT
+ native L&F
+ a real Java solution
. not sure about performance, yet
. not sure about the easy of learning and coding, yet
- dealloc needed to free resources
2. Qt Jambi
+ partially native L&F
+ many possibilies
+ quite easy to learn
. not sure about performance, yet
- a wrapper around a C++ toolkit => might the code become ugly?
3. Java Gnome
. not sure about anything, yet - has anybody tried it?

Toolkits for which no actively developed Java wrapper seems to exist:
- WxWidgets

Toolkits which are discarded:
- Swing/AWT: Old and I don't like the coding
- JavaFX: Rich Internet Application targeted - I want a standalone application

A new toolkit written for Scala programmers from scratch would be nice but I guess this won't happen due to the possibility of reusing Java based solutions.

Lauraine answered 22/5, 2011 at 12:24 Comment(5)
There are Java bindings for Qt. And the only way to get a native look and feel is to either use the native widgets or a toolkit that uses them (AWT or wxWidgeds comes to mind). Qt does its own painting and so does Swing. Both are (imho) inferior in terms of UX to native widgets usually.Gallows
Unfortunately there does not seem to be a Java binding for wxWidgets which is actively developed, or am I wrong?Lauraine
I just read that Qt by this time tries to use the native APIs available on each platform: en.wikipedia.org/wiki/…Lauraine
there is Scala Swing DSL ingomaier.blogspot.com/2010/11/…Primrose
Here is Scala with SWT post: #5707407Primrose
H
6

Scala should be able to do anything you can do in java, so yes if you have a java binding for a gui library, it should work fine.

Have you looked at SWT, as an alternative to AWT/Swing? It uses native widgets whenever possible. Eclipse is written with SWT.

Harmonic answered 22/5, 2011 at 12:34 Comment(3)
If I remember right, Eclipse also tends to be quite slow (although I don't know whether this is caused by the GUI or by the backend). Therefore I'd preferably use a toolkit which has already proofed to be more lightweight. I'll have a look at SWT anyway.Lauraine
Bastian: Eclipse's slowness is mostly a result of it being a gigantic, unmovable behemoth. SWT incurs a penalty for every event since you need to step out of Java-land into native code and back, but for a normal UI that's rarely a problem.Gallows
Second what Joey says. Eclipse is a beast (but a good tool nontheless). SWT is fast. Speed was one of the main design goals of SWT at OTI/IBM.Harmonic
M
0

What about JavaFX ? JavaFX 2.0 expected to release soon. You do can write JavaFX into Scala :)

Mcadoo answered 22/5, 2011 at 16:35 Comment(5)
oops i think JAvaFX2.0 first released for Windows and later adopts linux and mac!Mcadoo
I haven't heard about it, yet. So I'll have a look at it tonight and then give you some feedback about whether it suits my needs.Lauraine
Ok now that I have checked JavaFX I think will decide to not use it as it is intended to develop Internet applications whilst I am going to build a simple standalone desktop application. It therefore shouldn't be dependent on a Browser. Additionally I always felt that such Java browser programs appeared to be a bit sluggish.Lauraine
JavaFX is a Rich Internet Application. I like to call it as Rich Application. Not necessary you only develop internet applications. RIA gives a very good User Interface better than Swing or any other GUI application.Mcadoo
The current issue is its goign to be released as beta. if you can develope in that you are welcome. but first release is only for Windows later you got for others.Mcadoo
T
0

QT-Jambi is the way to go, it doesn't work out of the box,

Instructions? This link will be useful for you: http://www.davidlauzon.net/2010/01/getting-started-with-qt-jambi-on-linux/

http://qt-jambi.org/downloads

I suggest to use the 4.6.3 because is complete, the betas has missing files

__

I decided to learn that language first and then try to build the program.

And i dont know if you are looking specific Java solution, but Python is a good alternative, and you can choose QT (again), wxWidgets, and more...

Python QT Specific there are 2 bindings, one is PyQT, and PySide, the advantage of last one is LGPL license and you can monetize it.

Sample code here and here: http://qt-project.org/wiki/PySide_Example_Applications https://github.com/PySide/Examples

Toxic answered 23/10, 2014 at 0:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.