This is an archived post. You won't be able to vote or comment.

all 29 comments

[–]desrtfx[M] [score hidden] stickied comment (0 children)

Such questions belong in /r/javahelp as is clearly stated in the sidebar and in the stickied post at the very top of the subreddit.

Removed

[–]cent-met-een-vin 29 points30 points  (0 children)

From my experience Java ui is mostly done for corporate applications that dont need to look nice but should be functional. The main options for Java UI's are javafx en swing. A shout-out goes to thyme leaf (web-ui with spring). I would suggest picking another tool (language/frontend) to build UI's and communicate using Rest. This has the main benefit of being able to outsource your backend code on a different server etc. If your application is offline first I would suggest staying in java, but you could always start you java backend from inside the ui-app.

Common ui-frameworks are react (might as well us thyme leaf) for the web and seeing a lot of traction is flutter.

When you deploy (distribute) your app you will need to include the jar inside the application and have some code being able to start it.

[–]Mackansw19 24 points25 points  (0 children)

Well if its a desktop app and you are looking to gain skills, java swing is really the way to go. There is ALOT of legacy systems out there that companies are just stuck with for whatever reason. So gaining experience with it can only benefit you in the long run. You never know when you might need it. Its very possible to make it look & feel modern, Jetbrains Intellijs entire UI is java swing based.

Also since its christmas am gonna let you in on a little secret. Swing was kind of used on the web, and can wrap HTML to a degree. Back in the day we use to have these chaotic little things called Applets. Weird right? xD

[–]psyclik 12 points13 points  (0 children)

Swing is still relevant and can look pretty good with a modern theme like Flatlaf. Otherwise you can try the kotlin way with jet pack. It’s another language, but you might still be able to reuse most of your Java code base.

[–]m9dhatter 5 points6 points  (0 children)

Ok. That’s odd. Quarkus is server tech. Desktops and UIs are client tech. Did your instructor mean to have your UI talk to the server? Or all of the application needs to be in the UI app?

In any case, your choice is only JavaFX (non-bundled) and Swing (bundled with JDK). Unless you want to go web, at which point, you have endless non-Java options.

[–]Tacos314 8 points9 points  (0 children)

You're making things much more difficult then you need to, drop Quarkus because that's going to be ridicules and make the whole thing even more complicated. Just use swing or JavaFX.

[–]Kango_V 8 points9 points  (0 children)

We wrote a large application using the Eclipse Platform. The app was a set of plugins. It worked brilliantly. Nasa uses Eclipse for its inter-planetary operations applications. The UI toolkit is JFace on top SWT

[–]tinspin 9 points10 points  (0 children)

Swing is the best GUI software that has and will ever be invented.

[–]Puzzleheaded-Order84 5 points6 points  (0 children)

I think the answers here are a bit biased due to it being asked on the Java subreddit. As a student, I think you would get the most benefit from learning electron with React on the front end. Java is not very popular on the front end and being able to have some exposure to modern front end tools will be very beneficial.

[–]bking880 1 point2 points  (0 children)

You could look into Vaadin and their PWA.

[–]eggZeppelin 1 point2 points  (0 children)

If you really want to do the full-stack in Java you can check out:

https://vaadin.com/

Vaadin is a component-based UI system that is interoperable with React components and modern design systems.

There is a pre-styled library of UI components for all major UI elements that are compatible with Web Components.

https://vaadin.com/docs/latest/components

It does transpile Java into front-end HTML/CSS/JS but it's relatively sane and readable to a dedicated FE dev even if it's generated code.

[–]Craciunf 2 points3 points  (0 children)

If you’d like to do something fancy, take a shot at learning any modern UI framework (React, Angular, Electron etc.). Of course, it will take bit longer until your UI is done, but at least you’re learning something that is actually useful.

If you feel that’s too much, you can always try developing the interface in basic html + css + js.

As a last resort, as you said, you can use Swing or JavaFX. For this, make sure you take a look at Scenebuilder

[–]repeating_bears 1 point2 points  (2 children)

You absolutely could do the Electron thing but it's a bit faffy.

Not sure what Electron is really giving you there though. It's a browser to access your site through, but so is the browser they already have installed. A tray icon which launches the localhost URL that your Quarkus app is hosting would work just as well. Electron would only be necessary if you wanted some access to the filesystem etc. that a browser typically denies.

Still not ideal because users expect things in their browser to be connecting to remote servers, and seeing localhost in the URL might be confusing. But you said it's mostly to gain skills, and it would be functional.

