0

I am trying to resize the widths of the columns in a JTable.
I would need to resize them when the program is running to see the full column header names.
I want to resize table of database showing in swing frame.

I have tried

table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS)

But i dont get the desired output becouse when i use this i have a horizontal scrollbar to scroll to the columns that are off screen. But i want that the size of the whole table should become approximately equal to the size of frame.

How can I make the columns as wide as they need to be to display all the text?
Please answer as soon as possible.

2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by heenakashyap
0

You seem to be asking for two things:
1. Make the table wide enough to show all the text
2. Make the table fit in the frame without scrolling
You can't have both when the text is long, so what is your single requirement?

0

I want to make the table wide enough to show whole text without scrolling when text is not too long.

0

I have tried this already

table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS)

Also my text is not too long. I just want to display the table to full dimension of the frame (width). I don't want to use any scroll bar at all.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.