-1
tabbedPane = new JTabbedPane();
tabbedPane.addTab( "Page 1", class1);
tabbedPane.addTab( "Page 2", class2);
tabbedPane.addTab( "Page 3", class3);
topPanel.add( tabbedPane, BorderLayout.CENTER );

can i put 3 classes here? How?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • 2
    Huh? Could you expand on your issue a little bit more please? – Craig Dec 30 '13 at 03:27
  • I would like to put different classes in JTabbedPane. is that possible? – user3139706 Dec 30 '13 at 03:29
  • [addTab String, Component](http://docs.oracle.com/javase/7/docs/api/javax/swing/JTabbedPane.html) allows you to add any class that extends [component](http://docs.oracle.com/javase/7/docs/api/java/awt/Component.html) – Craig Dec 30 '13 at 03:30
  • Do you mean different classes extending `Component`? You can't add a class itself, but you can an add instance of a class extending `Component`. – FThompson Dec 30 '13 at 03:31

1 Answers1

1

Start by taking a read through How to Use Tabbed Panes

You can only instance of classes that extend from Component, so assuming your three classes extend from Component, you shouldn't have any issues

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366