• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JScrollPane inside a JTable cell

 
Rames Raja
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am in an urgent need to implement a JTable where each cells will contain multiline text. When text content exceeds my cell size I want a JScrollbar to appear so that I can see the entire content inside my table cell.
I desperately need help on this, please help me out.
many thanks in advance.
Ramesh
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
extend JPanel or JScrollPane (or some custom component) and implement the TableCellRenderer (see the source of DefaultTableCellRenderer for performance issues!)
you have to set the row height of the JTable appropriately or it will be to small.
moreover, the mouse events have to be transmitted to the scrollpane:
you have to write a custom TableCellEditor for this:

see this page for a more general sample:
http://www.codeguru.com/java/articles/162.shtml
Chantal
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic