JTable header not showing

前端 未结 3 1264
故里飘歌
故里飘歌 2021-01-11 22:59

JTable header not showing...

My JTable header wont show even if add it into a container like JScrollPane...tell me why is it happen and how can i fix it or debug i

3条回答
  •  礼貌的吻别
    2021-01-11 23:15

    Start by removing

    panel.add(table.getTableHeader());
    

    The JTable is designed to add it's header to the JScrollPane. An instance of a component can only belong to a one parent/container, the above line is removing it from the scrollpane

    Also, change this...

    panel.add(table);
    

    To

    panel.add(scrollPane);
    

提交回复
热议问题