2
@Override
public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected,
        boolean hasFocus, int row, int col) {

    // *** here  *** 
    Component c = super.getTableCellRendererComponent(table, value, isSelected, 
               hasFocus, row, col); 

    // Formatting here
    return c;
}

I'm getting an error in the indicated line. It says "cannot find symbol" but I can't realize what the real problem is.


Updated

@martinusadyh

I'm afraid the class is too big so it doesn't allow me to paste it here.

@ Hovercraft Full Of Eels

here's the error in Netbeans
https://i.stack.imgur.com/R4fv3.jpg

@Henery

It's not my class. I'm only implementing an interface method.

Gray
  • 115,027
  • 24
  • 293
  • 354
Maxi Dee
  • 61
  • 2
  • 6
  • 6
    Please show the actual text of the error message in your post above. Does it say more than "cannot find symbol"? Every bit of information is essential. – Hovercraft Full Of Eels Nov 05 '11 at 14:44
  • And you can't **bold** posted code. – Hovercraft Full Of Eels Nov 05 '11 at 14:46
  • Did you make sure that your super class contain the exact method getTableCellRendererComponent with the same signature? – Bhavesh Nov 05 '11 at 14:51
  • 1
    @Maxi Dee: can you paste your full source code ? I mean, we need to know which class you implemented or extend. – martinusadyh Nov 05 '11 at 14:53
  • @martinusadyh I'm afraid the class it's too big so it doesnt allow me to paste it here. – Maxi Dee Nov 05 '11 at 15:14
  • @martinusadyh I'm afraid the class it's too big so it doesnt allow me to paste it here. – Maxi Dee Nov 05 '11 at 15:14
  • PLEASE! Do me (and yourself) a favour and put the font of NetBeans to something **Monospaced**... – Martijn Courteaux Nov 05 '11 at 15:14
  • 1
    In which class this method getTableCellRendererComponent() is implemented? or at least say which class you are extending if such is a case? – Bhavesh Nov 05 '11 at 15:14
  • @ Hovercraft Full Of Eels here's the error in Netbeans h t t p : / / i. stack.i mgur.com/R4fv3.jpg – Maxi Dee Nov 05 '11 at 15:16
  • @martinusadyh done, here's the code h t t p://pastebin.com/m7QnkUMC its too big to paste it here. – Maxi Dee Nov 05 '11 at 15:21
  • @MaxiDee: that's why you shouldn't try to have a class do too much. Your class extends JPanel and implements TableCellRenderer, but JPanel doesn't have the super method. Perhaps you want your class to extend DefaultTableCellRenderer. – Hovercraft Full Of Eels Nov 05 '11 at 15:37
  • @MaxiDee you get error because `super` in your method calling JPanel class, and JPanel don't have method `getTableCellRendererComponent()`. If you want to do some custom rendering to your JTable, why you do not implemented in your method in this class ? Why you must call `super` ??? – martinusadyh Nov 05 '11 at 15:38

2 Answers2

3

It's not mine that class, i'm only implementing an interface's method.

Then your parent class super is Object and has no method getTableCellRendererComponent. You either have to extend a suitable class or get along without calling non-existing methods.

A.H.
  • 63,967
  • 15
  • 92
  • 126
2

You have to extends DefaultTableCellRenderer instead of implements TableCellRenderer.


Note: DefaultTableCellRenderer its method getTableCellRendererComponent returns this. This means that it's enough to call the super.getTableCellRendererComponent(); without assigning it to a local variable. Because the local variable equals this. Maybe my explanation is too difficult: example.

public class MyTableCellRenderer extends DefaultTableCellRenderer
{

    @Override
    public Component getTableCellRendererComponent(
            JTable table, Object value, boolean isSelected,
            boolean hasFocus, int row, int col) {

        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col); 

        // Formatting here
        setIcon(myCustomIcon);
        setText(myCustomText);

        return this;
    }

}
Martijn Courteaux
  • 67,591
  • 47
  • 198
  • 287