/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

7,791 Subscribers

7

CSS extension for Ansi4j library

I wrote a CSS extension for the Ansi4j library, which parses text with ANSI functions. There is a demo application showcases how it works. Feedback is welcome.

The CSS extension allows you to style text using CSS in a way that mirrors the styling applied by SGR functions. For example, this extension can be used to style program outputs, log messages, documentation, and more.

To display styled text, you can use components from any platform (JavaFX, Swing), as neither the core library nor the CSS extension (except for the demo module) depend on the classes of these platforms.

Out of the box, the library provides three style generators for JavaFX WebView, JavaFX TextFlow, and RichTextFX InlineCssTextArea. These generators are located in the API module and can be easily modified. A table listing the features supported by each of these components is available in the demo application.

0 Comments
2024/12/02
22:20 UTC

5

Why does the error occurs? Can anyone please explain and correct it for me? Thank you.

3 Comments
2024/12/02
10:27 UTC

3

Dialogs in MVCI

u/hamsterrage1, what's the best way to show dialogs in MVCI? Where should they be called from?

2 Comments
2024/12/01
23:33 UTC

3

Difficulty in organizing and understanding project structure

Hello! So I am quite new at JavaFX and my lecturer gave me a quite big final project for my Java course.

So basically, it's a desktop JavaFX chatting system (likely cloning Messenger, Telegram, etc) with almost all features for a popular chat app. Including authentication, real-time messaging (including groups), profile edit, add/remove/block friends, search/delete messages and also admin panel for overall system management. And it is also required to be structured using three layered architecture (and sadly including Hibernate too...).

This is just too overwhelming for a beginner at JavaFX like me, I just can't visualize how all the components works together. Like do I have to use sockets for real-time chat? Do I have to do the queries to database for all searches/filters or handle it directly on the GUI?

I'm in desperate need of help. Could you give me maybe just a simple guide of how I should structure my project or some tips on developing such a complex system with JavaFX? Thank you so much in advance!

6 Comments
2024/11/28
14:51 UTC

13

New Article: Dealing With Modena

Modena.css is the stylesheet that ships with modern JavaFX, replacing the old Caspian style sheet. It is tightly integrated with the library of standard JavaFX `Node` classes, and it's over 3,000 lines long. So it can be a bit intimidating.

This article should give you the information that you need to understand how Modena works, and how to add your own styling to `Nodes` when you want to do something a little bit different than Modena but not break everything so that your GUI's look goofy.

Take a look: https://www.pragmaticcoding.ca/javafx/elements/modena and let me know what you think.

1 Comment
2024/11/27
20:51 UTC

1

¿Dependencias de JavaFX para AudioClip?

Hola, estoy utilizando NetBeans IDE23 para hacer un proyecto en Java SDK17 que utiliza JavaFX versión 17, es una aplicación con Ant, no Maven ni Gradle, ya he hecho gran parte de la aplicación y JavaFX ha funcionado bien.

al utilizar los siguientes códigos (obviamente dentro de la respectiva estructura orientada a objetos):

import javafx.scene.media.AudioClip; AudioClip a = new AudioClip("file_path"); a.play();

obtengo un error del tipo:

Exception in thread "JavaFX Application Thread" Exception in thread "main" java.lang.IllegalAccessError: class com.sun.media.jfxmediaimpl.NativeMediaManager (in unnamed module @0x75672d56) cannot access class com.sun.glass.utils.NativeLibLoader (in module javafx.graphics) because module javafx.graphics does not export com.sun.glass.utils to unnamed module @0x75672d56

Pero no sé qué hacer, al parecer faltan dependencias que no han sido importadas o instaladas.

Nota: "file_path" es una ubicación válida, probada y comprobada de diferentes formas, siguiendo el formato requerido por AudioClip.

2 Comments
2024/11/26
00:00 UTC

3

MVVM in JavaFX

Hi, all. I've just started to build my first JavaFX application (Kotlin and JavaFX).

I'm going to use Scene Builder. I've seen the advice to just build views with Kotlin/Java, but I honestly hate building UIs by hand.

I was looking around for a MVVM framework and of course found mvvmFX. But it looks like it hasn't been updated for 5 years. Is it outdated in any way? Should I go ahead and use it?

