This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

JScrollPane within JTable cell issue  RSS feed

 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dinuka Arsakularatne
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found the answer guys. This is a working example of scrollable table data cell;

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!