We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,322 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

How to resize table of database in swing frame.

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
2 Days
Discussion Span
8 Months Ago
Last Updated
5
Views
heenakashyap
Newbie Poster
3 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 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?

JamesCherrill
... trying to help
Moderator
8,526 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,456
Skill Endorsements: 30

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

heenakashyap
Newbie Poster
3 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

AUTO_RESIZE_ALL_COLUMNS does that anyway. But what do you want to do when the text is too long?

JamesCherrill
... trying to help
Moderator
8,526 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,456
Skill Endorsements: 30

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.

heenakashyap
Newbie Poster
3 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0725 seconds using 2.77MB