column header not visible in my JTable i have created a JPanel and added the JTable to the JPanel.
Object rowData[][] = { { "Row1-Column1", "Row1-Column2", "Row1-Column3"}, { "Row2-Column1", "Row2-Column2", "Row2-Column3"} }; Object columnNames[] = { "Column One", "Column Two", "Column Three"}; JTable jTable = new JTable(rowData, columnNames);
The DefaultTableCellRenderer class can extend JLabel class and it can be used to add images, colored text and etc. inside the JTable cell. We can hide the table header of a JTable by unchecking the JCheckBox and show the table header of a JTable by clicking the JCheckBox.
The API for JTable states:
"Note that if you wish to use a JTable in a standalone view (outside of a JScrollPane) and want the header displayed, you can get it using getTableHeader() and display it separately."
Or just add the table to a scrollpane, and add your scrollpane to the panel...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With