0

Firstly, sorry for my English. I hope, you unterstand it.

Last Month I started developing a little programm with FXML/ JavaFX.

I have two screens, and I'm switching between them. This is not the problem.

The problem is: On one Screen i have a listview, where i can choose an item. When i have chosen an item, i want to open a new tab on the other screen with the content of the item. Therefore, i have to click on a button.

When i have chosen an item, i can print out the selected item, but how do I open a new tab on the other screen. Both Screens a two different FXML and are activited from the controller. How can I add a Tab, although loading fxml?

     public class Controller{

    @FXML
    private ListView<String> lv;

    @FXML
    private Button check;
            @FXML
            public void projectview (Event e3) throws Exception{
                    Stage stage = null;
                    Parent root = null;
                    if(e3.getSource()==check){
                            //Check is the declaration for the Button on the screen with the listview
                            String projectview= lv.getSelectionModel().getSelectedItem();
                            stage = (Stage) check.getScene().getWindow();
                            root = FXMLLoader.load(getClass().getResource("FXML1.fxml"));
                            //Here I want to add a tab in FXML1.fxml
                            Scene scene = new Scene(root);
                            stage.setScene(scene);
                            stage.show();

                    }
           }
     }

If something is missing or not clear, please ask. I read other similar questions, but i don't know, what to do.

Thanks for help

Alith
  • 1
  • 2
  • 1
    The thing with similar questions is they are likely to be duplicates. Unless you can describe, why your issue is different, it's a duplicate of [Passing Parameters JavaFX FXML](http://stackoverflow.com/questions/14187963/passing-parameters-javafx-fxml). You just need to pass the info you need to create the `Tab`, maybe even the `Tab` itself. – fabian Jul 14 '16 at 08:46
  • Yes, thank you for link me to that questions. But that didn't helped me. I have found this: http://stackoverflow.com/questions/30551088/passing-parameters-between-screens-in-javafx-fxml-scenebuilder ; Now I can pass data between two Screens – Alith Jul 20 '16 at 08:07

0 Answers0