/r/JavaFX

Photograph via snooOG

JavaFX is an open source, next generation client application platform for desktop, mobile and embedded systems.

Useful resources (Full list)

Rules

  1. No NSFW/NSFL content
  2. No service requests/offers
  3. Must be JavaFX related
  4. No politics

Related subreddits

Other communities

/r/JavaFX

8,034 Subscribers

3

Trying to get started with Java FXML, stuck at setup

Hi.

I'm trying to get started with FXML, to create a simple Video player.

I've setup the following:

IntelliJ - latest version

Setup Java, Setup Environment Variables: added new JAVA_HOME, and added bin folder to PATH.

openjdk-23.0.2_windows-x64_bin

openjfx-23.0.2_windows-x64_bin-sdk

Scene Builder.

If I add just buttons in scene builder, it runs, i see the interface but I get the error:

Feb 02, 2025 11:30:43 PM javafx.fxml.FXMLLoader$ValueElement processValue

WARNING: Loading FXML document with JavaFX API of version 23.0.1 by JavaFX runtime of version 17.0.6

If I add Media View, it no longer rungs, and I get the error:

Exception in Application start method java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at 
javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:465)
 at 
javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
 at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1164) Caused by: java.lang.RuntimeException: Exception in Application start method at 
javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:901)
 at 
javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
 at java.base/java.lang.Thread.run(Thread.java:1575) Caused by: javafx.fxml.LoadException:```

//path to hello-view.fxml

at javafx.fxml/javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2714) at javafx.fxml/javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2986) at javafx.fxml/javafx.fxml.FXMLLoader.processImport(FXMLLoader.java:2830) at javafx.fxml/javafx.fxml.FXMLLoader.processProcessingInstruction(FXMLLoader.java:2765) at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2631) at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2555) at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:2523) at com.ddusoftware.vld/com.ddusoftware.vld.HelloApplication.start(HelloApplication.java:14) at 
javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
 at 
javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
 at 
javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
 at java.base/java.security.AccessController.doPrivileged(AccessController.java:400) at 
javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
 at 
javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
 at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at 
javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
 ... 1 more Caused by: java.lang.ClassNotFoundException: javafx.scene.media.MediaView at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:528) at javafx.fxml/javafx.fxml.FXMLLoader.loadTypeForPackage(FXMLLoader.java:3054) at javafx.fxml/javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:3043) at javafx.fxml/javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2984) ... 15 more Exception running application com.ddusoftware.vld.HelloApplication  Process finished with exit code 1

What am I missing? The code I'm familiar with, the setup is killing me :(

4 Comments
2025/02/02
21:37 UTC

1

Anyone knows what this means?

4 Comments
2025/02/01
20:16 UTC

6

Need Help Beginner

Please someone explain why first statement works but not the other In both directory libraries are present. I am new to JavaFx so don't know much

6 Comments
2025/02/01
06:37 UTC

1

what should be the type of parent pane when you want to dynamically add children "Panes" to it and also make app responsive?

purple pane is my parent pane, for which i used Anchor pane. But apparently it doesn't take max-width of available space (even if the max-width is set to computed)

https://preview.redd.it/n0aoh0pls9ge1.jpg?width=2560&format=pjpg&auto=webp&s=9dacb051420553902b0d1f9d0d2f88f35ec8e1ac

4 Comments
2025/01/31
06:04 UTC

6

Will Compose Multiplatform become the JavaFX killer?

Only facts:

ParamCompose MultiplatformJavaFX
LanguageKotlinJava
Age5 years17 years
LicenseApache License 2GPL 2 + CPE
Stars16.7k2.8k
Forks1.2k489
Contributors15690
23 Comments
2025/01/29
16:51 UTC

12

JavaFX/Gluon status vs other options

I have some ideas for some projects I want to make that I'd like to run on Windows/Linux/OS X and also Android/iOS.

I've looked into various options, and I really like JavaFX and Gluon based on what it promises: A solution that allows you to write basically all of your code in Java and have it compiled to native across the environments I mentioned. That said, I've started to play around with it, and I find the documentation isn't great (it's more of a JavaDoc reference than some type of programmer guide), I find that there are some weird quirks and issues (for instance, I never managed to get anything to work properly when building with Gradle, but Maven seems fine), etc. And honestly, I'm quite worried that JavaFX/Gluon will be killed, or that it will simply deteriorate in terms of maintenance and usage will dwindle.

It seems that the most popular options aren't great for various reasons, such as performance issues, lack of Linux support, JavaScript (I really just don't like JavaScript). Nonetheless, I'm wondering if I should simply go with something more popular than JavaFX/Gluon. By picking a popular technology, I get a large community of people solving similar problems and writing libraries and stuff.

What is the status of JavaFX and Gluon today? Would you use these technologies for a new project? If not, what would you use instead?

21 Comments
2025/01/28
16:48 UTC

0

Custom Cell Factory in ChoiceDialog

Hey, I want to create a custom Cell Factory for the drop down menu in the choice dialog like I already did it for a normal ComboBox, but there does not seem a way to do that.

Am I doing something wrong or is there no way to do that?

5 Comments
2025/01/28
14:18 UTC

2

Advise needed javafx devs. Do i use a scene or pane here?

I have always understood scene as the white plain surface on the stage(like a canvas). I know the root node is placed in it. Can you tell if i should use pane such as anchor pane for the following purple container on the right side

https://preview.redd.it/ns4yt2v01kfe1.jpg?width=1390&format=pjpg&auto=webp&s=6b52288ec6cdc30ea8cae135ca38bbc931143848

The purple container should show content based on click on various button('dashboard', 'Available Room' ) placed on left side of the screen.

The reason for my confusion is that there is option to add a scene in Scene Builder. So what basically is scene?

4 Comments
2025/01/27
15:28 UTC

2

What libraries can you suggest for styling JavaFX with CSS?

I use AtlantaFX for Javafx styling. This is a great library and I am sure everyone knows it. But can anyone suggest other libraries?

1 Comment
2025/01/27
09:18 UTC

2

can we use % to define width and height of nodes (to set some percent of width/height based on its parent node) ?

7 Comments
2025/01/27
05:54 UTC

4

Scene Builder Help

I can't see the drop down option that shows available methods of my corresponding controller class (to use for my Button)

tried annotating both the button and the method with @ fxml

https://preview.redd.it/p2z4hw9ipgfe1.jpg?width=2704&format=pjpg&auto=webp&s=8fca984bf439f94502c2c634ac355279c8eab0e2

https://preview.redd.it/rjt63byspgfe1.jpg?width=2560&format=pjpg&auto=webp&s=de3f637e56c4dec708d16f8ffbdb3a2ed2c7a63b

11 Comments
2025/01/27
04:17 UTC

3

What could be the reasons not to use JavaFX for new projects?

I am working with JavaFX development, and it seems to me that today, for new projects focused on creating desktop UIs, it should be used. However, just recently on r/java there was a question - Anyone still using JavaFX? That made me wonder – what could be the reasons not to use JavaFX?

12 Comments
2025/01/25
18:41 UTC

4

Does any use buy commercial support for JavaFX?

There are companies that provide commercial support, for example Gluon. Besides I was once asked by oracle employer (we were talking about javafx) if I had a subscription(???). Taking into consideration that UI bugs can seriously decrease the quality of the product does anyone buy commercial support? If so, what is its price?

3 Comments
2025/01/26
10:01 UTC

1

is it true that src/main/resources Is Sometimes Called the "Classpath Root" (Informally)?

GPT was calling the path as root classpath and said it's informal

2 Comments
2025/01/25
08:30 UTC

2

.toExternalForm() not displaying my image in javafx

[DUMB Mistake- SOLVED)

I am using maven build (inside IntelliJ), and have kept my image under resources/images folder. My app is running but image is not rendering, though in the final build i can see my images folder with bank_logo.png (view

My code:

        Group root = new Group();
        Image bankImg = new Image(getClass().getResource("/images/bank_logo.png").toExternalForm());
        ImageView imageView = new ImageView(bankImg);
        imageView.setX(100);
        imageView.setY(200);
        root.getChildren().add(imageView);

I have also tried using input stream by

InputStream inputStream = Main.class.getResourceAsStream("images/bank_logo.png"); 
Image bankImg = new Image(inputStream);

and got "Input stream must not be null" exception //idk why

I have also tried using other methods stated in Img Not displayed articles such as using file: and putting the img directly under src/main and using the absolute path. But none of them helped, sadly.

7 Comments
2025/01/24
11:50 UTC

10

How to "deploy" my JavaFX app?

Like how do I share it with other people.

14 Comments
2025/01/22
20:19 UTC

0

java market application in javaFX

I'm working on developing an application that helps manage store items efficiently and visually represents the data using a pie chart. The goal is to make it easier to track inventory, analyze stock distribution, and gain insights into sales or product categories. I've already experimented with some functions, but I'm still refining the implementation to ensure accuracy and usability.

18 Comments
2025/01/21
19:50 UTC

1

How to clear an ItemView?

I'm working on a UI part, which is basically a list of directories and its contents

https://preview.redd.it/mtch8nu53eee1.png?width=1285&format=png&auto=webp&s=5d41e912d7f293b2d5f5af295eee8562a9d66407

Whenever you select the ChoiceBox, there is a list of subfolders.

I have a ChangeListener hooked up to ChoiceBox, which basically calls

listView.getItems().clear();
listView.getItems().addAll(...);
listView.refresh();

If I'm switching content of listView from 10 elements to 3 (from `Interrogator` to `Pariah Nexus`) I'm getting leftovers.

And the leftovers are not clickable. Just a graphical glitch.

How to address this?

10 Comments
2025/01/21
18:26 UTC

3

Is it possible to define layouts to fill the whole space?

Started working on an app (still brainstorming the details)

https://preview.redd.it/o4z9zut6zide1.png?width=1435&format=png&auto=webp&s=9f5da1da9cc6e218d5d497ed8638ab4af45616d8

With a structure of

https://preview.redd.it/y1v5yg1azide1.png?width=640&format=png&auto=webp&s=3a48ca6ab5ea96d1c6552747e21cdaf090dba79b

But whatever I try, I can't really make a ScrollPane to stretch to the dimensions of the parent AnchorPane(the VBox is one of many attempts to maybe make it right).

I confess that it has been quite a while (6+ years) the last time I read (it took me a while to find this documentation) the details for each JavaFX element and how they function.

I did manage to make it achieve what I wanted through code, adding a listener to Anchor's height property, but the question is - is it my lack of knowledge how to properly work with this type of elements? Or its simply how the things are(maybe I needed to add CSS to make it work)?

UPD: my bad. Wrote ScrollPane instead of the next in line ListView, which is the problem I'm facing.

16 Comments
2025/01/17
09:50 UTC

0

TrayMenu look outdated

The tray menu available looks very old looking, is there a way to get the modern look such as discord for example ?

Thanks in advance

4 Comments
2025/01/16
14:51 UTC

1

Grouping @JXML into an entity

Is it possible to combine several

```

