File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to show a long description in a jtable ?

 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a requirement where my user enter a long description about a product or tender , but when i display that in a jtable then only half part is displayed and rest is shown in this way ....
with dots
can you suggest me a alternative where i can show this description in full details the way my user have entered it ?
 
Riaan Nel
Ranch Hand
Posts: 160
IntelliJ IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not show the full description in a tooltip popup when the user hovers over the description column?
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Custom renderer/editor that uses a JTextArea.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Naved,
I suggest attaching a JPopupMenu to the table cell containing the description.
The popup menu would have a "Show All" item.
Choosing that item would display a dialog window with a scrollable JTextArea displaying the entire description.

Also note that if you try the tooltip option that Riaan suggested, I suggest you use HTML to format the tooltip text because you may end up with a tooltip that stretches wider than the screen which would result in still not being able to view the entire description.
(Speaking from experience :-)

Good Luck,
Avi.
 
Rob Camick
Ranch Hand
Posts: 2473
8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I like the tool tip suggestion.

Otherwise if you want to see the entire text you need to change the width of the column. However I would only use this approach when you have a reasonable maximum size, say 30-50 characters. If you are going to enter multiple sentences then you need another approach. the Table Column Adjuster can do the column resizing automatically.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic