Table.scrollPaneBorder
import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JViewport;
import javax.swing.UIManager;
public class MainClass {
public static void main(String args[]) {
Object rows[][] = { { "A", "a" }, { "B", "b" }, { "E", "e" } };
Object headers[] = { "Upper", "Lower" };
JTable table = new JTable(rows, headers);
table.setTableHeader(null);
JScrollPane scrollPane = new JScrollPane(table);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(scrollPane, BorderLayout.CENTER);
frame.setSize(300, 150);
frame.setVisible(true);
}
}
class HeaderlessTable extends JTable {
public HeaderlessTable(Object rowData[][], Object columnNames[]) {
super(rowData, columnNames);
}
protected void configureEnclosingScrollPane() {
Container container = getParent();
if (container instanceof JViewport) {
Container viewParent = container.getParent();
if (viewParent instanceof JScrollPane) {
JScrollPane scrollPane = (JScrollPane)viewParent;
JViewport viewport = scrollPane.getViewport();
if (viewport == null || viewport.getView() != this) {
return;
}
scrollPane.setBorder(UIManager.getBorder("Table.scrollPaneBorder"));
}
}
}
}
Related examples in the same category
1. | TableHeader.cellBorder | | |
2. | JTable.AUTO_RESIZE_ALL_COLUMNS | | |
3. | JTable.AUTO_RESIZE_LAST_COLUMN | | |
4. | JTable.AUTO_RESIZE_NEXT_COLUMN | | |
5. | JTable.AUTO_RESIZE_OFF | | |
6. | JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS | | |
7. | new JTable(Object name, Object[][] data) | | |
8. | new JTable(TableModel dm) | | |
9. | new JTable(Vector rowData, Vector columnNames) | | |
10. | JTable: addColumnSelectionInterval(int index0, int index1) | | |
11. | JTable: changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) | | |
12. | JTable: clearSelection() | | |
13. | JTable: configureEnclosingScrollPane() 'Headerless Table' | | |
14. | JTable: createDefaultColumnsFromModel() | | |
15. | JTable: getCellSelectionEnabled() | | |
16. | JTable: getColumnCount() | | |
17. | JTable: getColumnModel() | | |
18. | JTable: getColumnSelectionAllowed() | | |
19. | JTable: getIntercellSpacing() | | |
20. | JTable: getRowCount() | | |
21. | JTable: getRowSelectionAllowed() | | |
22. | JTable: getSelectedColumns() | | |
23. | JTable: getSelectedRows() | | |
24. | JTable: getSelectionModel() | | |
25. | JTable: getTableHeader() | | |
26. | JTable: getValueAt(int row, int column) | | |
27. | JTable: isCellSelected(int row, int column) | | |
28. | JTable: moveColumn(int column, int targetColumn) | | |
29. | JTable: print() | | |
30. | JTable: print(PrintMode p, MessageFormat hFormat, MessageFormat fFormat) | | |
31. | JTable: removeColumn(TableColumn aColumn) | | |
32. | JTable: removeColumnSelectionInterval(int index0, int index1) | | |
33. | JTable: removeRowSelectionInterval(int index0, int index1) | | |
34. | JTable: selectAll() | | |
35. | JTable: setAutoCreateColumnsFromModel(boolean autoCreateColumnsFromModel) | | |
36. | JTable: setAutoResizeMode(int m) | | |
37. | JTable: setCellSelectionEnabled(boolean cellSelectionEnabled) | | |
38. | JTable: setColumnSelectionAllowed(boolean columnSelectionAllowed) | | |
39. | JTable: setDefaultEditor(Class columnClass, TableCellEditor editor)
| | |
40. | JTable: setDefaultRenderer(Class columnClass, TableCellRenderer renderer) | | |
41. | JTable: setFocusable(boolean focusable) | | |
42. | JTable: setGridColor(Color gridColor) | | |
43. | JTable: setIntercellSpacing(Dimension intercellSpacing) | | |
44. | JTable: setPreferredScrollableViewportSize(Dimension size) | | |
45. | JTable: setRowHeight(int rowHeight) | | |
46. | JTable: setRowSelectionAllowed(boolean rowSelectionAllowed) | | |
47. | JTable: setRowSelectionInterval(int index0, int index1) | | |
48. | JTable: setRowSorter(RowSorter extends TableModel> arg0) | | |
49. | JTable: setSelectionMode(int m) | | |
50. | JTable: setShowGrid(boolean showGrid) | | |
51. | JTable: setShowHorizontalLines(boolean showHorizontalLines) | | |
52. | JTable: setTableHeader(JTableHeader tableHeader) | | |
53. | JTable: setShowVerticalLines(boolean showVerticalLines) | | |
54. | JTable: setValueAt(Object aValue, int row, int column) | | |