On Sat, 5 Sep 2026 11:48:23 GMT, Marius Hanl <[email protected]> wrote:

> This PR fixes a Warning I always get when JavaFX and Swing are both mixed 
> together in an application.
> The error: `XSetErrorHandler() called with a GDK error trap pushed. Don't do 
> that.`
> 
> The problem is that we call `gdk_error_trap_push`, which will result in this 
> warning when there was already an `XSetErrorHandler` set previously, in this 
> case Swing.
> 
> See also:
> - 
> https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gdk/x11/gdkmain-x11.c#L313
> 
> Checking the Swing code, we just call `XSetErrorHandler` and not 
> `gdk_error_trap_push`. See also:
> 
> - 
> [XlibWrapper](https://github.com/openjdk/jdk/blob/master/src/java.desktop/unix/native/libawt_xawt/xawt/XlibWrapper.c#L1328)
> - 
> [gtk3_interface](https://github.com/openjdk/jdk/blob/master/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c#L679)
> 
> `gdk_error_trap_push` will call `XSetErrorHandler`, so we might as well do 
> that directly.
> I checked the code in `gdk_error_trap_push` I do not see any problems with 
> this new approach.
> 
> cc @tsayao, a review is appreciated.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

I have encountered this before when using both AWT/Swing and JavaFX together. 
Is that specific to Swing or also happens when you initialize AWT before 
JavaFX? My app does this, but for some reason, I don't see the message anymore, 
even though I remember seeing it some time ago.

I can test this PR, is there any premade test or app in the jfx repo that 
reproduces this? Or do you need to create your own small application?

-------------

PR Comment: https://git.openjdk.org/jfx/pull/2296#issuecomment-5809012188

Reply via email to