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 / February 2005

Tip: Looking for answers? Try searching our database.

cell rendering in JTable

Thread view: 
datta patkar - 11 Feb 2005 10:41 GMT
I am trying to render the single cell of the JTable
with the another JTable. so that it gives look & feel of
cascaded tables (as in MS excel or word)
can any one help me out with the sample code?
Michael Klaus - 11 Feb 2005 20:45 GMT
> I am trying to render the single cell of the JTable
> with the another JTable. so that it gives look & feel of
> cascaded tables (as in MS excel or word)

This CellRenderer should do the trick:

public class ComponentRenderer implements TableCellRenderer {
       public Component getTableCellRendererComponent(JTable table, Object value,
                       boolean isSelected, boolean hasFocus, int row, int column) {
               if( value instanceof Component )
                       return (Component)value;
               return new JLabel(value.toString());
       }
}

Register it at your table-containing table with
       setDefaultCellRenderer(Object.class, new ComponentRenderer())
and you're clean.


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.