Thanks for that reply.I'm using the change listner
I've added tab inside the other tab.When i print the index of the tab selected i'm getting the correct index when clicked on the main tab.But for the child tabs i get the corrct tab index when ever i click on the last main tab and its children.Whre as for all the other tabs i'm getting index as zero......where am i going wrong?
public GUITabbedPane createTabedPane(HashMap noOfSec,HashMap Pages){
System.out.println("noOfSec "+noOfSec+" Pages"+Pages);
allPages = Pages;
Set set = noOfSec.keySet();
Iterator itr = set.iterator();
sectionTabPane = new GUITabbedPane();
sectionTabPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
int i = sectionTabPane.getSelectedIndex();
System.out.println("Change listener ==>"+i);
sectionTabPane.revalidate();
sectionTabPane.repaint();
}
});
while(itr.hasNext()){
Object ob = itr.next();
splitHashMap(ob,noOfSec.get(ob));//will return the arraylist for each section
}
return sectionTabPane;
}
private void splitHashMap(Object mainTabTitles,Object sectionWiseArrayList){
try{
arrList = new ArrayList();
arrList = (ArrayList)sectionWiseArrayList;
String sectionWiseMainTabTitle = mainTabTitles.toString();
//now using this arraylist,allpages
System.out.println("arrList.length "+arrList.size());
GUIPanel p = new GUIPanel();
sectionTabPane.addTab(sectionWiseMainTabTitle,addChildTab(arrList));
}catch(Exception e){
e.printStackTrace();
}
}
private GUIBasePanel addChildTab(ArrayList sectionWiseArrayList) {
GUIBasePanel pnlBaseChild = new GUIBasePanel();
pnlBaseChild.setLayout(new BorderLayout());
try{
tab = new GUITabbedPane();
tab.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
int i = tab.getSelectedIndex();
System.out.println("Change listener child ==>"+i);
tab.revalidate();
tab.repaint();
}
});
for(int g=0;g<sectionWiseArrayList.size();g++){
tab.addTab(sectionWiseArrayList.get(g).toString(),(JPanel)allPages.get(sectionWiseArrayList.get(g)));
}
pnlBaseChild.add(tab,BorderLayout.CENTER);
}catch (Exception e) {
e.printStackTrace();
}
return pnlBaseChild;
}
}
thanks in advance