\@FXML private TextField myField

```

into a separate class, which then would be used in a `\@FxmlView`?

14 Comments
2025/01/16
09:23 UTC

1

Guys I am a beginner in gui application development, can anyone guideme to set up responsive ui page.

When I resize the application window every object moves and not properly resizing. Especially imageview object. Kindly share tutorials or documents to set up responsive UI in javaFX.

2 Comments
2025/01/14
10:31 UTC

1

Scenebuilder menu item

Hi, I am a newbie in javaFx doing a project with it for a course. I am facing some problems regarding menu item. To clarity let me explain in details. I had three buttons- logout, help, settings, corresponding buttons were performing their functions(like loging out, shifting scene to to settings)

Then my faculty asked me to do this with menu bar. When I am doing this with menu bar and setting the same code for the menu items they ar not working at all. What could be the problem? Is there any specific source to learn about this easily?TIA.

1 Comment
2025/01/14
05:43 UTC

1

JavaFX plus Spring Boot 2

Could someone please forward me to a working doc/example/tutorial for adding JavaFX (openjfx or smt) to an existing SpringBoot 2 project?

21 Comments
2025/01/13
17:21 UTC

3

Is JavaFX is the go to now?

1 Comment
2025/01/13
07:12 UTC

3

Newly added Items to ListView are not selectable.

I've tied the observableList to the extent of the 'Studio' class. In this way:

ListView<Studio> studioListView = (ListView<Studio>) scene.getRoot().lookup("#studioListView");
studioListView.setEditable(false);
studioListView.getSelectionModel().setSelectionMode(SelectionMode.
SINGLE
);
ObservableList<Studio> studioList = FXCollections.
observableList
(
grabStudioExtent
());
studioListView.setItems(studioList);

The problem I'm having is when new objects are added to the extent, the list updates and shows them, however I can't select them in the ListView anymore. I've looked around on the internet for a solution but can't seem to find anything.

4 Comments
2025/01/12
20:26 UTC

14

Ikonli Icon Browser

I created this app because I use Ikonli a lot. There are tons of icons, and at this time, they do not have a complete icon browser. Their browser is in the works.

My browser will allow users to search all icons, search icons by provider, browse all icons, or browse icons by provider.

Improvements I would like to see in the future:

  1. A splash screen. It takes the app a while to load all of the icons.
  2. A better UI look. If anyone is good at UI's, let me know.

Link to repo -> https://github.com/sedj601/IkonliIconBrowser

Try it! If you find bugs or want to see improvements, let me know.

https://preview.redd.it/e6lw4c8hgice1.png?width=1102&format=png&auto=webp&s=f6eaf9acd397a2642a4ea4802277b969709397f6

11 Comments
2025/01/12
07:05 UTC

2

How to align a button to the right of a vbox with the middle of the vbox children?

https://preview.redd.it/tmmj2jtyxhce1.png?width=1251&format=png&auto=webp&s=a2e2922edb60b46fedcfb4f1c135efad7256f2f3

For the file upload area I have it set up so that there is an Hbox whose children are the Vbox containing both labels and the button to the right. How do I get the button to align with the middle of the two labels? (moving it down a few pixels essentially)

Thanks!

4 Comments
2025/01/12
05:14 UTC

0

Afterburner.fx - File: *.fxml not found

Hey,

I am trying to figure out why my *.fxml are not loaded in my JavaFX + Afterburner.fx app.

I made a question with details here: https://stackoverflow.com/q/79348850/17985451

Help would be kindly appreciated.

Thanks

0 Comments
2025/01/11
22:37 UTC

Back To Top