Add a title to a JTable

前端 未结 4 1350
醉酒成梦
醉酒成梦 2021-01-19 07:48

I have a JTable which is created using a TableModel JTable t = new JTable(tableModel) I want to add a title to it. I was hoping for something like t.setTi

4条回答
  •  旧时难觅i
    2021-01-19 08:06

    You can also add your title the JScrollPane which inscribes jtable in it.

    Code:

    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.setBorder(BorderFactory.createTitledBorder ("Table Title"));
    

提交回复
热议问题