This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JScrollPane inside a JTable cell Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JScrollPane inside a JTable cell " Watch "JScrollPane inside a JTable cell " New topic

JScrollPane inside a JTable cell

Rames Raja

Joined: Jan 27, 2003
Posts: 7
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.
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
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:
I agree. Here's the link:
subject: JScrollPane inside a JTable cell
It's not a secret anymore!