Thursday , February 22 2018
Home / java / Java Swing JTable Example

Java Swing JTable Example

In this tutorials, we are going to create a simple JTable with Swing in Java. The Swing JTable is used to display data as regular two dimensional table of cells.

 Java Swing JTable :

package com.swing.examples;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

public class JTableDemo extends JFrame {
    JTable table;

    JTableDemo() {
        super("JTable Demo");
        String headers[] = { "Name", "Address", "Phone", "Experiance" };
        String data[][] = { { "Chandra", "Hyderabad", "4568569568", "true" },
                { "Srikanth", "Vijayawada", "8595652541", "true" },
                { "Rajesh", "Banglore", "8585656545", "false" },
                { "Charan", "Mumbai", "9858654852", "true" },
                { "Kumar", "Pune", "4568569568", "2" },
                { "Venu", "Chennai", "8451265923", "2" },
                { "Gopal", "Vizag", "7845956585", "2" } };

        // Creating JTable with table data and headers
        table = new JTable(data, headers);
        // Adding table to content pane
        getContentPane().add(new JScrollPane(table));
        setSize(500, 150);

    public static void main(String[] args) {
        new JTableDemo();

Output :

Java Swing JTable

Happy Learning 🙂

About chandrashekhar

Hi Folks, you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,


Java String to int conversion Example

In this tutorial we are going to see how to convert Java string to int. …

Leave a Reply

Your email address will not be published. Required fields are marked *