From: Ajit Bhingarkar [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 08, 2002 2:21 PM
To: Bhangale Bhushan
Cc: 'Advanced-Swing'
Subject: Re: resize jtable column width
It should be very close, if not same as pixel width for the String in a
specific font. You can obtain an instance of FontMetrics from
Toolkit implementation or from a Component (table cell renderer).
Hope this helps.
- Ajit
"Bhangale, Bhushan" wrote:
Hi All,I am trying implement a utility in JTable by which when a person clicks on the column header, the whole column should resize according to the cell which has lengthiest data. If you have seen this in MS Excel where by clicking on the column this happens. I want the same thing.Is there anyway already defined in javax.swing?I have added a Mouselistener on Tableheader and when the person clicks on a column header, I first finds out the column index. Now on that column index scan the whole column for the lengthiest data. After finding the lengthiest data I set the preferred width for that column and call doLayout on the table object. In this case the problem is of font as the font is not fixed width. The multiplication factor which returns the pixel doesn't gives the right pixel width. Is there any way by which I can find pixel width of a String? Thanks & Regards
Bhushan Bhangale
Sr. Software Engineer
Fusion Infotech India Private Ltd.
Ph. no. - 1-212-641-6932 (O), 1-732-906-5730 (R)
"The information in this e-mail, and any attachment therein, is
confidential and for use by the addressee only. If you are not the
intended recipient, please return the e-mail to the sender and delete
it from your computer. Although The Bank of New York attempts to
sweep e-mail and attachments for viruses, it does not guarantee that
either are virus-free and accepts no liability for any damage sustained
as a result of viruses."
"The information in this e-mail, and any attachment therein, is
confidential and for use by the addressee only. If you are not the
intended recipient, please return the e-mail to the sender and delete
it from your computer. Although The Bank of New York attempts to
sweep e-mail and attachments for viruses, it does not guarantee that
either are virus-free and accepts no liability for any damage sustained
as a result of viruses."
