这里我有代码:
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JPanel;
public class MouseEvents extends MouseAdapter {
@Override
public void mousePressed(MouseEvent e) {
JPanel selectedPanel = (JPanel) getComponentAt(e.getPoint()).getParent();
}
}
这可能是一个非常简单的原因,但我无法弄清楚为什么getComponentAt()
返回错误cannot find symbol
。之前,当我没有这个问题时,它给出了错误getComponentAt() could not be referenced in a static context
——但它是如何被引用为静态的?