I have several classes(all in swing). How can I put all the classes that I have create into tabbed Pane?
I have 4 class:
Intro in=new Intro();
Hist his=new Hist();
Product pro=new Product();
Contact con=new Contact();

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

public class MainControl extends JFrame {
    
    public MainControl() {
        
        setTitle("Fruits ordering system.");
        JTabbedPane jtp = new JTabbedPane();
        getContentPane().add(jtp);
        
        Intro in=new Intro();//class
        Hist his=new Hist();//class
        
        JLabel label1 = new JLabel();
        label1.setText("Introduction");
        JLabel label2 = new JLabel();
        label2.setText("History");
        in.add(label1);
        his.add(label2);
        jtp.addTab("Tab1", in);
        jtp.addTab("Tab2", his);
        
    }
    public static void main(String[] args) {
        
        TabbedPane tp = new TabbedPane();
        tp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        tp.setVisible(true);
        
    }
}

Change those classes to use JPanels rather than JFrames.

Edit: Better (although you probably wouldn't comprehend it, yet) is to extend JComponent and override any method that you dont wan't to be able to have effect your component.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.