-
Bug
-
Resolution: Fixed
-
P3
-
8u20
-
Java 8u-dev repo tip, Linux
I believe a recent fix has caused sub menus to fail to show in ContextMenus.
To reproduce run the test class below:
1. Right cick on the label and mouse over the sub menu to display it.
2. Click on the Rebuild button.
3. Repeat step 1.
********************************************* Test Class **********************************************
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class ContextMenuTest extends Application {
@Override public void start(final Stage primaryStage) throws Exception {
primaryStage.centerOnScreen();
primaryStage.setHeight(350);
primaryStage.setWidth(500);
final Menu submenu = new Menu("Sub Menu");
submenu.getItems().add(new MenuItem("Test 1"));
Label contextMenuLabel = new Label("Right Click On Me!");
final ContextMenu contextMenu = new ContextMenu(submenu);
contextMenuLabel.setContextMenu(contextMenu);
Button button = new Button("Rebuild Menu");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
contextMenu.getItems().clear();
contextMenu.getItems().add(submenu);
}
});
VBox box = new VBox(20, contextMenuLabel, button);
box.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
primaryStage.setScene( new Scene( new StackPane( box ) ) );
primaryStage.show();
}
public static void main(String[] args) throws Exception {
launch(args);
}
}
To reproduce run the test class below:
1. Right cick on the label and mouse over the sub menu to display it.
2. Click on the Rebuild button.
3. Repeat step 1.
********************************************* Test Class **********************************************
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class ContextMenuTest extends Application {
@Override public void start(final Stage primaryStage) throws Exception {
primaryStage.centerOnScreen();
primaryStage.setHeight(350);
primaryStage.setWidth(500);
final Menu submenu = new Menu("Sub Menu");
submenu.getItems().add(new MenuItem("Test 1"));
Label contextMenuLabel = new Label("Right Click On Me!");
final ContextMenu contextMenu = new ContextMenu(submenu);
contextMenuLabel.setContextMenu(contextMenu);
Button button = new Button("Rebuild Menu");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
contextMenu.getItems().clear();
contextMenu.getItems().add(submenu);
}
});
VBox box = new VBox(20, contextMenuLabel, button);
box.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
primaryStage.setScene( new Scene( new StackPane( box ) ) );
primaryStage.show();
}
public static void main(String[] args) throws Exception {
launch(args);
}
}
- relates to
-
JDK-8094989 CSS warnings logged to console when showing a sub menu in a rebuilt ContextMenu.
- Resolved