0

Im trying to invoke a method of a controller form another controller. But It gives me Null Pointer Exception saying that java.lang.reflect.InvocationTargetException.

Here is my first controller with the method:

public class FirstController implements Initializable {

   @FXML
   private AnchorPane pane;
   ...
}

Here is the method :

public void setFadeEffect(Effect effect) {
    pane.setEffect(effect);
}

Here is my second controller:

public class SecondController implements Initializable {

    @FXML
    private Button myBtn; 
    ...

    @FXML
    private void myAction(ActionEvent event) throws IOException {
        FirstController ic = new FirstController();
        ic.setFadeEffect(new GaussianBlur(10));  
    }

Can anyone suggest me a way to perform this action please..

ItachiUchiha
  • 36,135
  • 10
  • 122
  • 176
Madushan Perera
  • 2,568
  • 2
  • 17
  • 36
  • Possible duplicate of [Switch between fxml files](http://stackoverflow.com/a/25886632/1759128) – ItachiUchiha Oct 23 '15 at 11:53
  • Consider to work with fx:root based controls/ controllers instead. – Puce Oct 23 '15 at 11:56
  • [Documentation](http://docs.oracle.com/javase/8/javafx/api/javafx/fxml/doc-files/introduction_to_fxml.html#custom_components) for @Puce's suggestion. – James_D Oct 23 '15 at 11:58

0 Answers0