• Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing Question:Row Width in JTables  RSS feed

 
Susmita Tripathy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am creating a JTable, with a default column width.
Is there any way I can specify the row width. Also when my text is longer than the column width the text shows as "My text...."
Is there any way I can set the cells so that when the text is longer than the column width, the row size increases and the text
gets displayed (Something like the AutoLineWrap).
Thanks a lot
 
deekasha gunwant
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi susmita,
To wrap the text in your cell u'll have to make use of a renderer. what u need to do is write a renderer that extends JTextArea (so that u may have multiple lines in your cell).
and then use
setLineWrap(true);
setWrapStyleWord(true);
method to make sure that the text gets wrapped.
Once the renderer is ready set this renderer for every table column.
here is an example of multilinerenderer

in case u need more help do post back
regards
deeksha

regards
deeksha
 
Susmita Tripathy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot deeksha.
It works.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!