I also found Cognitive (https://github.com/carldea/cognitive). This looks like it's being actively maintained. And any opinions about this one?

From a quick look, mvvmFX looks more comprehensible to me. Less work on my part and very complete.

And... I could try doing my own hacky MVVM implementation in Kotlin and try to use Scene Builder FXML views. But I'm sure I'll end up re-implementing parts of the wheel.

Any guidance would be very welcome. Thanks in advance.

13 Comments
2024/11/25
22:24 UTC

1

4 a question,About BorderPane

I faced fall a difficult problem with me ,just for building fx-application by using BorderPaneI wanna know if there any ideas, for making BorderPane self-adaptive border-radius, I need Rounded corner effects on BorderPane! :)

4 Comments
2024/11/23
14:36 UTC

7

Creating Delay With JavaFX

Hello! I am studying cs and right now Im programming a little hobby software using JavaFX.

My problem is, I have a long string that is read from a file. I use toCharArray function because what i want to do is append this string character by character to textarea with 20ms delay between characters.

Normally i would use thread.sleep() but it freezes whole program. If someone could point me to a right direction it would be much appreciated.

Thank you in advance!

16 Comments
2024/11/22
14:50 UTC

3

JavaFX runtime components are missing - HELP!

[FIXED] Hey guys, I hope you're all well.

I've got an issue that's driving me insane right now. I was working on a JavaFX project on IntelliJ and I used Maven to build it. Didn't configure anything, Maven did all the work. I was using temurin-21 as my JDK. Two days ago I ran it, and it was working just fine.

Today, I tried to run it to give my team members a demo, and it wouldn't work! It said JavaFX components are missing. WHAT! I did not change anything! I did not touch the file, add code, change settings, nothing! I didn't do anything and it just stopped working. I don't know what to do, it's so frustrating. I updated my IDE, tried changing the JDK to 23 (that's the only thing that happened - I installed JDK 23 for something else on my machine, didn't even use it on IntelliJ) and it didn't work, so now we're back to 21.

I keep getting this error: Error: JavaFX runtime components are missing, and are required to run this application

Why!? The project is due Saturday and it decided to stop working. I checked the pom.xml even though I know the issue probably won't be there, because like I said it was working two days ago. Still, the JavaFX dependency is still there. I'm stuck and I don't know what to do. If anyone has any idea on how to fix this, please let me know. I am so bummed. I added a module-info file, added the requires JavaFX graphics, controls, fxml, specified the package but nothing.

Thank you so much for your help!

EDIT: If you're facing this issue, I found the fix for it. It was not adding a path or reinstalling Maven as some YouTube videos and some stackoverflow posts suggested. Besides the 'requires' lines on the module-info.java file, you should also add:

opens [your package name] to javafx.fxml;

exports [your package name]; both without the [ ] square brackets

The package should be the one that contains your application. I hope this can help!

Additionally, please do check out some of the awesome suggestions that kind commentors made below.

7 Comments
2024/11/20
16:25 UTC

23

Hello, brothers, I am an independent developer from China. It's nice to meet you

Hello, brothers, I am an independent developer from China. It's nice to meet you!

I am looking for a brother who shares my interest in JavaFX to participate in the development of JavaFX public welfare projects. Of course, it must be open source.

Why do I come here to find it? Because JavaFX is not popular in China, because most people learn Java for living, and only learn what Java needs for work in order to make money. I personally am different. Although I have no money and am poor, I like JavaFX. I don't care what others think of the future of this technology. I just feel that I am doing what I like, and that's enough.

I currently have two years of work experience. Unfortunately, I am forced by life and am looking for a job. I hope that after I find a job again, I will spend all my time and energy studying JavaFX after work. I am an obsessed and fanatical person about JavaFX. I have liked Java very much since I played J2ME for the first time in elementary school. This is my project. I hope

https://preview.redd.it/su7x30xsmk1e1.png?width=1502&format=png&auto=webp&s=94182768dea7744139b64c4793aabaadd3a69c08

https://preview.redd.it/axhfwefumk1e1.png?width=1562&format=png&auto=webp&s=4de81fc8a780dc90caf3ed19b8b12f4b11317ce4

https://preview.redd.it/yavmqgpvmk1e1.png?width=1218&format=png&auto=webp&s=56d2fcd3693ef19d2ce7d4aa3cd09d248a10777f

These are all written using JavaFX, and I am looking forward to meeting like-minded brothers to develop JavaFX applications that we love together

my personal email: fntp66@gmail.com

22 Comments
2024/11/18
02:31 UTC

2

Center StackPane in ScrollPane

When I use the code below, I can display a 3x3 grid that is in a center of the window (I see with the ligthgreen that StackPane takes all the place in the window)

GridPane gridPane = getGridPane(image);
gridPane.setAlignment(Pos.CENTER);
StackPane stackPane = new StackPane(gridPane);
stackPane.setStyle("-fx-background-color: lightgreen;");

But when I put this stack inside a ScrollPane, the stack only takes the place of the grid, and is at the upper left. I tried a lot of thing but I can't find a way to center my stack (so my grid) in the center when using ScrollPane. Any idea ?

ScrollPane scrollPane = new ScrollPane(stackPane);
4 Comments
2024/11/16
21:31 UTC

4

New Article: ObservableList Basics

Carrying on after the other Observable articles, we now come to ObservableLists.

I thought this was going to be a pretty boring topic because ListChangeListener is just tedious to deal with - and not a lot of use in day-to-day stuff, but it was actually interesting to get down into the details of how the changes present inside the Listener.

One of the things that I cottoned on to when doing the article about ListProperty was that you can just treat an ObservableList like a plain old Observable, ignore Listiness of it and create a Binding. There's an example of how to do that in the article. It's actually really, really useful and something that I'd wished I'd figured out 5 years ago.

Here's the article:

https://www.pragmaticcoding.ca/javafx/elements/observable-lists-basics

Have a read and tell me if you think it's useful.

0 Comments
2024/11/15
19:35 UTC

4

Weird effect happening

13 Comments
2024/11/15
16:01 UTC

1

Window size not the same as content size

Hey guys, I'm observing a quite strange an annoying behavior on my Windows PC. A window size does not match the content size, it's 16px larger for some reason, as if there is some kind of invisible padding.
Here's a reproducer:

StackPane root = new StackPane();
root.setMinSize(500.0, 500.0);
Scene scene = new Scene(root);
stage.widthProperty().addListener(o -> System.out.println(stage.getWidth()));
stage.setScene(scene);
stage.show();

// Watch the console
// It should print 500.0 but it is 516.0
// Content is indeed 500.0, I can see this in ScenicView too

I say this is annoying because this makes the window not respect its min sizes, here's the follow-up to the reproducer:

stage.setMinWidth(500.0);
// Resize window
// Observe that the content's width is now 484.0

stage.setMinWidth(516.0);
// This works but I don't think it's very convenient as
// I'm not sure whether this is a OS related thing or what

What's going on exactly? Bug? Is it documented somewhere?

Edit: for some reason, the height is even worse!! It's around 40px taller, what the hell is going on

5 Comments
2024/11/15
12:26 UTC

1

JavaFX on intelliJ and scenebuilder

I'm trying to create an fxml file in the scene builder however when I save and run the program the error appears "Nov. 12, 2024 10:05:10 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" and this leads to a series of errors in the code and I can't change the java fx version because I'm using intelliJ.

Can anyone give me some help?

6 Comments
2024/11/13
01:20 UTC

4

JavaFX ignores some clicks on Menu in MenuBar and ComboBox arrows in Ubuntu

Has anyone noticed when working with JavaFX in Ubuntu that the platform doesn't respond to clicks on Menu and ComboBox arrows? You click again and again until popup with Menu/ComboBox items is shown. I see it constantly in Ubuntu 20.04

2 Comments
2024/11/11
17:46 UTC

4

How do I change the color of the top left corner in a date-picker?

https://preview.redd.it/ug4vbcjnv30e1.png?width=326&format=png&auto=webp&s=206a653d86deb4a4cfcd12b1e2bb50775e6a8d6d

.date-picker-popup  {
    -fx-background-color: -background-100;
}
.date-picker {
    -fx-background-color: -background-100; 
}

Talking about the white square. The code above doesn't work sadly (-background-100 is #121212)

3 Comments
2024/11/10
17:06 UTC

2

Error: JavaFX runtime components are missing...

Hiiii, I'm working with javaFX for a project in gitlab and I can't get it to work whatever I do, I made it work at the start but it would work in everything but the project I needed it to work in, then I made it work on the project but now I need to work on a different branch and I can't get it to work again. It always gives off this error: ERROR: javaFX runtime components are missing, and are required to run this application I've tried a lot of the stuff I've seen online but they aren't working or I'm not doing something right. Does anyone know how to help 🙏🏻😭

2 Comments
2024/11/09
20:24 UTC

2

column setOnEditStart does not get trigger sometimes, why?

I'm working with two columns, let's call them Column A and Column B. When I finish editing Column A, I want to press Tab to jump to Column B, and I expect Column B's setOnEditStart to be triggered. However, it only triggers sometimes. Why is that?

First, I define Column B's setOnEditCommit:

javaCopy codecolumnB.setOnEditStart((CellEditEvent<tableEntry, String> event) -> { 
    // Does not get triggered sometimes.
});

Then, I set up Column A with a custom CellFactory to handle the Tab key press:

javaCopy codecolumnA.setCellFactory(col -> { 
    TextFieldTableCell<tableEntry, String> cell = new TextFieldTableCell<>(new DefaultStringConverter());
    
    cell.addEventFilter(KeyEvent.KEY_PRESSED, event -> { 
        if (event.getCode() == KeyCode.TAB) { 
            event.consume(); 
            
            Platform.runLater(() -> { 
                int rowIndex = cell.getIndex(); 
                cell.requestFocus();
                
                // Allow the UI thread to process any remaining events
                Platform.runLater(() -> { 
                    int currentIndex = cell.getTableView().getColumns().indexOf(cell.getTableColumn()); 
                    int nextIndex = currentIndex + 2; // Assuming this moves focus to *Column B*
                    logService.info("Next index is: " + nextIndex, true); 
                    
                    cell.getTableView().edit(rowIndex, cell.getTableView().getColumns().get(nextIndex)); 
                }); 
            }); 
        } 
    }); 
    
    return cell; 
});

---

This setup sometimes skips triggering Column B's `setOnEditStart`. Does anyone know why this might be happening? Is there a better approach to ensure `setOnEditStart` always triggers when moving to the next column?

8 Comments
2024/11/08
04:36 UTC

3

javafx.fxml.LoadException: ClassNotFoundException for FXML Controller in JavaFX Application

Hi everyone,

I’m encountering a javafx.fxml.LoadException when trying to load my FXML file. Here’s the relevant error message:

javafx.fxml.LoadException:
/home/dodo/Dokumenty/studia/Projekt_zespolowy/Service-Point-Desktop-App/target/classes/Fxml/User/MiniOrderLook.fxml
Caused by: java.lang.ClassNotFoundException: com.servicepoint.app.Controllers$User$MiniOrderLookController

Here are the details of my setup:

  • Java Version: 17.0.6
  • JavaFX Version: 21.0.4

FXML Snippet:

<Pane fx:controller="com.servicepoint.app.Controllers.User.MiniOrderLookController" ... >
...
</Pane>

Controller Snippet:

package com.servicepoint.app.Controllers.User;

import javafx.fxml.FXML;
import javafx.scene.text.Text;

public class MiniOrderLookController {
    u/FXML
    private Text titleText; 
    // Metoda do ustawiania danych
    public void setSomeData(String data) {
        titleText.setText(data); 
    }
}

Controller used in:

