| Author |
How to wrap column name in swing
|
rahul S Sharma
Greenhorn
Joined: Jun 08, 2011
Posts: 21
|
|
Hi Folks,
I am fetching some data from database and showing it in jtable by using AbstractTableModel. Now the columns which I am fetching has some long description like 'Payment Method' is showing 'Payment Met...'. How can I wrap those column name . Please suggest me some solution.
regards......
|
 |
Matthew Brown
Bartender
Joined: Apr 06, 2010
Posts: 3793
|
|
You could try using HTML. I think JTables use JLabels as cell renderers by default, and they'll wrap HTML text, or let you put your own line breaks in. So try setting the column title to "<html>Payment<br>Method</html>"
Failing that, I think you need to supply your own TableCellRenderer, and use a component that will do what you want. You can change the renderer for a single column by using table.getTableColumn(...).setHeaderRenderer(...), or for all the headers at once using table.getTableHeader().setDefaultRenderer(...).
See http://download.oracle.com/javase/tutorial/uiswing/components/table.html#renderer for more about using custom renderers in tables.
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8436
|
|
|
Try
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
 |
|
|
subject: How to wrap column name in swing
|
|
|