-
Bug
-
Resolution: Fixed
-
P3
-
8u40, 9
-
x86_64
-
windows_7
FULL PRODUCT VERSION :
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) Client VM (build 25.45-b02, mixed mode)
java 8u20, 8u31, 8u40
ADDITIONAL OS VERSION INFORMATION :
windows 7 6.1.7601
windows 8 6.3.9600
A DESCRIPTION OF THE PROBLEM :
There are various nullpointerexception when using jfxpanel. Exceptions occur when setting up jfxpanel with fx components or when closing parent frame.
Might be threading/synchronization issue since jfxpanel has to handle swing and fx.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run code sample.
Click the FX button.
New internal frame opens.
Console prints exception.
Close internal frame.
Console prints exception.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No exception
ACTUAL -
exception when adding jfxpanel and closing jfxpanel depending on java version and os
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Occurs when click button to launch internal frame
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javafx.embed.swing.JFXPanel$HostContainer.lambda$setEmbeddedStage$52(JFXPanel.java:915)
at javafx.embed.swing.JFXPanel$HostContainer$$Lambda$93/32395568.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Occurs when closing internal frame
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javafx.embed.swing.JFXPanel.getInputMethodRequests(JFXPanel.java:858)
at sun.awt.im.InputMethodAdapter.haveActiveClient(InputMethodAdapter.java:61)
at sun.awt.windows.WInputMethod.deactivate(WInputMethod.java:340)
at sun.awt.im.InputContext.deactivateInputMethod(InputContext.java:492)
at sun.awt.im.InputContext.focusLost(InputContext.java:458)
at sun.awt.im.InputContext.removeNotify(InputContext.java:627)
at java.awt.Component.removeNotify(Component.java:7010)
at java.awt.Container.removeNotify(Container.java:2820)
at javax.swing.JComponent.removeNotify(JComponent.java:4767)
at javafx.embed.swing.JFXPanel.removeNotify(JFXPanel.java:880)
at java.awt.Container.removeNotify(Container.java:2804)
at javax.swing.JComponent.removeNotify(JComponent.java:4767)
at java.awt.Container.removeNotify(Container.java:2804)
at javax.swing.JComponent.removeNotify(JComponent.java:4767)
at java.awt.Container.removeNotify(Container.java:2804)
at javax.swing.JComponent.removeNotify(JComponent.java:4767)
at javax.swing.JRootPane.removeNotify(JRootPane.java:765)
at java.awt.Container.removeNotify(Container.java:2804)
at javax.swing.JComponent.removeNotify(JComponent.java:4767)
at java.awt.Container.remove(Container.java:1204)
at javax.swing.JLayeredPane.remove(JLayeredPane.java:246)
at javax.swing.JDesktopPane.remove(JDesktopPane.java:505)
at java.awt.Container.remove(Container.java:1262)
at javax.swing.JDesktopPane.remove(JDesktopPane.java:436)
at javax.swing.DefaultDesktopManager.closeFrame(DefaultDesktopManager.java:100)
at javax.swing.plaf.basic.BasicInternalFrameUI.closeFrame(BasicInternalFrameUI.java:547)
at javax.swing.plaf.basic.BasicInternalFrameUI$Handler.propertyChange(BasicInternalFrameUI.java:1410)
at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:335)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:327)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:263)
at java.awt.Component.firePropertyChange(Component.java:8422)
at javax.swing.JInternalFrame.doDefaultCloseAction(JInternalFrame.java:1634)
at javax.swing.plaf.basic.BasicInternalFrameTitlePane$CloseAction.actionPerformed(BasicInternalFrameTitlePane.java:619)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
at java.awt.Component.processMouseEvent(Component.java:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.beans.PropertyVetoException;
import javax.swing.*;
import javafx.application.*;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
public class SwingEmbedFX2 {
protected static JFXPanel fxPanel;
protected static JDesktopPane desktopPane;
static void packInternalFrame(JInternalFrame iframe) {
try {
iframe.pack();
iframe.setIcon(true);
iframe.setMaximum(true);
iframe.moveToFront();
iframe.setVisible(true);
// From setMaximum method call
} catch (PropertyVetoException ex) {
System.out.println(ex);
ex.printStackTrace();
}
}
static void launchFXFrame() {
JInternalFrame iframe = new JInternalFrame(
"FX Embedded", true, true, true);
iframe.setLayout(new BorderLayout());
desktopPane.add(iframe);
try {
iframe.setMaximum(true);
// From setMaximum method call
} catch (PropertyVetoException ex) {
System.out.println(ex);
ex.printStackTrace();
}
fxPanel = new JFXPanel();
iframe.add(fxPanel, BorderLayout.CENTER);
Platform.runLater(() -> createScene());
packInternalFrame(iframe);
}
public static void runTest() {
final JFrame f = new JFrame();
f.setLayout(new BorderLayout());
f.setSize(new Dimension(500, 500));
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
desktopPane = new JDesktopPane();
f.getContentPane().add(BorderLayout.CENTER,
new JScrollPane(desktopPane));
JInternalFrame iframe = new JInternalFrame();
iframe.setResizable(true);
JButton btn = new JButton("FX");
btn.addActionListener(a -> launchFXFrame());
iframe.add(btn);
desktopPane.add(iframe);
iframe.pack();
desktopPane.validate();
iframe.setVisible(true);
desktopPane.setVisible(true);
f.setVisible(true);
}
public static void createScene() {
StackPane fxRoot = new StackPane();
fxPanel.setScene(new Scene(fxRoot));
BorderPane bp = new BorderPane();
fxRoot.getChildren().addAll(bp);
bp.setCenter(new Label("FX Label"));
}
public static void main(String [] args) {
try {
SwingUtilities.invokeAndWait(() -> runTest());
} catch (Exception ex) {
System.out.println(ex);
ex.printStackTrace();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Moving packInternalFrame before creating scene helps depending on java version and possibly operating system.
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) Client VM (build 25.45-b02, mixed mode)
java 8u20, 8u31, 8u40
ADDITIONAL OS VERSION INFORMATION :
windows 7 6.1.7601
windows 8 6.3.9600
A DESCRIPTION OF THE PROBLEM :
There are various nullpointerexception when using jfxpanel. Exceptions occur when setting up jfxpanel with fx components or when closing parent frame.
Might be threading/synchronization issue since jfxpanel has to handle swing and fx.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run code sample.
Click the FX button.
New internal frame opens.
Console prints exception.
Close internal frame.
Console prints exception.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No exception
ACTUAL -
exception when adding jfxpanel and closing jfxpanel depending on java version and os
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Occurs when click button to launch internal frame
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javafx.embed.swing.JFXPanel$HostContainer.lambda$setEmbeddedStage$52(JFXPanel.java:915)
at javafx.embed.swing.JFXPanel$HostContainer$$Lambda$93/32395568.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Occurs when closing internal frame
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javafx.embed.swing.JFXPanel.getInputMethodRequests(JFXPanel.java:858)
at sun.awt.im.InputMethodAdapter.haveActiveClient(InputMethodAdapter.java:61)
at sun.awt.windows.WInputMethod.deactivate(WInputMethod.java:340)
at sun.awt.im.InputContext.deactivateInputMethod(InputContext.java:492)
at sun.awt.im.InputContext.focusLost(InputContext.java:458)
at sun.awt.im.InputContext.removeNotify(InputContext.java:627)
at java.awt.Component.removeNotify(Component.java:7010)
at java.awt.Container.removeNotify(Container.java:2820)
at javax.swing.JComponent.removeNotify(JComponent.java:4767)
at javafx.embed.swing.JFXPanel.removeNotify(JFXPanel.java:880)
at java.awt.Container.removeNotify(Container.java:2804)
at javax.swing.JComponent.removeNotify(JComponent.java:4767)
at java.awt.Container.removeNotify(Container.java:2804)
at javax.swing.JComponent.removeNotify(JComponent.java:4767)
at java.awt.Container.removeNotify(Container.java:2804)
at javax.swing.JComponent.removeNotify(JComponent.java:4767)
at javax.swing.JRootPane.removeNotify(JRootPane.java:765)
at java.awt.Container.removeNotify(Container.java:2804)
at javax.swing.JComponent.removeNotify(JComponent.java:4767)
at java.awt.Container.remove(Container.java:1204)
at javax.swing.JLayeredPane.remove(JLayeredPane.java:246)
at javax.swing.JDesktopPane.remove(JDesktopPane.java:505)
at java.awt.Container.remove(Container.java:1262)
at javax.swing.JDesktopPane.remove(JDesktopPane.java:436)
at javax.swing.DefaultDesktopManager.closeFrame(DefaultDesktopManager.java:100)
at javax.swing.plaf.basic.BasicInternalFrameUI.closeFrame(BasicInternalFrameUI.java:547)
at javax.swing.plaf.basic.BasicInternalFrameUI$Handler.propertyChange(BasicInternalFrameUI.java:1410)
at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:335)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:327)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:263)
at java.awt.Component.firePropertyChange(Component.java:8422)
at javax.swing.JInternalFrame.doDefaultCloseAction(JInternalFrame.java:1634)
at javax.swing.plaf.basic.BasicInternalFrameTitlePane$CloseAction.actionPerformed(BasicInternalFrameTitlePane.java:619)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
at java.awt.Component.processMouseEvent(Component.java:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.beans.PropertyVetoException;
import javax.swing.*;
import javafx.application.*;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
public class SwingEmbedFX2 {
protected static JFXPanel fxPanel;
protected static JDesktopPane desktopPane;
static void packInternalFrame(JInternalFrame iframe) {
try {
iframe.pack();
iframe.setIcon(true);
iframe.setMaximum(true);
iframe.moveToFront();
iframe.setVisible(true);
// From setMaximum method call
} catch (PropertyVetoException ex) {
System.out.println(ex);
ex.printStackTrace();
}
}
static void launchFXFrame() {
JInternalFrame iframe = new JInternalFrame(
"FX Embedded", true, true, true);
iframe.setLayout(new BorderLayout());
desktopPane.add(iframe);
try {
iframe.setMaximum(true);
// From setMaximum method call
} catch (PropertyVetoException ex) {
System.out.println(ex);
ex.printStackTrace();
}
fxPanel = new JFXPanel();
iframe.add(fxPanel, BorderLayout.CENTER);
Platform.runLater(() -> createScene());
packInternalFrame(iframe);
}
public static void runTest() {
final JFrame f = new JFrame();
f.setLayout(new BorderLayout());
f.setSize(new Dimension(500, 500));
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
desktopPane = new JDesktopPane();
f.getContentPane().add(BorderLayout.CENTER,
new JScrollPane(desktopPane));
JInternalFrame iframe = new JInternalFrame();
iframe.setResizable(true);
JButton btn = new JButton("FX");
btn.addActionListener(a -> launchFXFrame());
iframe.add(btn);
desktopPane.add(iframe);
iframe.pack();
desktopPane.validate();
iframe.setVisible(true);
desktopPane.setVisible(true);
f.setVisible(true);
}
public static void createScene() {
StackPane fxRoot = new StackPane();
fxPanel.setScene(new Scene(fxRoot));
BorderPane bp = new BorderPane();
fxRoot.getChildren().addAll(bp);
bp.setCenter(new Label("FX Label"));
}
public static void main(String [] args) {
try {
SwingUtilities.invokeAndWait(() -> runTest());
} catch (Exception ex) {
System.out.println(ex);
ex.printStackTrace();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Moving packInternalFrame before creating scene helps depending on java version and possibly operating system.
- duplicates
-
JDK-8089371 JFXPanel close() may cause a NPE
-
- Closed
-