Search code examples
javaswingjtablejtableheaderheader-row

How do I display the header row in a JTable that uses AutoBinding against model


For some reason my header row is not visible. I am using SwingBindings.createJTableBinding to bind a pojo to the table. My table is showing all the rows however the header row is not visible.

If I inspect the JTableHeader in the table is there and its columns have names as expected. The JTable header properties: isEnabled and isVisible are set to true.

Is there something I am missing?


Solution

  • I don't know what SwingBindings.createJTableBinding is, but when you use Swing you add the table to a JScrollPane. The table header is then used as the column header view of the scrollpane.

    If you are not using a JScrollPane, then you need to create a JPanel using a BorderLayout. The table is added to the CENTER and the table header is added to the NORTH.