How to create simple table in Java Swing

A Table is used to display data in the form of rows and columns. It can allow editing of data which is optional. By default, the columns of a table can be resized.


It can be accomplished by dragging the mouse along with their boundaries. The columns can also be dragged to a new position. A table is an object of class JTable which is a subclass of JComponent.



import javax.swing.*;

class swingtable extends JApplet


      public static void main(String aa[])


              JFrame jff=new JFrame("Table Demo");

               String dataa[][]={{"1","Pooja","90%"},










    String fields[]={"Roll No","Student Name","Percentage"};

     JTable jtt=new JTable(dataa,fields);

    JScrollPane panee=new JScrollPane(jtt);







Simple Table in Java Swing