LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Horizontal scrolling in a jTable (http://www.linuxquestions.org/questions/programming-9/horizontal-scrolling-in-a-jtable-867723/)

vitorsgoncalves 03-10-2011 09:43 AM

Horizontal scrolling in a jTable
 
I am creating an application in java that uses a jTable for showing some data.
There are multiple columns in that table, an I do not want to show them all at once, so the user slides the horizontal scroll for viewing the remaining columns.

How can I do that?

Snark1994 03-10-2011 10:15 AM

It should be enough to call

Code:

table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

Certainly, this works with the SimpleTableDemo from Oracle (if it doesn't work with your code, perhaps you can post it so we can see why not)
Hope this helps :)

vitorsgoncalves 03-10-2011 10:28 AM

It was so simple... I have searched in the web without success.

Thanks.

Snark1994 03-10-2011 03:39 PM

No worries :D


All times are GMT -5. The time now is 07:22 PM.