We have a Java application that used Swing, but we are migrating it to JavaFX. Therefore, we wrap the old Swing code into SwingNode
s and replace them step-by-step.
Before migrating, the Swing application used com.sun.java.swing.plaf.gtk.GTKLookAndFeel
as look-and-feel (default on Ubuntu). We used following code to set it (if available):
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if (info.getClassName().equals("com.sun.java.swing.plaf.gtk.GTKLookAndFeel")) {
UIManager.setLookAndFeel(info.getClassName());
}
}
This worked fine. Yet, after switching to JavaFX, the call to UIManager.setLookAndFeel()
freezes the application, and nothing happens. The manual setting of the look-and-feel is needed since we want to still style the Swing components that have not been migrated to JavaFX based on the GTKLookAndFeel
.
Further info: This only does not work with com.sun.java.swing.plaf.gtk.GTKLookAndFeel
, since it works when using javax.swing.plaf.metal.MetalLookAndFeel
, javax.swing.plaf.nimbus.NimbusLookAndFeel
or com.sun.java.swing.plaf.motif.MotifLookAndFeel
.
What can we do to make it work with GTKLookAndFeel
to style our Swing components in the SwingNode
s?
kill -3
command. One of the stack traces should indicate where setLookAndFeel is stuck. – Greasewoodcom.sun.java.swing.plaf.gtk.GTKEngine.native_get_gtk_setting(Native Method)
... Tested this with a thread dump and the eclipse debugger. – RaeraeannJTabbedPane
that gets set as a SwingNode's content in our view's controller'sinitialize
method, and we are currently investigating if it has something to do with that. It seems that the constructor call ofJTabbedPane
hangs the application. I will try to create a minimal example. – Raeraeannjstack -l
, it will show you if there is a deadlock. You guys mentioned that the thread was stuck innative_get_gtk_setting
, and that this method is synchronized, so maybe another thread is holding the lock. And that might happen because Swing and JavaFX each have their own thread... – AshjianUbuntu 16.04 LTS
install. – Raeraeanndpkg -s libgtk2.0-0|grep '^Version'
returnsVersion: 2.24.30-1ubuntu1.16.04.2
anddpkg -s libgtk-3-0|grep '^Version'
returnsVersion: 3.18.9-1ubuntu3.3
– RaeraeannGKT
deadlocking. These posts bugs.eclipse.org/bugs/show_bug.cgi?id=341538 and bugs.eclipse.org/bugs/show_bug.cgi?id=341799 helped me solve the issue by callinggdk_threads_leave()
before Swing/AWT dispatches the threads. – Vizzabreak
statement in your if ? – Aindrea