Java Program for TabbedPane: Swing Component

Program:

import javax.swing.*;  
import java.awt.FlowLayout;
public class TabbedPaneExample 
{  
    JFrame f;  
    TabbedPaneExample(){  
    f=new JFrame();  
    //creating JTable
    String data[][]={ {"MIT College","Pune","No"},    
                          {"Government Polytechnic, Pune","Pune","Yes"},    
                          {"Government Polytechnic, Satara","SAtara","Yes"}};    
    String column[]={"College","City","Autonomous"};         
    JTable jt=new JTable(data,column); 
    jt.setBounds(30,40,200,300);          
    JScrollPane sp=new JScrollPane(jt);  
    JTextArea ta=new JTextArea(100,100);  
    JPanel p1=new JPanel();  
    p1.add(ta);  
    JPanel p2=new JPanel();  
    p2.add(jt);
    JPanel p3=new JPanel(); 
    JTabbedPane tp=new JTabbedPane();  
    tp.setBounds(50,50,300,300);  
    tp.add("TextArea",p1);  
    tp.add("JTable",p2);  
    tp.add("Blank",p3);   
    f.add(tp);  
    f.setSize(400,400);  
    f.setLayout(null);  
    f.setVisible(true);  
    }  
    public static void main(String[] args) {  
    new TabbedPaneExample();  
    }
}  



Output:

Tab1:

                 

Tab2:
                 

Tab3:

                 



















Comments