Java Swing JTable Example | Simple JTable Example in Java

PROGRAMMINGJava ExamplesC Examples
Java Examples
C Examples
C Tutorials
aws
JAVAEXCEPTIONSCOLLECTIONSSWINGJDBC
EXCEPTIONS
COLLECTIONS
SWING
JDBC
JAVA 8
SPRING
SPRING BOOT
HIBERNATE
PYTHON
PHP
JQUERY
PROGRAMMINGJava ExamplesC Examples
Java Examples
C Examples
C Tutorials
aws
In this tutorials, we are going to create a simple JTable with Swing in Java. The Swing JTable is used to display data as a regular two-dimensional table of cells.
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);
        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new JTableDemo();
    }
}
Output :
Happy Learning 🙂

Java JList Multiple Selection Example
How to change Look and Feel of Swing setLookAndFeel
Java Swing Advanced JTable Example
Java Swing JLabel Example
Java Swing Login Example
Java Swing JSplitPane Example
Java Swing ProgressBar Example
Java Swing JTabbedPane Example
Java Swing JMenu Example
Java Swing JToolBar Example
Java Swing JOptionPane Example
Java Swing JTree Example
How to create Java Smiley Swing
How to create Java Rainbow using Swing
Java Swing BorderFactory Example

Java JList Multiple Selection Example
How to change Look and Feel of Swing setLookAndFeel
Java Swing Advanced JTable Example
Java Swing JLabel Example
Java Swing Login Example
Java Swing JSplitPane Example
Java Swing ProgressBar Example
Java Swing JTabbedPane Example
Java Swing JMenu Example
Java Swing JToolBar Example
Java Swing JOptionPane Example
Java Swing JTree Example
How to create Java Smiley Swing
How to create Java Rainbow using Swing
Java Swing BorderFactory Example
 


Δ
 Install Java on Mac OS
 Install AWS CLI on Windows
 Install Minikube on Windows
 Install Docker Toolbox on Windows
 Install SOAPUI on Windows
 Install Gradle on Windows
 Install RabbitMQ on Windows
 Install PuTTY on windows
 Install Mysql on Windows
 Install Hibernate Tools in Eclipse
 Install Elasticsearch on Windows
 Install Maven on Windows
 Install Maven on Ubuntu
 Install Maven on Windows Command
 Add OJDBC jar to Maven Repository
 Install Ant on Windows
 Install RabbitMQ on Windows
 Install Apache Kafka on Ubuntu
 Install Apache Kafka on Windows
 Java8 – Install Windows
 Java8 – foreach
 Java8 – forEach with index
 Java8 – Stream Filter Objects
 Java8 – Comparator Userdefined
 Java8 – GroupingBy
 Java8 – SummingInt
 Java8 – walk ReadFiles
 Java8 – JAVA_HOME on Windows
 Howto – Install Java on Mac OS
 Howto – Convert Iterable to Stream
 Howto – Get common elements from two Lists
 Howto – Convert List to String
 Howto – Concatenate Arrays using Stream
 Howto – Remove duplicates from List
 Howto – Filter null values from Stream
 Howto – Convert List to Map
 Howto – Convert Stream to List
 Howto – Sort a Map
 Howto – Filter a Map
 Howto – Get Current UTC Time
 Howto – Verify an Array contains a specific value
 Howto – Convert ArrayList to Array
 Howto – Read File Line By Line
 Howto – Convert Date to LocalDate
 Howto – Merge Streams
 Howto – Resolve NullPointerException in toMap
 Howto -Get Stream count
 Howto – Get Min and Max values in a Stream
 Howto – Convert InputStream to String