JavaFX & FXML. Nested lists in combobox - javafx

I am making an app and need to create a combobox with nested lists.
Like you have some options when you click on the combobox, but you can also click on them to get more options.
I am trying to make it with SceneBuilder and have no clue how to make it work.

Related

javafx deleting contents of an accordion pane

I have an accordion pane which contains three titled panes. I wish to delete these in the java program, however the Accordion object doesn't seem to have a clear or remove method to do this.
I have tried some ways to get around this such as the following:
if (!measureAccordion.getChildrenUnmodifiable().isEmpty()) {
ObservableList<javafx.scene.Node> accordionContent = measureAccordion.getChildrenUnmodifiable();
accordionContent.clear();
}
But this raised an UnsupportedOperationException.
If you check here accordion in javaFX , you will see that the accordion object has a method, getPanes(), which returns an ObservableList of TitledPane. The ObservableList has a lot of methods that you could use such as removeAll. You can see here the documentation for ObservableList.
Accordion is a control that can contain only TitledPane components. So if you want to modify content of Accordion then use Accordion#getPanes method.

How to get the tableview object which is inside a tab which inturn is inside a Tabpane Javafx

I have a tabpane which has 13 tabs and each of those thirteen tabs have 13 table views as well as some components like buttons and labels in each tab
I want to get the tableview object by selecting the tableview from a particular tab.
Like if the focus comes to a table view i can get to know from which tab it has come so that i can use the particular tableview object in a method.
As i have a method that will do a task which is same just the tableview changes depending upon the tab , si if i can get the tableviews i do not need to code 13 methods. But the issue is the tab on tabpane dosent only have tableview it has labels buttons also. How to fetch the extact I am not sure how to move further as beacuse what i exactly want is like i have a method that will do a task which ia same just the tableview changes depending upon the tab , so if i can get the tableview obj of each tab i do not need to code 13 methods. But the issue is the tab on tabpane dosent only have tableview it has labels buttons also. How to fetch the extact node.
The logic behind the tab and tab pane is a fxml component . I am using fxml component to develop my application.
eg:-
Set<Report> selection = new HashSet<Report>(businessEventReport.getSelectionModel().getSelectedItems());
here the businessEventreport is a table view in a table , i want to get the particular tableview by focusing on the particular tableview of the tab.
how do i do that .
i can get the tabs using
SingleSelectionModel<Tab> selectionModel = tabpane.getSelectionModel();
selectionModel.getSelectedItem().getContent();
but i am stuck after that.
One solution would be to assign each of your TableViews an identifier. This
identifier would then be used to discover the TableView from amongst the set of controls on each tab (or the whole Scene) using the lookup method.
To set the identifier for each TableView use the Node.setId method.
tableView.setId("MyTable")
To find the TableView from the TabPane use the Node.lookup method.
Tab selectedTab = tabPane.getSelectionModel().getSelectedItem()
Node selectedContent = selectedTab.getContent()
TableView selectedTable = selectedContent.lookup("#MyTable")
The lookup method searches through the children of the Node used to perform the lookup. This gives you the flexibility to either assign each of your TableViews a unique identifier, allowing lookup from TabPane itself or to assign them all the same identifier and use the parent Tab to discover the TableView (example above).
The lookup method uses a CSS selector to find controls so identifiers aren't mandatory. An alternative approach would be to use the class type and state of the TabPane and TableView to form a selector. Something like the following (untested).
selectedContent.lookup(".tab-pane > .tab:selected > .table-view")

Adding UIImagePickerController onto an already open UIPopoverController

I have a popover which contains a tableview, once a row has been selected I want to then push on a UIImagePickerController.
According to the documents on the Apple website, I can only present this in a new view controller. How do I present a popover, in a popover? Or is there another way to do it?
The easiest way is to create a delegate and dismiss the tableview on didSelectRowAtIndex using either an exit unWind segue or by dismissing the popover manually using a delegate. Then present the popOver containing the UIImagePickerController. You could also just use the delegate to display a popover along with the tableview although that probably would look cluttered.

List of Checkboxes in Android App using Flex and Flashbuilder

I am trying to implement a list of checkboxes and a Android Form App I am working on. I want the list to only have single selection, i.e. I can only select one option from the list.... for some reason I can not find any code to do this, I am using Flashbuilder and the Flex framework, anyone know of a way to do this ??
Thanks in advance for any help!
If you want a single selection, use radio buttons with a radio button group.
The only reason you'd want to use checkboxes is if you want to turn off all selections (with radio buttons, once you've clicked a button one is always selected).
If you still want to use checkboxes, do the following:
onCheckBoxSelected(e:Event){
for each(checkbox:CheckBox in collectionOfCheckBoxes){
if(checkbox != e.currentTarget){
checkbox.selected=false;
}
}
}

Flex: How can I Load data, then create required components?

I have a flex application that has three tabs. Each of these tabs has a component that loads a ‘form’ that has a dropdown combo box. These combo boxes depend on external data in order to populate correctly. Currently the first tab is being created and the data that should be populated in the combo box is not in there. The combo box for the second tab is populated with the required data.
What I’d like to do is create an event that is dispatched after the data is loaded. When this event happens I’d like to then create these tabs, or the components of the tabs. Is there a way to wait for the data to be loaded before the application creates the components?
You could create the components in actionscript.
this code will create a ComboBox:
var newBox = new ComboBox();
newBox.dataProvider = aDataProvider;
// You could alternativley use (v/h)box.addChild(newBox)
// to add it as a child of a specific element
Application.application.addChild(newBox);
You can use that sort of technique to create the components in actionscript, you will still need to set all the properties that are usually set in mxml, but they all have the same names.

Resources