Java examples for Swing:JTable Scroll
Showing the Table Header in a Non-Scrollable JTable Component
import java.awt.BorderLayout; import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.table.JTableHeader; public class Main { public void m() throws Exception { int rows = 10; int cols = 5; JTable table = new JTable(rows, cols); JTableHeader header = table.getTableHeader(); JPanel container = new JPanel(); container.setLayout(new BorderLayout()); // Add header in NORTH slot container.add(header, BorderLayout.NORTH); // Add table itself to CENTER slot container.add(table, BorderLayout.CENTER); }/* w w w. java 2 s. co m*/ }