JTable scrolling issue

R

Ray.Jaramillo

I have a JTable in a JScrollPane but I do not want the first two
colums to scroll when I move the scroll bar. I want the first two
columns to stay on the screen and the rest of the columns in my JTable
to scroll. Is there any way to make the first two columns permanent??
I have looked around and can't seem to come up with any answer besides
putting them in seperate JScrollPanes, but I want the scroll bar to
span the entire Pane.

Thank you ahead for any help,

Ray
 
D

Daniel Pitts

I have a JTable in a JScrollPane but I do not want the first two
colums to scroll when I move the scroll bar. I want the first two
columns to stay on the screen and the rest of the columns in my JTable
to scroll. Is there any way to make the first two columns permanent??
I have looked around and can't seem to come up with any answer besides
putting them in seperate JScrollPanes, but I want the scroll bar to
span the entire Pane.

Thank you ahead for any help,

Ray

I'm not quite sure what your asking... Perhaps you want two tables,
one that scrolls and one that doesn't?

JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(permanentTable, BorderLayout.WEST);
panel.add(new JScrollPane(scrollingTable), BorderLayout.CENTER);
 
J

Joshua Cranmer

I have a JTable in a JScrollPane but I do not want the first two
colums to scroll when I move the scroll bar. I want the first two
columns to stay on the screen and the rest of the columns in my JTable
to scroll. Is there any way to make the first two columns permanent??
I have looked around and can't seem to come up with any answer besides
putting them in seperate JScrollPanes, but I want the scroll bar to
span the entire Pane.

Thank you ahead for any help,

Ray
Somewhere in the JTable class, there is a protected method that prepares
the table for a scroll pane (something along the lines of
prepareTable()). If you fiddle with that and ColumnModels, you should be
able to get what you want.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top