Use JScrollPane
and add the JTable
in it.
JScrollPane scrollPane = new JScrollPane(table);
Try this one also if you want to show the scroll bar as per your requirement.
JScrollPane scrollPaneChatHistory = new JScrollPane(table,
JScrollPane.VERTICAL_SCROLLBAR_NEVER,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
--EDIT--
Try
table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
For more info have a look at Auto resizing the JTable column widths.