Created
January 8, 2014 20:49
-
-
Save jimklo/8324380 to your computer and use it in GitHub Desktop.
JavaFX Context Menus broken in when using E3 FXViewPart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sri.sunflower.fxquery; | |
import java.net.URL; | |
import java.util.ResourceBundle; | |
import javafx.fxml.FXML; | |
import javafx.scene.control.ListView; | |
public class SampleViewController { | |
@FXML // ResourceBundle that was given to the FXMLLoader | |
private ResourceBundle resources; | |
@FXML // URL location of the FXML file that was given to the FXMLLoader | |
private URL location; | |
@FXML // fx:id="myList" | |
private ListView<String> myList; // Value injected by FXMLLoader | |
@FXML // This method is called by the FXMLLoader when initialization is complete | |
void initialize() { | |
assert myList != null : "fx:id=\"myList\" was not injected: check your FXML file 'SampleViewLayout.fxml'."; | |
// Initialize your logic here: all @FXML variables will have been injected | |
myList.getItems().add("One"); | |
myList.getItems().add("Two"); | |
myList.getItems().add("Three"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<?import java.lang.*?> | |
<?import javafx.scene.control.*?> | |
<?import javafx.scene.layout.*?> | |
<?import javafx.scene.layout.GridPane?> | |
<fx:root type="GridPane" minHeight="600.0" minWidth="800.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="com.sri.sunflower.fxquery.SampleViewController"> | |
<children> | |
<ListView fx:id="myList" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="0" GridPane.rowIndex="0"> | |
<contextMenu> | |
<ContextMenu> | |
<items> | |
<MenuItem mnemonicParsing="false" text="Unspecified Action" /> | |
</items> | |
</ContextMenu> | |
</contextMenu> | |
</ListView> | |
</children> | |
<columnConstraints> | |
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" /> | |
</columnConstraints> | |
<rowConstraints> | |
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" /> | |
</rowConstraints> | |
</fx:root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sri.sunflower.fxquery.views; | |
import java.io.IOException; | |
import javafx.fxml.FXMLLoader; | |
import javafx.scene.Parent; | |
import javafx.scene.Scene; | |
import at.bestsolution.efxclipse.runtime.workbench3.FXViewPart; | |
public class SampleViewPart extends FXViewPart { | |
public static final String ID = "com.sri.sunflower.fxquery.views.SampleViewPart"; | |
@Override | |
protected Scene createFxScene() { | |
Scene scene = null; | |
try { | |
Parent root = FXMLLoader.load(getClass().getResource("/SampleViewLayout.fxml")); | |
scene = new Scene(root); | |
} catch (IOException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} | |
return scene; | |
} | |
@Override | |
protected void setFxFocus() { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment