List of usage examples for javafx.scene.control ContextMenu show
public void show(Window owner)
From source file:org.beryx.viewreka.fxapp.codearea.ViewrekaCodeArea.java
protected void showContextMenu(ContextMenu cm) { if (codeTemplates.isEmpty()) return;/* w w w.j a va 2s .c om*/ cm.getItems().clear(); for (CodeTemplate template : codeTemplates) { // TODO retrieve context and create MenuItem only if template.isAllowedInContext() returns true MenuItem item = new MenuItem(template.getName()); item.setOnAction(ev -> { if (classLoaderManager != null) { classLoaderManager.setProjectClassLoader(); } try { insertCodeFragment(template); } finally { classLoaderManager.resetClassLoader(); } }); cm.getItems().add(item); } cm.getItems() .sort((item1, item2) -> item1.getText().toLowerCase().compareTo(item2.getText().toLowerCase())); cm.show(getScene().getWindow()); }