Question: quickest way of testing UI changes in JFX
Cormac Redmond
credmond at certak.com
Mon Dec 22 01:21:27 UTC 2025
Hi,
Thank you both John and Michael for the detailed mails. Yeah, I've dabbled
with both approaches (building SDK each vs. copying classes to a separate
project).
I was curious if there was some *third* way to run from the JFX project
itself without needing to actually build the SDK each time (or copying
classes).
It sounds like there isn't, otherwise you'd have mentioned it, so that's
the answer... I was mainly wondering if I was missing a more streamlined
way.
Thanks again.
Kind Regards,
Cormac
On Mon, 22 Dec 2025 at 00:32, John Hendrikx <john.hendrikx at gmail.com> wrote:
> What I often do when I want to test changes to FX internals is to not
> build FX at all, but instead just copy the classes I need to change into my
> project and leaving them in the internal package.
>
> So for example, I want to change something in Window, I just copy the
> class into my mini project:
>
> - src/main/java/javafx/stage/Window.java
> - src/main/java/app/MyApp.java
> - pom.xml --> depends on JavaFX 25 maven artifacts or say 26-ea+18
>
> No `module-info.java`
>
> When you run this, you may get an error that you can't start your
> application like this. You can work around that with a mini launcher class:
>
> public void main(String... args) {
> Application.launch(MyApp.class, args);
> }
>
> Now it starts without whining about module restrictions.
>
> The Window class here can be modified in most ways, but you can't remove
> methods that may be overridden. You can remove "sealed" and "permits" if
> you're copying a class that has those (like Node).
>
> A screenshot of a project that I used to debug several issues over the
> past few days:
>
>
> --John
>
>
> On 21/12/2025 22:27, Cormac Redmond wrote:
>
> Hi,
>
> Are there any tricks to quickly spinning up a visible application (from a
> test or otherwise), from within the JFX project, in order to see your
> changes?
>
> Obviously building the SDK and "using" it in an application is time
> consuming.
>
> I've seen this in build.gradle, where I assume StubToolKit automatically
> runs a sort of headless Application for tests without tests needing to
> manage it. Can it be replaced with anything?
>
> test {
> def cssDir = file("${TEST_SDK_DIR}/shims/${moduleName}/javafx")
> jvmArgs enableNativeGraphics
> jvmArgs "-Djavafx.toolkit=test.com.sun.javafx.pgstub.StubToolkit",
> "-DCSS_META_DATA_TEST_DIR=$cssDir"
> }
>
> I know some people copy UI classes into their project (keeping the same
> package name as the real JFX control class, where it will take precedence),
> and develop/test it *there*. If that's the best solution to date, that's
> fine.
>
> In general, any other quick development tips (in the realm of quickly
> visually testing your changes) would be appreciated...
>
> Thanks in advance.
>
>
>
> Kind Regards,
> Cormac
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20251222/f0f08f78/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 3pl5VVBhrLuSerB9.png
Type: image/png
Size: 95058 bytes
Desc: not available
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20251222/f0f08f78/3pl5VVBhrLuSerB9-0001.png>
More information about the openjfx-dev
mailing list