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.

[2382 byte] By [kledrua] at [2007-9-29 5:30:11]
# 1
I'm sorry, the problem was not in addTabs() method as i assumed, instead there was something wrong with code responsible for focus policies and field validation. Case closed :)
kledrua at 2007-7-14 18:35:19 > top of Java-index,Archived Forums,Swing...