FULL PRODUCT VERSION :
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
macOS High Sierra 10.13.3
A DESCRIPTION OF THE PROBLEM :
When ContextMenu is displayed beyond the owner window, the rendering becomes randomly incomplete.
This problem occurs randomly, but the frequency is very high.
Context menus are used for multiple controls, especially problems with basic TextFields, so the impact of this problem is not small.
This problem was reproducible by installing the native package (pkg) application of macOS in Java 8, but in Java 9 it became possible to reproduce irrespective of this method.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Java9
1) Launch the test application
2) Open the context menu of TextField (or ChoiceBox)
3) Repeat 2
Java8
1) Create and install package of macOS by javapackager (nativeBundles="mac.appStore")
2) Launch the test application
3) Open the context menu of TextField (or ChoiceBox)
4) Repeat 3
It can be easily reproduced by quickly hitting ChoiceBox without moving mouse.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The entire context menu is displayed
ACTUAL -
Some contents of the context menu are not drawn.
When you mouse over over another menu item, the content is completely displayed.
REPRODUCIBILITY :
This bug can be reproduced often.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
import javafx.stage.Window;
public class ContextMenuOverWindowTest extends Application {
@Override
public void start(Stage stage) throws Exception {
// temporarySolution();
ObservableList<String> items = FXCollections.observableArrayList();
ChoiceBox<String> choiceBox = new ChoiceBox<>(items);
for (int i = 0; i < 10; i++) {
items.add("Item: " + (i + 1));
}
choiceBox.getSelectionModel().selectFirst();
Scene scene = new Scene(new HBox(new TextField(), choiceBox), 400, 100);
stage.setScene(scene);
stage.show();
}
private static void temporarySolution() {
ContextMenu.getWindows().addListener((ListChangeListener<Window>)(change)->{
while( change.next() ) {
for( Window window: change.getAddedSubList() ) {
if(window instanceof ContextMenu) {
final ContextMenu contextMenu = (ContextMenu)window;
contextMenu.setOnShown((event)->contextMenu.sizeToScene());
}
}
}
});
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Call the temporarySolution () method in the test source.
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
macOS High Sierra 10.13.3
A DESCRIPTION OF THE PROBLEM :
When ContextMenu is displayed beyond the owner window, the rendering becomes randomly incomplete.
This problem occurs randomly, but the frequency is very high.
Context menus are used for multiple controls, especially problems with basic TextFields, so the impact of this problem is not small.
This problem was reproducible by installing the native package (pkg) application of macOS in Java 8, but in Java 9 it became possible to reproduce irrespective of this method.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Java9
1) Launch the test application
2) Open the context menu of TextField (or ChoiceBox)
3) Repeat 2
Java8
1) Create and install package of macOS by javapackager (nativeBundles="mac.appStore")
2) Launch the test application
3) Open the context menu of TextField (or ChoiceBox)
4) Repeat 3
It can be easily reproduced by quickly hitting ChoiceBox without moving mouse.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The entire context menu is displayed
ACTUAL -
Some contents of the context menu are not drawn.
When you mouse over over another menu item, the content is completely displayed.
REPRODUCIBILITY :
This bug can be reproduced often.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
import javafx.stage.Window;
public class ContextMenuOverWindowTest extends Application {
@Override
public void start(Stage stage) throws Exception {
// temporarySolution();
ObservableList<String> items = FXCollections.observableArrayList();
ChoiceBox<String> choiceBox = new ChoiceBox<>(items);
for (int i = 0; i < 10; i++) {
items.add("Item: " + (i + 1));
}
choiceBox.getSelectionModel().selectFirst();
Scene scene = new Scene(new HBox(new TextField(), choiceBox), 400, 100);
stage.setScene(scene);
stage.show();
}
private static void temporarySolution() {
ContextMenu.getWindows().addListener((ListChangeListener<Window>)(change)->{
while( change.next() ) {
for( Window window: change.getAddedSubList() ) {
if(window instanceof ContextMenu) {
final ContextMenu contextMenu = (ContextMenu)window;
contextMenu.setOnShown((event)->contextMenu.sizeToScene());
}
}
}
});
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Call the temporarySolution () method in the test source.