0

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);
        
    }
}
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by masijade
0

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.

Edited by masijade: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.