Browsing all posts in "java table".

A Table with Row Headers

// RowHeaderTable.java
//
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
public class RowHeaderTable extends JFrame {
public RowHeaderTable( ) {
super(”Row Header Test”);
setSize(300, 200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
TableModel tm = new AbstractTableModel( ) {
String data[] = {””, “a”, “b”, “c”, “d”, “e”};
[...]

Tables in Java

This program was generated with very little code. All we did was set up a JTable object with a String[][] argument for the table data and a String[] argument for the table’s headers. Rather than adding the table itself directly to our window, we enclose it in a scrollpane:
here the code:
// SimpleTable.java
// A test [...]