-
Bug
-
Resolution: Unresolved
-
P4
-
8u92
-
x86_64
-
windows_7
FULL PRODUCT VERSION :
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
I used class javafx.embed.swt.FXCanvas to embed JavaFX UI in a SWT application. The JavaFX content also creates JavaFX context menus. If such a context menu is displayed and I click on any SWT widget the context menu does not disappear as expected.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Right click on the JavaFX button in the sample code to let a context menu appear. Click on the SWT button. Sometimes you have to do that twice to reproduce the issue.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The context menu should disappear.
ACTUAL -
The context menu will continue displaying.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javafx.embed.swt.FXCanvas;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class JavaFxInSwtContextBug {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new RowLayout());
org.eclipse.swt.widgets.Button swtButton = new org.eclipse.swt.widgets.Button(shell, SWT.PUSH);
swtButton.setText("SWT Button");
FXCanvas fxCanvas = new FXCanvas(shell, SWT.NONE) {
@Override
public Point computeSize(int wHint, int hHint, boolean changed) {
getScene().getWindow().sizeToScene();
int width = (int) getScene().getWidth();
int height = (int) getScene().getHeight();
return new Point(width, height);
}
};
Button jfxButton = new Button("JFX Button");
jfxButton.setId("ipad-dark-grey");
jfxButton.setContextMenu(new ContextMenu(new MenuItem("Test 1"), new MenuItem("Test 2")));
fxCanvas.setScene(new Scene(new Group(jfxButton)));
swtButton.addListener(SWT.Selection, event -> {
jfxButton.setText("JFX Button: Hello from SWT");
shell.layout();
});
jfxButton.setOnAction(event -> {
swtButton.setText("SWT Button: Hello from JFX");
shell.layout();
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use SWT context menus instead.
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
I used class javafx.embed.swt.FXCanvas to embed JavaFX UI in a SWT application. The JavaFX content also creates JavaFX context menus. If such a context menu is displayed and I click on any SWT widget the context menu does not disappear as expected.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Right click on the JavaFX button in the sample code to let a context menu appear. Click on the SWT button. Sometimes you have to do that twice to reproduce the issue.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The context menu should disappear.
ACTUAL -
The context menu will continue displaying.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javafx.embed.swt.FXCanvas;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class JavaFxInSwtContextBug {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new RowLayout());
org.eclipse.swt.widgets.Button swtButton = new org.eclipse.swt.widgets.Button(shell, SWT.PUSH);
swtButton.setText("SWT Button");
FXCanvas fxCanvas = new FXCanvas(shell, SWT.NONE) {
@Override
public Point computeSize(int wHint, int hHint, boolean changed) {
getScene().getWindow().sizeToScene();
int width = (int) getScene().getWidth();
int height = (int) getScene().getHeight();
return new Point(width, height);
}
};
Button jfxButton = new Button("JFX Button");
jfxButton.setId("ipad-dark-grey");
jfxButton.setContextMenu(new ContextMenu(new MenuItem("Test 1"), new MenuItem("Test 2")));
fxCanvas.setScene(new Scene(new Group(jfxButton)));
swtButton.addListener(SWT.Selection, event -> {
jfxButton.setText("JFX Button: Hello from SWT");
shell.layout();
});
jfxButton.setOnAction(event -> {
swtButton.setText("SWT Button: Hello from JFX");
shell.layout();
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use SWT context menus instead.