JTables within JScrollPanes

I am attempting to display data within JTable objects where the JTables provide verticle and horizontal scrollbars when exceeding the preferredScrollableViewPortSize. I've done this many times when designing the UI myself, but I haven't quite figured out the necessary steps using the GUI Builder.

I am successful displaying a JList within a JScrollPane, but have not been able to configure a JTable the same way. When you add a JList object over a JScrollPane, it will take the shape/size of the JScrollPane selected, a JTable will not; is this something by design, or are there additional JTable attribute settings required to achieve this?

If anyone can help, or lead me in a new direction, it would be greatly appreciated.

Thanks,
tlb

2 comments
Comment actions Permalink

Lane Burris wrote:

I am attempting to display data within JTable objects where the JTables provide verticle and horizontal scrollbars when exceeding the preferredScrollableViewPortSize. I've done this many times when designing the UI myself, but I haven't quite figured out the necessary steps using the GUI Builder.

I am successful displaying a JList within a JScrollPane, but have not been able to configure a JTable the same way. When you add a JList object over a JScrollPane, it will take the shape/size of the JScrollPane selected, a JTable will not; is this something by design, or are there additional JTable attribute settings required to achieve this?

If anyone can help, or lead me in a new direction, it would be greatly appreciated.

Thanks,
tlb


you have to set model to JTable

--
Vladimir Kondratyev
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Thanks for the direction.

I was actually doing what you stated, but was implementing problems on my own by adding the table/component manually to the JScrollPane. I now have the understanding that this is something already handled by design of the GUI Builder, and in calling the .add(JTable) method of the JScrollPane object, the table results will not display. Either way, I've got it working now...

Again, thanks for your time and input.
tlb

0

Please sign in to leave a comment.