I have the following JTable in my program which is placed inside a JScrollPane. I made it using the GUI builder provided by Netbeans.
The problem is some of the columns in the table is not visible and there is no horizontal scroll bar. I even set the horizontalScrollBarPolicy to ALWAYS and it didnt help. So how do I make the table scrollable?
As @Andrew Thompson mentiond you should provide some code that addresses the problem. Without seeing your code it's hard to find out what's the problem. But a common workaround about that is as the following:
If you have correctly added your JTable
to the ViewPort
of a JScrollPane
like this:
JTable jtable = new JTable();
//...
JScrollPane sc = new JScrollPane(jtable);
//sc.setViewportView(jtable); <- This way is correct too
//
getContentPane().add(sc);
Then the most probable problem is about the AutoResizeMode
of your JTable
. Try this:
jtable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
Hope this would help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.