I have FXMLDocumentController.java and i wanna to send name(textfill) to anoterclass
public class FXMLDocumentController implements Initializable {
@FXML
private Label label;
@FXML
private Button button;
@FXML
private TextField name;
private String sss = "";
@FXML
private void handleButtonAction(ActionEvent event) {
System.out.println("You clicked me!");
label.setText("Hello World!");
sss=name.getText();
setSss(sss);
System.out.print(sss);
}
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
public String getSss() {
return sss;
}
public void setSss(String sss) {
this.sss = sss;
}
and this another class login.java
public class Login extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
FXMLDocumentController fx = new FXMLDocumentController();
System.out.print(fx.getSss());
}
i debug and fx.getSss is null what should i do? thank you for comment