javafx deleting contents of an accordion pane - javafx

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.

Related

JavaFX & FXML. Nested lists in combobox

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.

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.

Make a Spark TitleWindow modal without using much AS3?

I want to be able to show a Spark TitleWindow container as a modal without having to construct it by code via AS3. I tried creating the TitleWindow before-hand manually by dragging and resizing it around and adding objects, etc then hiding it. Then on a button, I set the called function to the ones below:
public function doPopup():void {
testWindow.visible = true;
PopUpManager.addPopUp(testWindow, this, true);
}
Unfortunately, this only shows testWindow but not as a modal. I want it to be like this so that I can freely resize and design the layout of my TitleWindow and only have to call some function to show it as a modal one.
I'm pretty sure the reason you are seeing this behavior is because your TitleWindow (that you've declared within the mxml of the parent container) is already added to the stage even though it is set as not visible. A workaround you could try is to call this.removeElement(testWindow) in a creation complete handler for the parent container. That will get it off the stage so the PopUpManager can add it later properly.
Having said that, I would recommend putting your TitleWindow into a separate mxml file and instantiate it using the PopUpManager. It's cleaner that way and you can still use the design mode to lay it out as you see fit.
Hope that helps.
Try the Cairngorm 3 Popup library :
http://opensource.adobe.com/wiki/display/cairngorm/HowToUseCairngormPopup

Flex ContextMenu Change the items dynamically

I am using a ContextMenu for an AdvancedDataGrid in my application. I could implement the normal context menu for the grid. Now, I am planning to make the context menu dynamic.
For example, if I click on a particular cell, I need to see only the items related to that cell in the Context Menu. Is there any way we can do that?
ContextMenu class contains a customItems property which is (quoting from Adobe livedocs):
An array of ContextMenuItem objects. Each object in the array represents a context menu item that you have defined. Use this property to add, remove, or modify these custom menu items.
To add new menu items, you create a ContextMenuItem object and then add it to the customItems array (for example, by using Array.push()). For more information about creating menu items, see the ContextMenuItem class entry.
I found the solution for this. Quite simple:
http://www.pubbs.net/flex/200905/73331/

Resources