Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2006

Tip: Looking for answers? Try searching our database.

jlabel in a jtable

Thread view: 
6e - 04 Jan 2006 20:45 GMT
Hi,

I have created a custom tablecellrenderer of type jlabel.  Before that
I left it to the default.

However now that I have a custom tablecellrenderer, the cell no longer
gets highlighted when the user selects the row!

Silly little problem.  and ideas?
pit.grinja@gmx.de - 06 Jan 2006 08:22 GMT
Hi,
> I have created a custom tablecellrenderer of type jlabel.  Before that
> I left it to the default.
>
> However now that I have a custom tablecellrenderer, the cell no longer
> gets highlighted when the user selects the row!
have a look at
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/table/TableCellRenderer.html.
The method that is responsible for creating and returning the component
used for rendering accepts a boolean parameter that tells you whether
the cell is selected or not. It is your job to use that information, in
other words, you have to differentiate between "selected" and
"unselected" cells in your code and define appropriate rendering. E. g.
when you use a JLabel for  rendering, you could have something like:

JLabel rendererComponent = new JLabel();
if (isSelected) rendererComponent.setBackground(Color.RED);

to mark selected Cells with red.
If you don´t check the selection state of the cell, than I think you
won´t get any highlighting.
HTH,Piet


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.