• Post Reply Bookmark Topic Watch Topic
  • New Topic

tab doesn't show in the JTabbedPane  RSS feed

 
George Chen
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I use the toolbar to add and show Tab in the JTabbedPane componet.
My code like that :
public void actionAdd() {

AdminTabbedPane temp = (AdminTabbedPane) getTabbedPane();
int count = tabbedPane.getTabCount();
if (temp.tab1Option != 1) {
if (count == 2)
temp.removeTab(1);
temp.tab1Option = 1;
JPanel p3 = temp.getThirdPanel();
temp.addTab(tabbedPane, p3, "Add");

p3.invalidate();

}

temp.setSelectedIndex(1);

}

means: when I click the button in the toolbar , it will add tab into the tabbedpane ,switch to the tab and show it.
When I implement it . sometime it works, sometime it doesn't work. But I found when I resize the application window , the tab page will display.
Who can tell me why ? and how to fix it.
Thanks in advance.
George Chen
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi George,
You might need to invalidate the parent container because your tab pane is actually getting bigger with each added pane. The parent container needs to know about the new tab pane size. IMO, that is why it is working when you are resizing the frame.
Regards,
Manfred.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!