JTable Example Java Swing

JTable Example Java Swing

JTable displays data in horizontal and vertical columns in a two-dimensional format. The table can be resized or moved. Here, table is created and added to a scroll pane. In turn, scroll pane is added to the container.

We create a JTable and add it to a scroll pane. Then, scroll pane is added to the container.

Following is the HTML file to run the above JApplet

Output screen on JTable Example

JTable jt = new JTable(details, fields);

The JTable constructor takes the column data and column headers as parameters. The columns in JTable can be slided by dragging the column name.

Other options for ScrollPaneConstants:

Similarly for horizontal scroll bar also.

Leave a Reply

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