Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

compilation error ,ListCellRenderer implementaion for Jtable  RSS feed

mohana konakanchi
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to use this sample which is there on java doc.
But I am getting a compilation error as:
The method Component getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean) declared in class MyCellRenderer cannot override the method of the same signature declared in interface javax.swing.ListCellRenderer. They must have the same return type.

I am puzzled any help?
import javax.swing.*;
class MyCellRenderer extends JLabel implements ListCellRenderer {
//final static ImageIcon longIcon = new ImageIcon("long.gif");
// final static ImageIcon shortIcon = new ImageIcon("short.gif");
// This is the only method defined by ListCellRenderer. We just
// reconfigure the Jlabel each time we're called.
public MyCellRenderer() {
public Component getListCellRendererComponent(
JList list,
Object value, // value to display
int index, // cell index
boolean isSelected, // is the cell selected
boolean cellHasFocus) // the list and the cell have the focus
//String s = value.toString();
//setIcon((s.length() > 10) ? longIcon : shortIcon);
if (isSelected) {
else {
return (this);
thanks in advance,
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!