Tutorial Kotlin GUI


#1

Anyone have a tutorial or step by step how I can get by kotlin a drag and drop GUI System


#2

Kotlin does not provide a GUI framework. If you target the JVM, you can use JavaFX, Swing (obsolete), AWT (even more obsolete) or any other third-party framework.

Kotlin is a programming language. It has a small standard library so the same code can be used for the targets it supports (JVM, JavaScript and native). Most functionality that you need has to come from existing Java/JavaScript libraries, Kotlin wrappers around these libraries and/or libraries written from scratch in Kotlin. If you find a library/framework that you want to use, simply follow the tutorials for it, translating the example code to Kotlin where needed.


#3

You could try tornadoFX. there is some training material, and even an intelij plugin. TornadoFX is a wrapper for JavaFX with the goal of taking advantage of kotlin. (i have not tried this yet, but it seems to be the best answer i found while considering the same question)


#4

AWT and Swing are not two different GUI toolkits. Swing is implemented on top of AWT and except for the file chooser, the couple of native widgets that AWT implemented in Java 1.0 are not relevant and do not constitute a separate toolkit.

AWT/Swing is not obsolete, it’s one of the two GUI toolkits in the JRE. It’s actively maintained (see for example the new multi-resolution icons in Java 9) and 2 of the 3 major IDEs on the JVM are built with it, the other one uses SWT.


#5

tornadoFX is a great library. In fact, I tried it and moved all of my GUI code to kotlin from java just to be able to use it. It is still not fully documented, but they are making efforts to fix it here.


#6

AWT and Swing might not be obsolete from the “current usage” point of view, but someone starting a new project should avoid them and prefer more recent alternatives like JavaFX (which already starts being old now).


#7

Would ElectronJS be a viable framework when compiling to JS?


#8

I’d say there are no really good options right now. At least the “current usage” point of view guarantees that the major stakeholders have an interest in keeping things going. I’m using the JetBrains runtime (an OpenJDK fork), for example, where JetBrains is kind enough to fix all sorts of AWT/Swing bugs that Oracle is not interested in.