Jtable in java swing

    how to create table in java swing
    how to create table in swing
    java swing how to use tables
  1. How to create table in java swing
  2. Java table data structure...

    Swing Examples - Creating Table



    Following example showcase how to create a table in a Java Swing application.

    We are using the following APIs.

    • JTable(Object[][] data, String[] columnNames) − To create a table.

    Example

    import java.awt.FlowLayout; import java.awt.GridLayout; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; public class SwingTester { private JFrame mainFrame; private JLabel headerLabel; private JLabel statusLabel; private JPanel controlPanel; public SwingTester(){ prepareGUI(); } public static void main(String[] args){ SwingTester swingControlDemo = new SwingTester(); swingControlDemo.showTableDemo(); } private void prepareGUI(){ mainFrame = new JFrame("Java Swing Examples"); mainFrame.setSize(500,400); mainFrame.setLayout(new GridLayout(3, 1)); mainFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent){ System.exit(0); } }); headerLabel = new JLa