asked
2016-02-24 19:23:06 +0800
Princenuk 29 ● 5 I have Java Code for The Tabs to switch, however when they switch in the Application, only the headers switch and not the content.
The code:
public Tab createTab( String id, String title){
final Tab tab = new Tab();
tab.setId( "tab_" + id);
tab.setLabel(title);
tab.setDraggable("true");
tab.setDroppable("true");
tab.setClosable(true);
tab.setParent( getTabs());
tab.addEventListener(Events.ON_DROP, new EventListener(){
public void onEvent(Event event) {
DropEvent dropEvent = (DropEvent)event;
Tab tab =(Tab)dropEvent.getDragged();
Component tabs = tab.getParent();
tabs.removeChild(tab);
tabs.appendChild(tab);
tab.setSelected(true);
}
});
return tab;
}
When closed, the whole Tab closes both the Header and the content, however when Dragged and Dropped only the header moves and takes the place of the other Tab so now the Tab has a different header/Name but the same content.
Hi Chill,
I added the tabpanels like so (Is this how I switch the tabpanels?):
public void onEvent(Event event) {
DropEvent dropEvent = (DropEvent)event;
Tab tab =(Tab)dropEvent.getDragged();
Tabpanel tabpanel = (Tabpanel)dropEvent.getDragged();
Component tabs = tab.getParent();
Component tabpanels = tabpanel.getParent();
tabs.removeChild(tab);
tabs.appendChild(tab);
tabpanels.removeChild(tabpanel);
tabpanels.appendChild(tabpanel);
tab.setSelected(true);
}
});
However I get "org.zkoss.zul.Tab cannot be cast to org.zkoss.zul.Tabpanel" , which makes sense but I need it to treat the Tab & Tabpanel as one entity like it does with tab.setClosable(true) but its treating it as 2 different entities and I cant drag and drop tabpanels in this application.
The create tab class above is how each tab is generated and all the definitions inside are assigned to each tab, there is no zul file for the tab per sey if that makes sense.
I am not sure I added the tabpanels correctly.
Princenuk ( 2016-02-25 18:23:22 +0800 )edit