package interop; import java.awt.BorderLayout; import java.awt.Dimension; import javafx.application.Platform; import javafx.embed.swing.JFXPanel; import javafx.scene.Group; import javafx.scene.Scene; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.UIManager.LookAndFeelInfo; /** * Issue with Nimbus Look and Feel, JTabbedPane and JFXPanel: * * If more then one tab in JTabbedPane contains JFXPanel, tab titles * starts blinking when mouse slowly moving over it. */ public class BlinkingTabs implements Runnable { @Override public void run() { JFrame frame = new JFrame("TabbedPaneDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setPreferredSize(new Dimension(900, 600)); JTabbedPane tabbedpane = new JTabbedPane(); tabbedpane.addTab("1 1", makeJFXPanel()); tabbedpane.addTab("1 1", new JPanel()); tabbedpane.addTab("2 2", makeJFXPanel()); frame.add(tabbedpane, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); } public JFXPanel makeJFXPanel() { final JFXPanel jfxpanel = new JFXPanel(); Platform.runLater(new Runnable() { @Override public void run() { jfxpanel.setScene(new Scene(new Group())); } }); return jfxpanel; } public static void main(String[] args) { try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { System.err.println("Nimbus is not available"); } SwingUtilities.invokeLater(new BlinkingTabs()); } }