package sap;
import java.awt.ScrollPane;
import java.util.ArrayList;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
public class GetData {
public static void main(String[] args) throws Exception {
// Main Container
JFrame containerFrame = new JFrame();
containerFrame.setSize(800, 600);
ArrayList<String> coloumnnameArrayList= new ArrayList<>();
ArrayList<String[]> rowdatArrayList = new ArrayList<>();
// populate coloumn data
coloumnnameArrayList.add("code");
coloumnnameArrayList.add("description");
coloumnnameArrayList.add("stock");
// populate row data
for (int i = 0; i < 100; i++) {
rowdatArrayList.add( new String [] {"123","ashik","45"});
}
TableModel tableModel = new DefaultTableModel(rowdatArrayList.toArray(new Object [][] {}),coloumnnameArrayList.toArray());
JTable jTable = new JTable(tableModel);
JScrollPane scrollPane = new JScrollPane(jTable);
containerFrame.add(scrollPane);
containerFrame.setVisible(true);
}
}