为什么我收到此错误,即bruh.setLocation(bruh.x + 2,bruh.y);错误是x和y变量。我该如何解决这个问题?
public void paintComponent(Graphics g){
super.paintComponent(g);
ImageIcon ii = new ImageIcon(this.getClass().getResource("bruh.png"));
bruh = ii.getImage();
Graphics2D g2d = (Graphics2D)g;
g2d.drawImage(bruh, x, y, this);
}
public void keyTyped(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_RIGHT)
{
bruh.setLocation(bruh.x + 2, bruh.y);
}
}
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_LEFT)
{
}
}
public void keyReleased(KeyEvent e) {
}
}