Dynamically adding a panel to an existing panel?
I have a program where I have several tabs(JTabbedPane). On the second tab, there is a top panel that has three small panels inside of it. One of which is to be populated by several smaller panels at runtime when the user clicks import.
So basically, when the user clicks import from the menu, the list panel that is in the top panel of the second JTabbedPane should automatically be populated with smalled panels dynamically. Each of the small panels has like three labels and two button. The problem I am having is that when I iterate and add the small panels to the list panel, they do not show up. I know they are being crated correctly because I can add them as new tabs with ease and the iteration and construction is correct. They just won't appear in the already existing list panel.
This code works and produces new tabs with the small panels in them:
public void importCurAbsUC(EditUseCasePanel ucEditer, UseCaseGUI gui){
this.useCases = UseCaseModel.getUseCaseVector();
System.out.print("inside import call\n");
for (Iterator<UseCaseStruct> it = useCases.iterator(); it.hasNext();){
tempUseCase = it.next();
//ucEditer.getAbsListUCPanel().add(new absUCPanel(tempUseCase.getActor(), tempUseCase.getSystem(), tempUseCase.getVNPhrase()));
//ucEditer.getAbsListUCPanel().repaint();
gui.getjTabbedPane1().add("abstract UC", new absUCPanel(tempUseCase.getActor(), tempUseCase.getSystem(), tempUseCase.getVNPhrase()));
//gui.getjTabbedPane1().repaint();
System.out.print(tempUseCase.getVNPhrase()+ " panel was made and added\n");
}
}
But this code does not work, the code i want to work:
public void importCurAbsUC(EditUseCasePanel ucEditer, UseCaseGUI gui){
this.useCases = UseCaseModel.getUseCaseVector();
System.out.print("inside import call\n");
for (Iterator<UseCaseStruct> it = useCases.iterator(); it.hasNext();){
tempUseCase = it.next();
ucEditer.getAbsListUCPanel().add(new absUCPanel(tempUseCase.getActor(), tempUseCase.getSystem(), tempUseCase.getVNPhrase()));
//ucEditer.getAbsListUCPanel().repaint();
//gui.getjTabbedPane1().add("abstract UC", new absUCPanel(tempUseCase.getActor(), tempUseCase.getSystem(), tempUseCase.getVNPhrase()));
//gui.getjTabbedPane1().repaint();
System.out.print(tempUseCase.getVNPhrase()+ " panel was made and added\n");
}
}
Thanks in advance for any help.
Last edited by Thorshix; February 20th, 2010 at 03:01 PM..
|