为什么我会收到“找不到符号”的信息Java 中的错误?
@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;
}
我在指定的行中收到错误。它说“找不到符号”,但我不知道真正的问题是什么。
已更新
@martinusadyh
恐怕该类太大,因此不允许我将其粘贴到此处。
@ Hovercraft Full Of Eels
这是 Netbeans 中的错误
https://i.sstatic.net/R4fv3.jpg
@Henery
这不是我的课。我只是实现一个接口方法。
@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.sstatic.net/R4fv3.jpg
@Henery
It's not my class. I'm only implementing an interface method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
那么您的父类
super
是Object
并且没有方法getTableCellRendererComponent
。您要么必须扩展一个合适的类,要么在不调用不存在的方法的情况下相处。Then your parent class
super
isObject
and has no methodgetTableCellRendererComponent
. You either have to extend a suitable class or get along without calling non-existing methods.您必须
扩展DefaultTableCellRenderer
而不是实现TableCellRenderer
。注意:
DefaultTableCellRenderer
其方法getTableCellRendererComponent
返回this
。这意味着调用super.getTableCellRendererComponent();
就足够了,无需将其分配给局部变量。因为局部变量等于this
。也许我的解释太难了:例子。You have to
extends DefaultTableCellRenderer
instead ofimplements TableCellRenderer
.Note:
DefaultTableCellRenderer
its methodgetTableCellRendererComponent
returnsthis
. This means that it's enough to call thesuper.getTableCellRendererComponent();
without assigning it to a local variable. Because the local variable equalsthis
. Maybe my explanation is too difficult: example.