import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;
public class MainClass {
public static void main(final String args[]) {
final Object rows[][] = { { "one", "1" }, { "two", "2" },
{ "three", "3" } };
final String headers[] = { "English", "Digit" };
TableModel fixedColumnModel = new AbstractTableModel() {
public int getColumnCount() {
return 2;
}
public String getColumnName(int column) {
return headers[column];
}
public int getRowCount() {
return 3;
}
public Object getValueAt(int row, int column) {
return rows[row][column];
}
};
JFrame frame = new JFrame("Scrollless Table");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTable table = new JTable(fixedColumnModel);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
frame.add(new JScrollPane(table), BorderLayout.CENTER);
frame.setSize(300, 150);
frame.setVisible(true);
}
}