Buggy code:
Label label_task_id_name = new Label ( ) ; label_task_id_name . setText ( ( ( ( "Завдання<seq2seq4repair_space>:<seq2seq4repair_space>" + ( session_choice . getTask ( ) . getId ( ) . toString ( ) ) ) + "|" ) + ( session_choice . getTask ( ) . getName ( ) ) ) ) ; label_task_id_name . setLayoutX ( 50 ) ; label_task_id_name . setLayoutY ( 40 ) ; label_task_id_name . setFont ( Font . font ( 16 ) ) ; marks_matrix . getChildren ( ) . add ( label_task_id_name ) ; Label label_session_id = new Label ( ) ; label_session_id . setText ( ( "Сесія<seq2seq4repair_space>:<seq2seq4repair_space>" + ( session_choice . getId ( ) ) ) ) ; label_session_id . setLayoutX ( 50 ) ; label_session_id . setLayoutY ( 20 ) ; label_session_id . setFont ( Font . font ( 16 ) ) ; marks_matrix . getChildren ( ) . add ( label_session_id ) ; Label criteriy = new Label ( ) ; criteriy . setText ( ( "Критерій<seq2seq4repair_space>:<seq2seq4repair_space>" + ( session_choice . getCriterion ( ) . getCriterion ( ) ) ) ) ; criteriy . setLayoutX ( 400 ) ; criteriy . setLayoutY ( 40 ) ; criteriy . setFont ( Font . font ( 16 ) ) ; marks_matrix . getChildren ( ) . add ( criteriy ) ; SimpleDateFormat format1 = new SimpleDateFormat ( "dd.MM.yyyy<seq2seq4repair_space>hh:mm" ) ; Label dateLabel = new Label ( ) ; dateLabel . setText ( ( "Дата<seq2seq4repair_space>:<seq2seq4repair_space>" + ( format1 . format ( session_choice . getDate ( ) ) ) ) ) ; dateLabel . setLayoutX ( 150 ) ; dateLabel . setLayoutY ( 20 ) ; dateLabel . setFont ( Font . font ( 16 ) ) ; marks_matrix . getChildren ( ) . add ( dateLabel ) ; ArrayList < Button > archery_open_button_ver = new ArrayList < > ( ) ; ArrayList < Button > archery_open_button_hor = new ArrayList < > ( ) ; GridPane gridPane_mark = new GridPane ( ) ; gridPane_mark . getChildren ( ) . clear ( ) ; gridPane_mark . setHgap ( hsize ) ; gridPane_mark . setVgap ( vsize ) ; gridPane_mark . setPadding ( new Insets ( 10 , 10 , 10 , 10 ) ) ; gridPane_mark . setBorder ( Border . EMPTY ) ; Label arch_label = new Label ( ) ; arch_label . setText ( "Архітектура" ) ; gridPane_mark . add ( arch_label , 0 , 0 ) ; for ( int i = 0 ; i < ( session_choice . getTask ( ) . getArchitectures ( ) . size ( ) ) ; i ++ ) { archery_open_button_hor . add ( new Button ( ( "arch:<seq2seq4repair_space>" + ( i + 1 ) ) ) ) ; archery_open_button_ver . add ( new Button ( ( "arch:<seq2seq4repair_space>" + ( i + 1 ) ) ) ) ; gridPane_mark . add ( archery_open_button_hor . get ( ( ( archery_open_button_hor . size ( ) ) - 1 ) ) , ( i + 1 ) , 0 ) ; gridPane_mark . add ( archery_open_button_ver . get ( ( ( archery_open_button_ver . size ( ) ) - 1 ) ) , 0 , ( i + 1 ) ) ; } ArrayList < Label > labels_marks = new ArrayList < > ( ) ; for ( int i = 0 ; i < ( session_choice . getMarks ( ) . size ( ) ) ; i ++ ) { labels_marks . add ( new Label ( session_choice . getMarks ( ) . get ( i ) . getMark ( ) . toString ( ) ) ) ; gridPane_mark . add ( labels_marks . get ( ( ( labels_marks . size ( ) ) - 1 ) ) , ( ( ( session_choice . getMarks ( ) . get ( i ) . getNumArch1 ( ) ) - ( session_choice . getMarks ( ) . get ( 0 ) . getNumArch0 ( ) ) ) + 1 ) , ( ( ( session_choice . getMarks ( ) . get ( i ) . getNumArch0 ( ) ) - ( session_choice . getMarks ( ) . get ( 0 ) . getNumArch0 ( ) ) ) + 1 ) ) ; } class EventHandlerViewPreviewImpl implements EventHandler < ActionEvent > { final int finalI ; public EventHandlerViewPreviewImpl ( int finalI ) { } @ Override public void handle ( ActionEvent e ) { FXMLLoader loader = new FXMLLoader ( getClass ( ) . getResource ( "//src//view_fxml//preview.fxml" ) ) ; Stage stage = new Stage ( StageStyle . DECORATED ) ; try { stage . setScene ( new Scene ( ( ( Pane ) ( loader . load ( ) ) ) ) ) ; } catch ( IOException e1 ) { e1 . printStackTrace ( ) ; } <START_BUG> preview controller = loader . < preview > getController ( ) ; <END_BUG> controller . initData ( session_choice . getTask ( ) . getArchitectures ( ) . get ( finalI ) ) ; stage . setTitle ( ( "Візуалізація<seq2seq4repair_space>архітектури<seq2seq4repair_space>" + ( ( finalI ) + 1 ) ) ) ; stage . show ( ) ; choice_session ( actionEvent ) ; } } for ( int i = 0 ; i < ( archery_open_button_hor . size ( ) ) ; i ++ ) { final int finalI = i ; archery_open_button_hor . get ( i ) . setOnAction ( new EventHandlerViewPreviewImpl ( i ) ) ; } for ( int i = 0 ; i < ( archery_open_button_ver . size ( ) ) ; i ++ ) { final int finalI = i ; archery_open_button_ver . get ( i ) . setOnAction ( new EventHandlerViewPreviewImpl ( i ) ) ; } gridPane_mark . setLayoutY ( 60 ) ; gridPane_mark . setLayoutX ( 20 ) ; marks_matrix . getChildren ( ) . add ( gridPane_mark ) ; } public void Session_choise ( ActionEvent actionEvent ) { } public void goBackMain ( ActionEvent actionEvent ) { } public void exit ( ActionEvent actionEvent ) { } }

Fix:
Preview controller = loader . < Preview > getController ( ) ;