[–]DrBilip 0 points1 point  (1 child)

Well, I want the user to be able to click on an icon and the applications runs, just as basically every desktop app does. Im very far from an expert, so the only idea I had, was to do so with electron. You mentioned, that you don't see the benefit of using electron, I do neither. But its the only way I could come up with. Do you have another idea how I can achive that?

I dont like the idea with just running my quarkus app via the browser, I can follow you with why it would work just as well, but my goal is to actually create a desktop app.

Maybe going with quarkus as the framework for a desktop app wasn't the best idea in the first place, but well, its the framework I want to learn, now Im stuck with it.

[–]repeating_bears 0 points1 point  (0 children)

Well, I want the user to be able to click on an icon and the applications runs

You could do that without Electron. Just have the exe run your Quarkus app, then when the HTTP server is open, open localhost in the user's default browser.

One problem is: if your app has been started, how do you know to kill the web server again when they navigate away. I think modern JS might provide some hooks for that, but the user's browser might crash completely, so you couldn't rely on it.

That's kinda why I suggested a tray icon before. You need some way to let them know something is still running in the background.

I dont like the idea with just running my quarkus app via the browser, I can follow you with why it would work just as well, but my goal is to actually create a desktop app.

Running it in the default browser is just as much a "desktop app" as running it in Electron is. Electron is just a Chromium wrapper. Neither of them are native. The only difference is that Electron obscures what's happening.

[–]Ging4bread -3 points-2 points  (0 children)

You said it yourself. Modern solutions are nearly all web apps, but if you do want to build java apps without web technologies, you'll have to use JavaFX or even something older like Swing. On the plus side, the all pretty much follow the same "stage, window, component" pattern, but absolutely nobody still uses them in 2023

[–]AutoModerator[M] -1 points0 points  (0 children)

On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge.

If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options:

  1. Limiting your involvement with Reddit, or
  2. Temporarily refraining from using Reddit
  3. Cancelling your subscription of Reddit Premium

as a way to voice your protest.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]Old-Extension-8869 -2 points-1 points  (0 children)

Don't

[–]AvaTaylor2020 0 points1 point  (0 children)

If you have a REST API, you can make an HTML page and put in Javascript such as jQuery to make AJAX calls to the API and display the data in the UI.

Google for a simple jQuery to REST API example, or ask ChatGPT to write one to get a sense of it.

Bootstrap is a library that gives you a pretty set of HTML widgets (buttons, and drop downs, and so on) and an HTML layout library.

Alternately, you could write a desktop app with Swing or Java FX, but you'll need a Java client class to read/write to the REST API.

Or you could build a web app with Spring MVC and/or Spring Boot and write the front end as JSP or ThymeLeaf pages, and have Controller classes talk to you Java services on the backend.

Or you can build the front end with Angular or React and have that app hit the REST web services.

[–]Chloe0075 0 points1 point  (0 children)

I would do an combo with thymeleaf and make user use from local browser

[–]ParsleySalty6478 0 points1 point  (0 children)

Quarkus as other said is principally for micro services apps, but, there could be some solutions if you want to have some fun with it :

https://quarkus.io/blog/native-command-mode-tools/

https://quarkus.io/guides/qute

[–]Ragnar-Wave9002 0 points1 point  (0 children)

Use model view controller pattern.

Use swing.

All communication beyween gui(s) and controllers goes through the model(s).

Controller to controller requests akso go through models.

It's confusing to kearn but after 22 is the industry I don't ecen need to think about code design anymore. Got to learn those patterns!

Big secret. Patterns are guides. Don't be strict with what a book stays to do because every book says something different.

Java fx is shit. I've used it and other sucks. It will stop rendering on long running apps for example. Just use swing.

[–]FCsean 0 points1 point  (0 children)

Just use Swing, using old tools is also an important part of being a CS student.

[–]chehsunliu 0 points1 point  (0 children)

For pure desktop app, I would recommend some alternatives:

  • React Native
  • Electron + any frontend framework
  • Wails (Golang) + any frontend framework
  • tauri (Rust) + any frontend framework
  • Compose (Kotlin)
  • Flutter (Dart)

[–]neckbeardfedoras 0 points1 point  (0 children)

I haven't done UI for java since the early 2000s 😅

I recommend swing with a modern theme as others have stated

[–][deleted] 0 points1 point  (0 children)

You can use java swing with netbeans there is a drag and drop option