When embedding an FXCanvas directly in an SWT group without an SWT canvas in between Combobox pop-ups inside the FXCanvase are shifted some pixels to bottom right.
The following widget hierarchy leads to the Problem:
SWT shell -> SWT group -> FXCanvas -> GridPane -> ComboBox
Putting an SWT canvas between group and FXCanvas solves the problem as well as removing the SWT group. See test method below.
private void openTestShell(final boolean useSwtGroup,
final boolean useSwtCanvas) {
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Composite parent = shell;
if (useSwtGroup) {
Group group = new Group(parent, SWT.NONE);
group.setLayout(new GridLayout(1, true));
parent = group;
}
if (useSwtCanvas) {
Canvas swtCanvas = new Canvas(parent, SWT.NONE);
swtCanvas.setLayout(new FillLayout());
parent = swtCanvas;
}
FXCanvas canvas = new FXCanvas(parent, SWT.NONE);
GridPane gridPane = new GridPane();
Scene scene;
scene = new Scene(gridPane);
canvas.setScene(scene);
ComboBox<String> myCombo = new ComboBox<String>();
myCombo
.setItems(FXCollections.observableArrayList("One", "Two", "Three"));
gridPane.add(myCombo, 0, 0);
shell.pack();
shell.open();
}
The following widget hierarchy leads to the Problem:
SWT shell -> SWT group -> FXCanvas -> GridPane -> ComboBox
Putting an SWT canvas between group and FXCanvas solves the problem as well as removing the SWT group. See test method below.
private void openTestShell(final boolean useSwtGroup,
final boolean useSwtCanvas) {
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Composite parent = shell;
if (useSwtGroup) {
Group group = new Group(parent, SWT.NONE);
group.setLayout(new GridLayout(1, true));
parent = group;
}
if (useSwtCanvas) {
Canvas swtCanvas = new Canvas(parent, SWT.NONE);
swtCanvas.setLayout(new FillLayout());
parent = swtCanvas;
}
FXCanvas canvas = new FXCanvas(parent, SWT.NONE);
GridPane gridPane = new GridPane();
Scene scene;
scene = new Scene(gridPane);
canvas.setScene(scene);
ComboBox<String> myCombo = new ComboBox<String>();
myCombo
.setItems(FXCollections.observableArrayList("One", "Two", "Three"));
gridPane.add(myCombo, 0, 0);
shell.pack();
shell.open();
}