Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!69.16.185.11.MISMATCH!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!news-in-01.newsfeed.easynews.com!easynews.com!easynews!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail From: "Bart Cremers" Subject: Re: setCellRenderer for s Message-ID: <1165218307.459551.49220@73g2000cwn.googlegroups.com> X-Comment-To: comp.lang.java.gui Newsgroups: comp.lang.java.gui In-Reply-To: <1165203956.958986.34320@79g2000cws.googlegroups.com> References: <1165203956.958986.34320@79g2000cws.googlegroups.com> Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] Lines: 46 Date: Wed, 27 Apr 2011 15:26:50 GMT NNTP-Posting-Host: 96.60.20.240 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1303918010 96.60.20.240 (Wed, 27 Apr 2011 10:26:50 CDT) NNTP-Posting-Date: Wed, 27 Apr 2011 10:26:50 CDT Organization: TDS.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:317 To: comp.lang.java.gui Nickolay Cherkezishvili wrote: > Bart Cremers wrote: > > terpatwork@hotmail.com wrote: > > > Hi, > > > I'm working on JTable ->HTML Table representations and I'm trying to > > > figure out how to set a CellRenderer for a specific cell, rather than > ............................ > > } > > /* End sample code */ > > } > > > > > > Regards, > > > > Bart > > That's very nice solution, but there is too many code in one class :) > what about another solution: > > Making many single renderers for each cell type, then overriding > JTable.getCellRenderer(int,int) - overriden function should return > specific renderer ;) > > I use this method because it's much cleaner I can't see where there are to many lines in one class. Dropping the sample code from the renderer you're left with 25 lines of code, which is a rather small class in my opinion. There are two reason why I wouldn't go for overriding getCellRenderer in this case. First, the cellrenderer returned should be specified by the class of the value. It's much cleaner to go through a renderer subclass in this case. The second is, I simply don't like to subclass Swing components unless there is no other way. Regards, Bart --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24