Skip to content

Instantly share code, notes, and snippets.

@cooljith91112
Last active November 2, 2015 07:07
Show Gist options
  • Select an option

  • Save cooljith91112/5a2f6250b987266adaa1 to your computer and use it in GitHub Desktop.

Select an option

Save cooljith91112/5a2f6250b987266adaa1 to your computer and use it in GitHub Desktop.
Stackoverflow example 1
/*==========
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