private void initializeMiniOrderLookControllers() {
    int numberOfTiles = 1;
    for (int i = 0; i < numberOfTiles; i++) {
        try {
            FXMLLoader loader = new FXMLLoader(getClass().getResource("/Fxml/User/MiniOrderLook.fxml"));
            Pane miniOrderLook = loader.load();

            MiniOrderLookController miniOrderLookController = loader.getController();private void initializeMiniOrderLookControllers() {
    int numberOfTiles = 1; // Przykładowa liczba kafelków

    for (int i = 0; i < numberOfTiles; i++) {
        try {
            FXMLLoader loader = new FXMLLoader(getClass().getResource("/Fxml/User/MiniOrderLook.fxml"));
            Pane miniOrderLook = loader.load();

            MiniOrderLookController miniOrderLookController = loader.getController();

Panels should appear in the empty white field.Panels should appear in the empty white field:

https://preview.redd.it/ju1r94bdtvyd1.png?width=878&format=png&auto=webp&s=c807f3cbb11aa4f42b69517c8338787d718be75a

What I’ve Tried:

  • Verified that the package structure is correct.
  • Cleaned and rebuilt the project.
  • Checked the resource path for the FXML file.

Any help would be greatly appreciated!

14 Comments
2024/11/04
11:13 UTC

2

Exception in Application start method

Hello everyone, im trying to do an application based on a youtube playlist. i have done everything the guy does in his videos and i get those errors when i try to run the program.

in the main method if i remove the launch(args); the errors dont show but the program is running and not showing

at this point idk what else to fix

2 Comments
2024/11/03
16:56 UTC

1

No connection with je2java.exe

Hi Reddit,

So I have installed Java Editor for school on my laptop. But it does not have a connection to the je2java.exe file. It says: No connection with C:\ProgramFiles\JavaEditor\je2java.exe , but the je2java application is in the right map and location. So what do I need to do to make my JavaFX applications run?

0 Comments
2024/11/01
14:22 UTC

2

Qt/QML Professional Exploring JavaFX/Gluon Mobile Seeking Advice

Hey, everyone, thanks for your input. I work professionally in C++ with Qt (using QML for the GUIs) in both desktop and mobile applications built with Qt 6.8.0 (the newest LTS). I'd like to make a clone of one of the applications using JavaFX, but I know nothing about the audio libraries available for implementing robust panning, adequate reverb, changing pitch, changing tempo, etc.. I'm not an audio programmer, I just happen to work on audio applications, so writing all of that myself with adequate performance is highly unlikely, especially in a timely fashion.

I'm also a little confused about JavaFX's pulse processing and what, exactly, prevents render cycles in JavaFX that won't prevent them in Qt, especially since JavaFX seems to perform similarly to a QML GUI in most cases. I'd love some information from the community that really knows this tool, since I've read a book and built toy applications for Android, iOS, Linux, macOS, and Windows, not anything substantial.

2 Comments
2024/10/31
20:12 UTC

4

How to Use Firebase Authentication in JavaFX for Desktop Applications

Hi everyone,

I’m currently working on a JavaFX desktop application and want to integrate Firebase Authentication to manage user accounts. I chose Firebase because it's easy to use and will also help me transition to developing a native Android app in the future.

However, I'm feeling a bit lost on how to implement Firebase Authentication in my JavaFX app. Here are a few questions I have:

  1. Setup: What are the necessary steps to set up Firebase Authentication in a JavaFX project?
  2. Code Examples: Are there any code snippets or examples that show how to authenticate users (sign up, sign in, sign out)?
  3. Resources: Does anyone have recommendations for YouTube playlists or other resources that can guide me through this process?

I appreciate any help or guidance you can provide!

Thank you!

2 Comments
2024/10/31
07:52 UTC

5

JavaFx window doesn't cover fullscreen

I'm not sure why I have this problem.

I just wanna know if anybody else has ever experienced something similar.

When I want to set my JavaFx window to fullscreen using the little "maximise" icon on top -> it normally goes to full screen (as it should).

However when I align the window to be somewhat directly in the middle of the two Screens (actuall desktop screens) it doesn't go up in scale.

I'm using Windows 11 with Openjdk 22 and JavaFx 17.0.2

2 Comments
2024/10/30
12:10 UTC

8

Whats the best way to change scenes in javafx?

I'm new to javafx (i'm using scenebuilder aswell) and i'm trying to build a simple expense tracker project. My question is, what's the best practice regarding switching scenes in javafx ?

https://preview.redd.it/1uy8wtb82wwd1.png?width=1351&format=png&auto=webp&s=94c6f5187602833d21c9757b5f1c75b26a399fd7

For example, the navbar of the app will be something like this and i intend to show different interfaces when the savings button is clicked or when the expenses button is clicked. From what i've seen online there are a couple of ways to do this :

  1. have two fxml files one for savings and one for expenses where you just switch scenes each time.

  2. have one fxml file with both interfaces, and when each button is clicked set visible the one interface and set invisible the other one.

  3. have one common fxml file for the navbar, and then add to the same file either an fxml having the savings interface or the expenses interface

Are there any other ways? Which is the best practice? Which is the most "viable" for a beginner?

19 Comments
2024/10/25
11:40 UTC

2

How to add Textures to FXGL?

1 Comment
2024/10/22
20:18 UTC

Back To Top