title: Javafx window gets maximised with new stage if not so and gets restored if it is in maximised form
body: <p>Could you please tell what I am making mistake here this code maximizes the current window if it is not so and viceversa.<br>
  This is done to refresh table view since refresh of table does not work after hiding PopOver of controlfx. It would have been better if you suggest an idea to refesh a table content after getting value from PopOver.</p>
  
  <pre><code>public class HomeController implements Initializable {
  @FXML
  private JFXButton btnViewMedicine;
  
  @FXML
  private JFXButton btnAdditional;
  
  @FXML
  private GridPane commGridMed;
  
  @FXML
  private TabPane tabPane;
  
  @FXML
  private Tab tabMedicine;
  
  @Override
  public void initialize(URL arg0, ResourceBundle arg1) {
      tabPane.getSelectionModel().selectFirst();
      btnViewMedicine.fire();
      tabPane.getSelectionModel().selectedItemProperty().addListener(new ChangeListener&lt;Tab&gt;() {
          @Override 
          public void changed(ObservableValue&lt;? extends Tab&gt; observable, Tab oldTab, Tab newTab) {
              if(newTab!=null) {
                  if(newTab.equals (tabMedicine)) {            
                      btnViewMedicine.fire();
                  }
              }
      }
      });
  }
  
  @FXML
  public void viewMedicine(ActionEvent event) throws IOException {
      GridPane node = (GridPane) FXMLLoader
              .load(getClass().getResource(Constants.VIEW_MEDICINE));
      deleteNode();
      commGridMed.add(node, 0, 1);
  }
  
  @FXML
  void viewAdditional(ActionEvent event) throws IOException {
      BorderPane node = (BorderPane) FXMLLoader
              .load(getClass().getResource(Constants.VIEW_ADDITIONAL));
      deleteNode();
      commGridMed.add(node, 0, 1);
  }
  
  public void viewAdditional() {
      tabPane.getSelectionModel().clearSelection();
      tabPane.getSelectionModel().select(0);
      btnAdditional.fire();
  }
  
  public void viewMedicine() {
      tabPane.getSelectionModel().clearSelection();
      tabPane.getSelectionModel().select(0);
      btnViewMedicine.fire();
  }
  
  private void deleteNode() {
      Set&lt;Node&gt; deleteNodes = new HashSet&lt;&gt;();
      for (Node child : commGridMed.getChildren()) {
          Integer row = GridPane.getRowIndex(child);
          Integer column = GridPane.getColumnIndex(child);
          if (row != null) {
              if (row.equals(1) &amp;&amp; column.equals(0)) {
                  deleteNodes.add(child);
              }
          }
      }
      commGridMed.getChildren().removeAll(deleteNodes);
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>public class ViewMethods{
  public void refresh(MouseEvent event) throws IOException {
      FXMLLoader loader = new FXMLLoader();
      loader.setLocation(getClass().getResource(Constants.HOME));
      Parent root = loader.load();
      HomeController controller = (HomeController) loader.getController();
      controller.viewAdditional();
      Scene scene = new Scene(root);
      Stage stage = (Stage((Node)event.getSource()).getScene().getWindow();
      stage.setScene(scene);
      //stage.setMaximized(true);
      stage.show();
  }
  }
  </code></pre>