• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to update table of one fxml by clicking button of other fxml?  RSS feed

drashti pandya
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have TableView and add button in my first.fxml when i click on add button it should display second.fxml and take input form user.when i click save button in second.fxml Tableview in first.fxml should be update with user input which i take in second.fxml.
public void handlePriceSaveButton(ActionEvent a){
Stage stage = new Stage();
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("second.fxml"));
Parent root = (Parent) fxmlLoader.load();
FirstController controller=fxmlLoader.<FirstController>getController();
stage.setScene(new Scene(root));


Button SaveButton;
private ObservableList<Person1> data = FXCollections.observableArrayList();
FXMLLoader fxmlLoader1 = new FXMLLoader(getClass().getResource("Sys1.fxml"));
Sys1Controller controller=fxmlLoader1.<Sys1Controller>getController();

public void handleAddOnButtonAction(ActionEvent a){
data.add(new Person1(

Stage stage = (Stage) SaveButton.getScene().getWindow();

public void initialize(URL location, ResourceBundle resources) {
controller.AddOnColumn.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person1,String>("AddOn Name"));
controller.ValueColumn.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person1,String>("Value"));
controller.ByPercentageColumn.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person1,String>("By Percentage"));
controller.TaxColumn.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<Person1,String>("Tax Exclusive"));

public class Person1 {
private final StringProperty AddOnColumn;
private final StringProperty ValueColumn;
private final StringProperty ByPercentageColumn;
private final StringProperty TaxColumn;
// private final ObjectProperty<LocalDate> birthday;
public Person1() {
this(null, null,null,null);
public Person1(String AddOnColumn, String ValueColumn,String ByPercentageColumn,String TaxColumn) {
this.AddOnColumn = new SimpleStringProperty(AddOnColumn);
this.ValueColumn = new SimpleStringProperty(ValueColumn);
this.ByPercentageColumn = new SimpleStringProperty(ByPercentageColumn);
this.TaxColumn = new SimpleStringProperty(TaxColumn);
public String getAddOnColumn() {
return AddOnColumn.get();
public void setAddOnColumn(String AddOnColumn) {
public StringProperty AddOnColumnProperty() {
return AddOnColumn;
public String getValueColumn() {
return ValueColumn.get();
public void setValueColumn(String ValueColumn) {
public StringProperty ValueColumnProperty() {
return ValueColumn;
public String getByPercentageColumn() {
return ByPercentageColumn.get();
public void setByPercentageColumn(String ByPercentageColumn) {
public StringProperty ByPercentageColumnProperty() {
return ByPercentageColumn;
public String getTaxColumn() {
return TaxColumn.get();
public void setTaxColumn(String TaxColumn) {
public StringProperty TaxColumnProperty() {
return TaxColumn;

But it shows error in initialize method in first line null pointer exception.
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!