Hi, I'd like to be able to put a JTable inside a ScrollPane, so that when the table is large, the horizontal and/or vertical scrollbars 'kick in', and when the JTable is small, I just get a small JTable.
Also I want to limit the size of the scrollpane to say 500 by 500.

I can sort of do it by using the number of rows and columns and cell sizes to work out the full table size, then if this is bigger than 500 by 500, I place it in a scrollpane of that size.
But it gets messy with say just 1 horizontal scrollbar, I cannot see all the rows as the scrollbar takes up space.

Is there a simple way to do this. Thanks for any help

Place it in a JScrollPane to begin with. You should always have it in the Scroll Pane and set the Scroll Pane up so that it sizes how you want to. Don't keep putting it in and taking it out. See how to size a scroll pane

Place it in a JScrollPane to begin with. You should always have it in the Scroll Pane and set the Scroll Pane up so that it sizes how you want to. Don't keep putting it in and taking it out. See how to size a scroll pane

Thanks, but that doesn't help. What happens when I add rows/columns, its not gonna work. I can do it by totally rebuilding the whole thing when I add a row/column, but thats not ideal.

Can you offer any more advice?

Thanks, but that doesn't help. What happens when I add rows/columns, its not gonna work. I can do it by totally rebuilding the whole thing when I add a row/column, but thats not ideal.

Can you offer any more advice?

Sorry, I'm wrong, theres a app with circles on the link you sent, that should be sufficient for me, I think.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.