This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes how to show a long description in a jtable ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to show a long description in a jtable ?" Watch "how to show a long description in a jtable ?" New topic
Author

how to show a long description in a jtable ?

naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 688

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 ?


The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Riaan Nel
Ranch Hand

Joined: Apr 23, 2009
Posts: 157

Why not show the full description in a tooltip popup when the user hovers over the description column?


"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." - George Bernard Shaw
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Custom renderer/editor that uses a JTextArea.


luck, db
There are no new questions, but there may be new answers.
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1121

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

Joined: Jun 13, 2009
Posts: 2156
    
    7
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.
 
subject: how to show a long description in a jtable ?
 
Similar Threads
JTable
JTable(!!!)
JTable help
JTable
JTable