This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes jtable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "jtable" Watch "jtable" New topic
Author

jtable

keiyia jackson
Ranch Hand

Joined: Jul 16, 2001
Posts: 49
i hava a frame with a refresh button. refresh simply resubmits the current query and updates the table with new info if it is available. well..., my refresh button works, except when i refresh, my columns got to a smaller widht that may be one character long. and if i submit a query the data on the table doesn't change. it leaves all of the data, but because my first query was the default that gets eveything, it only makes those in the new query available to view it's info on the textarea on the other side of my split pane. any suggestions how i can get this info to look and work correctly.
SAFROLE YUTANI
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
I know how you can fix the column problem. Basically, the first time you update the table the column widths are adjusted correctly, but any subsequent update to the table resizes the columns to the uncorrect width, right?
So, here's what you do:
after you update your table model with new data, immediately do the following...
for( int i = 0; i < table.getColumnCount(); i++)
table.sizeColumnsToFit( i);

You may have to initialize your table with a call to the following...
table.setAutoResizeMode( JTable.AUTO_RESIZE_ALL_COLUMNS);
Let me know if that works, email me, I dont check this board much anymore
SAF
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jtable
 
Similar Threads
JTable question
Refreshing/Reloading JSPs when user hits Back button
function of refresh button
Column Names
using of Next and Previous button to display database values