This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JScrollPane within JTable cell issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JScrollPane within JTable cell issue" Watch "JScrollPane within JTable cell issue" New topic
Author

JScrollPane within JTable cell issue

Dinuka Arsakularatne
Ranch Hand

Joined: Aug 12, 2006
Posts: 198
Hi guy,

im having a problem with not being able to scroll inside a JTable's cell. I have a cell with JScroll pane added to it. Within that there is a JLabel representing the text to be displayed. But the horizontal scroll bar does not seem to work. Following i have added the test code i have used for this.



Any help in this regard is much appreciated guys. I even looked at the threads here and there was one issue listed here but did not have a clear answer.


if who i am is what i have, and what i have is lost, then who am i?<br /> <br />SCJP 5.0<br />SCWCD 1.4<br />SCBCD preparing
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

A renderer isn't added to any visible component hierarchy and can't receive input events. What you see in a JTable's cells is the image of the renderer component.

Use a custom editor. An editor responds to input events (obviously!)

I even looked at the threads here and there was one issue listed here but did not have a clear answer.

A link to that thread might help us to help you better.


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

Joined: Aug 12, 2006
Posts: 198
Darryl Burke wrote:A renderer isn't added to any visible component hierarchy and can't receive input events. What you see in a JTable's cells is the image of the renderer component.

Use a custom editor. An editor responds to input events (obviously!)

I even looked at the threads here and there was one issue listed here but did not have a clear answer.

A link to that thread might help us to help you better.


Hi Darryl,

Thank you for the prompt response. This is the thread i looked at but could not a get a complete idea on it http://www.coderanch.com/t/335150/GUI/java/JScrollPane-inside-JTable-cell#1483844.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Note that the linked thread suggests the same solution.
Chantal Ackermann wrote:you have to write a custom TableCellEditor for this


So, problem solved?
Dinuka Arsakularatne
Ranch Hand

Joined: Aug 12, 2006
Posts: 198
Darryl Burke wrote:Note that the linked thread suggests the same solution.
Chantal Ackermann wrote:you have to write a custom TableCellEditor for this


So, problem solved?


Hi Daryl,

Im trying it out right now. still was not successful where the horizontal scroll bar wont move. Will try more and post my findings here to find out from you guys what i am doing wrong. Thank you so much for your prompt responses. appreciate it alot.


Dinuka
Dinuka Arsakularatne
Ranch Hand

Joined: Aug 12, 2006
Posts: 198
Hi Daryl

This is the latest example i tried out. Still no luck. Please if you have the time go through the following and let me know what im doing wrong. Your help is much appreciated.

Dinuka Arsakularatne
Ranch Hand

Joined: Aug 12, 2006
Posts: 198
Found the answer guys. This is a working example of scrollable table data cell;

 
Consider Paul's rocket mass heater.
 
subject: JScrollPane within JTable cell issue
 
Similar Threads
JTable inside JScrollPane - background coloring problem
JRadioButton in JTable
JTable cell rendering
JTable is not inserting the data
JCheckBox in JTable