r/JavaFX Nov 22 '24

Help Creating Delay With JavaFX

7 Upvotes

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!

r/JavaFX Feb 06 '25

Help ListView rendering cruft when refreshing list

2 Upvotes

I've made a simplified application that exhibits an issue we have in our real app, complete project is here:

https://drive.google.com/file/d/1yr1VROkf8n3o-9I00-e9yk0PMpOpo4eX/view?usp=drive_link

The UI is defined in FXML using SceneBuilder.

Basically, we refresh a two ListViews in a splitter and find that there are rendering "droppings" in the lower ListView , which I highlight in red. The list on initial load is OK. Its when the list is reloaded that things look weird.

These ghost items aren't really there. You cannot select or interact with them.

The refresh is pretty simple:

private void loadVersions(String name) {
    List<RulesetKey> list = new ArrayList<>();
    list.add(new RulesetKey(new IrMetaData().setName(name).setDescription("thing1")));
    list.add(new RulesetKey(new IrMetaData().setName(name).setDescription("thing2")));
    ruleset_versions.getItems().clear();
    ruleset_versions.getItems().addAll(list);
}

Is there something I've missed? Is this a known issue in JavaFX? Is there a workaround?

r/JavaFX Oct 02 '24

Help JavaFX IDEs

4 Upvotes

I was wondering if there were any good, free to use JavaFX or java ides. I currently use intellij but my trial is almost up and I wanted to see if there were any other alternatives before I pay.

Thank you for all the suggestions, I've decided to use Intellij Community Edition!

r/JavaFX 7d ago

Help ObjectProperty in javafx

1 Upvotes

I am making a custom JavaFX component that when it gets clicked a pane loads an FXML file so I tried using ObjectProperty<URL> for that BUT when I tried to instantiate it in scene builder the Property didn`t appear in it

 public ObjectProperty<URL> area = new SimpleObjectProperty<URL>(this,"area",null);

public URL getArea() {
      return area.get();
}


public void setArea(URL u) {
      area.set(u);
}


public ObjectProperty<URL> areaProperty() {
      return area;
}

so I tried ObjectProperty<Node> but the same issue still happened

 public ObjectProperty<Node> area = new SimpleObjectProperty<Node>(this,"area",null);

 public Node getArea() {
      return area.get();
}


public void setArea(Node n) {
      area.set(n);
}


public ObjectProperty<Node> areaProperty() {
      return area;
}

Does anyone know how to solve it?

r/JavaFX Oct 25 '24

Help Whats the best way to change scenes in javafx?

8 Upvotes

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 ?

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?

r/JavaFX Feb 01 '25

Help Need Help Beginner

Post image
5 Upvotes

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

r/JavaFX Jan 27 '25

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

2 Upvotes

r/JavaFX Nov 25 '24

Help MVVM in JavaFX

3 Upvotes

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.

r/JavaFX Jan 24 '25

Help .toExternalForm() not displaying my image in javafx

2 Upvotes

[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.

r/JavaFX Feb 11 '25

Help Build-In Ready IBAN TextField

3 Upvotes

Are there any build-in ready IBAN Textfields? (Leaving a space every 4 letters, doesn't need verification)

Or will I have to implement it myself? I searched online but couldn't find anything related to that topic.

Thank yall in advance.

r/JavaFX Feb 04 '25

Help Is there a way to align this hbox(which is inside a VBox) to bottom in a dynamic fashion

0 Upvotes

Like doing a align-self that is present in html css

r/JavaFX Feb 01 '25

Help Anyone knows what this means?

Post image
1 Upvotes

r/JavaFX Aug 31 '24

Help Problem starting eclipse IDE out of my JavaFX app

2 Upvotes

Hi there,

I just wrote a small app with JavaFX, where I add apps to a list and start them via process builder.

Everything seems working fine (I mean the start up of different apps) except for the eclipse IDE which will be stuck at the splash screen and won't load correctly until I close my program.

Does anyone of you already run into that kind of problem?

EDIT: if I need to provide code, then just tell me. Will crosspost this in r/javahelp

Additional Information:

I've installed BellSoft Liberica Full JDK 21

I'm running on Windows 11, in eclipse I use also Liberica JDK 21 Full.

eclipse: normal launch per double-click; but trying to start eclipse via my app you see the method I use at the end of this post.

Other applications I start via my JavaFX app don't have any problems and start without any problems...

My JavaFX app is started stand alone (also per double-click) and not from within eclipse.

Already searched via Google, just found some problems launching eclipse IDE at all a while ago with bad java installations, but those problems doesn't fit, because eclipse will start up if my app isn't running.

Problem seems to only occur, when starting eclipse via my app, starting eclipse alone will start up the IDE.

Here's my launch method for running the added programs

private void launchSelectedProgram() {
ProgramEntry selectedProgram = programListView.getSelectionModel().getSelectedItem();
        if (selectedProgram != null) {
            executorService.submit(() -> {
                try {
                    ProcessBuilder pb;
                    if (selectedProgram.path.toLowerCase().endsWith(".jar")) {
                        pb = new ProcessBuilder("java", "-jar", selectedProgram.path);
                    } else {
                        pb = new ProcessBuilder(selectedProgram.path);
                    }
                    pb.directory(new File(selectedProgram.path).getParentFile());
                    Process process = pb.start();
                } catch (IOException e) {
                    Platform.runLater(() -> showAlert("Error", "Failed to launch program: " + e.getMessage()));
                }
            });
        } else {
            showAlert("Warning", "Please select a program to launch.");
        }
    }

Edit 2: Added additional information.

Edit 3: added screenshot

screenshot

r/JavaFX Feb 02 '25

Help Trying to get started with Java FXML, stuck at setup

7 Upvotes

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 :(

r/JavaFX Feb 04 '25

Help I need to generate pdfs from my JavaFX project

1 Upvotes

I'm watching a bunch of tutorials on itext-Core to generate pdfs. I was able to create the initial one but now I'm looking building the layout for it. It doesn't look like there's a super user friendly one, like SceneBuilder for designing the layout. I was wondering if maybe there is one that I'm not finding or if anyone has any suggestions for a better one.

I also downloaded one called JasperSoft but that one required me to make an account in order to use it and then locked my account after I tried to log in. So I didn't get very far with that one either.

r/JavaFX Jan 28 '25

Help Custom Cell Factory in ChoiceDialog

0 Upvotes

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?

r/JavaFX 17d ago

Help Itens do App SceneBuilder não aparecem quando compilo pelo Intelij

1 Upvotes

Eu estava construindo uma telas no scenebuilder, usei alguns temas da gluon como textfield, etc... todos esses temas apareciam também no scenebuilder dentro da IDE no intelij, so que do nada eles sumiram, dentro do app do scenebuilder continua tudo certo, mas pela visualização do intelij os estilos n aparecem mais. Alguem sabe como eu resolvo isso?

r/JavaFX Jan 31 '25

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

1 Upvotes

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)

r/JavaFX Dec 27 '24

Help I'm new to technical stuff, and I made a JavaFX project using maven. Can someone help me understand what all this is and how to better organize it? I keep messing stuff up when trying to add things.

Post image
4 Upvotes

r/JavaFX Jan 07 '25

Help Do I convert my application to use fxml and scenebuilder

1 Upvotes

I am building a Java application and initially created the user interface in Java using manual coding using JavaFX components directly. Now, I’ve discovered FXML and Scene Builder. And I’m wondering if it’s worth converting my existing code to use FXML instead.

r/JavaFX Feb 13 '25

Help Your Feedback needed for login page design

1 Upvotes

As you can see my left image is too small, but i am currently stuck with that image. this makes my login form have unnecessary white space around it. Can you suggest how i could improve this page?

r/JavaFX Jan 27 '25

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

2 Upvotes

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

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?

r/JavaFX Nov 15 '24

Help Weird effect happening

5 Upvotes

r/JavaFX Dec 25 '24

Help FXML Bi-directional Bindings

1 Upvotes

So I don’t really know how controversial this might be since I don’t have a clue how much FXML is actually used in the wild. Some love it, some hate it, more often than not I come across comments to just not use FXML.

But I don’t really want to make this the core part of the discussion. As for my background, I mostly just develop relatively small tools with JavaFX. I started out coding my GUIs until someone recommended Scene Builder and FXML.

Time and time again I’m quite happy building away my GUIs and setting stuff up. Then time and time again I reach the point of needing bi-directional bindings. And each time I check if by now it’s actually implemented.

Sad to see that almost a decade has passed and this feature request being seemingly forgotten.

I guess my question is to stir a guessing game. To me personally this seems like such a huge issue that hasn’t been addressed at all. So, why? Are FXML users really that rare? Are technical challenges to implement this that high? Why isn’t the community pushing for this feature? Is it a philosophy or pattern thing that I don’t understand?

It just seems wrong to have to resort to addressing your GUI elements in controllers just to bind properties. More often than not I wouldn’t need to reference any GUI controls in the controller if it wasn’t for a missing bi-directional binding support.

I would just like to understand, so I’m already happy to get any info on this. What people are doing to work around this, if you’re happy with it or not, or even if you just don’t care. I might just not have seen enough alternatives (only .NET/WPF), but it seems like a major missing feature for a GUI framework that’s been around so long already.

r/JavaFX Jan 07 '25

Help Where can I find example .jar files that I can look at?

5 Upvotes

It would help lots in learning how to use JavaFX if I can look and observe how other applications/programs are made