I'm writing an application that has 5 or 6 classes. I want to set up the application in a JTabbedPane. At this moment, each class has its own JFrame & contentPane. I have tried to combine all of these into a JTabbedPane with no success. I think I have to extend JFrame in the MainTab class (the class with the JTabbedPane)and extend JPanel for the rest of the classes.
I also have to get rid of the JFrame in each of the other classes and then create an instance of a class within one of the tabs. I can't seem to be able to bring the other classes into one of the panels in MainTab.
I guess My question is how do I create in instance of another class and bring it into a certain tab(panel)
Here the code that i have tried & commented out & rewrote too many times to count.
I'm sure that it is something very stupid that i'm doing wrong.
Unfortunely, at this moment my system is out of resources & won't let me compile this code.
Thanks in Advance
Shannon
import java.sql.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
//declare the public class
public class MainTab extends JFrame
{
public JPanel p1,p2,p3,p4,p5;
public JLabel l1;
public JTabbedPane tp1;
public JFrame f1;
public Container contentPane;
public void draw()
{
tp1=new JTabbedPane();
l1=new JLabel("Test");
p1=new JPanel();
p2=new JPanel();
p3=new JPanel();
p4=new JPanel();
p5=new JPanel();
tp1.addTab("Log-In",p1);
tp1.setSelectedIndex(0);
Client c1=new Client();
tp1.addTab("Client",p2,c1);
tp1.addTab("Property",p4);
tp1.addTab("Search",p5);
f1=new JFrame("Sell My Home Realtors");
contentPane=f1.getContentPane();
contentPane.add(tp1,BorderLayout.CENTER);
//set the frame size and make it visible
f1.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);}});
f1.setSize(700,500);
//f1.pack();
f1.setVisible(true);
}
public static void main(
String []args)
{
MainTab mt1=new MainTab();
mt1.draw();
}
}