Last active
November 2, 2015 07:07
-
-
Save cooljith91112/5a2f6250b987266adaa1 to your computer and use it in GitHub Desktop.
Stackoverflow example 1
This file contains hidden or 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
| /*========== | |
| Main Class | |
| ==========*/ | |
| URL locations = Main.class.getResource("your.fxml"); | |
| FXMLLoader loader = new FXMLLoader(); | |
| loader.setLocation(locations); | |
| loader.setBuilderFactory(new JavaFXBuilderFactory()); | |
| Parent root = loader.load(locations.openStream()); | |
| Scene scene = new Scene(root, 650, 340); | |
| primaryStage.setScene(scene); | |
| primaryStage.show(); | |
| MyController controller = new MyController(); | |
| controller.initMyVariables("NoName"); | |
| String name = controller.getMyVariable(); | |
| /*=================== | |
| MyController Class | |
| ===================*/ | |
| public class MyController implements javafx.fxml.Initializable{ | |
| String myName; | |
| @Override | |
| public void initialize(URL location, ResourceBundle resources) { | |
| } | |
| public initMyVariables(String myName){ | |
| this.myName = myName; | |
| } | |
| public String getMyVariable(){ | |
| return myName; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment