r/javahelp • u/Troctor99 • Aug 07 '22
Java GUI Framework to learn in 2022?
I want to learn a Java GUI dev framework, but I don't know which ones are used nowadays.
I've seen people talking about JavaFX and Swing, but I don't know if any of those are outdated or not used anymore. And also, does any of these come with a Scene Builder like QT or do I have to do everything manually like you do with TKinter (in python). Any suggestions are appreciated :D
13
7
u/wildjokers Aug 08 '22
JavaFX and Swing are both used. JavaFX is a little newer. Swing is still in the JDK so is easier to get started with and has much better documentation.
Both have GUI builders available but for Swing I wouldn’t use one because they are nothing but java code generators.
JavaFX on the other hand has an intermediate FXML file format available which is what SceneBuilder generates so it isn’t generating java code. So it is more accepted to use SceneBuilder in JavaFX.
Saying that though for both Swing and JavaFX I find it much faster to code the GUIs by hand. (Opinions vary though)
2
u/8igg7e5 Aug 08 '22
Both Swing (part of Java) and JavaFX (OpenJFX) are current technologies
JavaFX is a newer framework with a number of nicer features but is not yet widely used.
Swing is much older, and somewhat clumsy to work with, but has wider use.
Both had early attempts at GUI builders, with mixed success (even though JavaFX is somewhat designed to make this more tractable). I don't know what the state of the art of GUI designers is today however, for either framework.
I would suggest, if you can, to look at JavaFX first - it has a more modern approach and is being actively improved (though no longer as part of Java itself - which might actually be an improvement in the degree of engineering effort it is now receiving) and, while Swing continues to be supported, Swing is unlikely to see any fundamental improvement.
1
1
u/red_dit_nou Aug 08 '22 edited Aug 08 '22
Swing and JavaFX are both good options. But take a look at Vaadin as well.
If you are building for Android in Java/Kotlin. Android SDK has good library for UI.
If you really want to do low level graphics stuff, take a look at OpenGL/WebGL.
And if you want to build web UI and use a popular option then explore one of the JavaScript frameworks like ReactJS.
1
1
u/philfrei Aug 09 '22
JavaFX has the equivalent of a DOM tree, and is much easier to learn. If you've accessed HTML with JavaScript, some of that knowledge will be transferable. Swing has more than a few weird and arbitrary complications. On the downside, JavaFX is an external library, not part of core Java, so it really helps to have something like Maven to assist with building a project. There's good documentation for JavaFX at openjfx.io, which also has the scene builder you are looking for.
1
Oct 16 '22
You can also create a mobile app with GraalVM and OpenJFX, you could use Gluon's free plan for mobile components or write your own. There's also Jetpack Compose that supports Windows, Mac, Linux and Android but not iOS yet.
4
Aug 08 '22
[removed] — view removed comment
1
u/Troctor99 Aug 08 '22
Yeah, I already learned PostgreSQL. But I dont have any project to test it on yet because I still dont know any frontend, but in the future I'm thinking of making a small twitter-like page (users, posts, and stuff), just to test my front end and back end knowledge. When that time comes I think it would be fine to learn how to make it a desktop app with Electron too, and have everything covered.
Thanks for the advice tho
•
u/AutoModerator Aug 07 '22
Please ensure that:
Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
You include any and all error messages in full
You ask clear questions
You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.
Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar
If any of the above points is not met, your post can and will be removed without further warning.
Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.
Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.
Code blocks look like this:
You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.
If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.
To potential helpers
Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.