• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JTabbedPane

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
In my project I have created many forms like candiateInfo,Resume etc.(which extends JFrame)
Now I want to use JTabbedPane.Menas if I click on one tab it should take user to resp. form.Code I have written like this(it's in contstructor of that class):
[code]{ contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
JTabbedPane tabbedPane = new JTabbedPane();
String tabs[] = {"CandidateInfo", "Resume"};
tabbedPane.addTab(tabs[0], new Candidate());
tabbedPane.addTab(tabs[1], new Resume());
tabbedPane.setSelectedIndex(0);
add(tabbedPane, BorderLayout.CENTER);

this.setSize(new Dimension(400, 300));
this.setTitle("Frame Title");
}
****It's giving runtime error- IllegalArgumentException:a window added to a conatainer.Can anybody explain me why it's giving this error.

Thanks in advance
Anagha

------------------
 
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah your problem is that your forms extend JFrame (which is an individual window Object and does not extend Component) You need to extend JPanel in these forms to be able to add them as components in a tabbed pane. If they also need to be standalone windows soemtimes, just make a constructor of the form that creates a JFrame and adds itself to the JFrame.
Hope this helps.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic