Java Program for JTable: Swing Components

Program:

import javax.swing.*;    
public class TableExample 
{   
 
    JFrame f;    
    TableExample()
        
   
    f=new JFrame(); 
   
    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,400);        
  
    JScrollPane sp=new JScrollPane(jt);    
    f.add(sp);          
    f.setSize(500,270);    
    f.setVisible(true);    
  }  
   
  public static void main(String[] args) {    
    new TableExample();    
  }    
}  


Output:




Comments