Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Swing Question:Row Width in JTables

 
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
 
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.
 
So you made a portal in time and started grabbing people. This tiny ad thinks that's rude:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic