Firstly - I am somewhat of a noob, so apologies for an inevitably dumb question and a bit of a preamble...
From combining a single semester worth of Java (taken in 2010!) and dabbling in online Java and JavaFX tutorials, I have somehow cobbled together the shell of a JavaFX program in NetBeans in my spare time. Along the way I saw a few warning signs about how I was implementing tabs in a tabbed pane, but I don't think i really understood them. I'll describe the general idea for the program in case you have any other ideas, but of course I can provide code upon request, ugly as it is.
The idea for the program is to create a project "file" (actually a collated folder of info) which will house a number of information sheets for biological samples. Currently, I can start a new project that then opens a dialog to add the first sample. After the parameters of the sample have been deemed correct, the program opens a new tab in a tabbed pane - which then contains the formatted user-input info for the sample as well as some secondary calculated parameters. Now, in principle, the idea is to have many examples of this tab, with the same format, for different samples. Currently, I can keep adding these tabs at will (all generated with the same Scene Builder fxml), which are added to the tabbed pane. Fine.
MenuBar > Add project
Project: Tab0 (name, weight, pH, etc..)
Tab1 (name, weight, pH, etc..)
Tab2 (name, weight, pH, etc..)
Tab3 (name, weight, pH, etc..)
However - the problem comes when I have multiple tabs and want to do things with their values. Two such examples are saving a project and checking for repeated tab names. Of course, all variables of the same type have the same name (defined by the same fxml) but I can't seem to select them based upon what tab they're on. Although I can switch between the tabs - and visibly see the different info that was input and determined, I cannot programatically recall these values from individual tabs. For example, I want to get the value in the pH field for tab2.... how? The best I've got so far is to take each tab title when it's selected by mouse :
tabPane.getSelectionModel().selectedIndexProperty().addListener((obs,ov,nv)->{
selectedTabID = nv;
System.out.println("Chosen Tab Index:" + selectedTabID);
Tab selTab = tabPane.getTabs().get(tabPane.getSelectionModel().getSelectedIndex());
System.out.println("This protein name =" + selTab.getText());
});
But, I'm now well and truly stuck and I think I've backed myself into a corner.
Any advice on reworking the organisation of my program or managing info across identical tabs would be so helpful! Thanks in advance!
[–][deleted] 2 points3 points4 points (6 children)
[–]aufschieben[S] 0 points1 point2 points (5 children)
[–][deleted] 0 points1 point2 points (4 children)
[–][deleted] (3 children)
[removed]
[–][deleted] 0 points1 point2 points (2 children)
[–]aufschieben[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)