JTabbedPane contents not shown
Greetings.
I have a JFrame containing a MenuBar, a ToolBar, a status panel and a JTabbedPane.
I build it, set it visible, and everything is just fine. A parent object receives
new frame descriptions from time to time and attempts to rebuild some of the four
or all of them.
So, after callinggetContentPane().removeAll(), I add the four
components one by one. Method called addTabs() is responsible for composing and
adding the JTabbedPane... After calling it, i can see the new tab headings where
they should be, but none is selected, none can be selected and the tab contests
are not shown. Why?
The code of addTabs looks something like this:
privatevoid addTabs(){
workTabs=new MyTabs(JTabbedPane.TOP,this);
int i=1;
String tabItem=null;
// prepare tabs
do{
if (there_is_a_tab_description_for(i)){
MyPanel newPanel=new MyPanel(some_arguments,new GridBagLayout());
workPanels[i]=newPanel;
JScrollPane scrollpane=new JScrollPane(newPanel);
workTabs.addTab(name_of_tab(i),scrollpane);
}
i++;
}while (tabItem!=null);
// add prepared tabs to main frame
if (workTabs.getTabCount()>0){
workTabs.setBackground(formBG);
GridBagConstraints c=new GridBagConstraints();
//...
topLayout.setConstraints(workTabs,c);
workTabs.revalidate();
workTabs.repaint();
getContentPane().add(workTabs);
getContentPane().validate();
}
}
thanks, Klaus.

