1

I want to call anchorpane form another class and add canvas to it. what is the simplest solution to my problem.

I'm new to Javafx

TlmeLineFxController.java

    public class TlmeLineFxController implements Initializable {

        @FXML
        private AnchorPane myViewAPid;
// more code
    .....
    }

AddEventFxController.java

    public class AddEventFxController implements Initializable{
        //more code

   @FXML
  void saveEvent(ActionEvent event) {
        // i get an error here because i need to put static to @FXML private AnchorPane myViewAPid;
        TlmeLineFxController.myViewAPid.getChildren().add(CanvasNewTimeLine.drawEventDuration());

        }
//more code
    }

CanvasNewTimeLine.java

public class CanvasNewTimeLine {    

    public static Canvas drawEventDuration(){

            Canvas canvas = new Canvas((yearsNO*120)+100, 200);
            GraphicsContext gc = canvas.getGraphicsContext2D();
            drawShapesEventDuration(gc);


            return canvas;

        }


        private static void drawShapesEventDuration(GraphicsContext gc) {

            //      TimeLine length  |-------------|
            gc.fillText(TLtitle, 40, 40);
    // more code....
      }
    }
Moodi1409
  • 155
  • 1
  • 10
  • See http://stackoverflow.com/questions/29639881/javafx-how-to-use-a-method-in-a-controller-from-another-controller/29640013#29640013 – James_D Apr 19 '15 at 13:09

0 Answers0