I seem to get the error:
error: cannot find symbol
super.paintComponent(g);
^
symbol: method paintComponent(Graphics)
very often in my code. I always seem to fix it, but this is always after as much as an hour of hair pulling trying to find the solution on a coding thread from 5 years ago. Also, I never seem to remember what I did. So, I am finally asking the graphics pros here. I wrote a little test program that should display a coordinate plane on the JFrame, but instead, I receive this error. I am fairly new to graphics in java, so I have not tried much, except calling repaint on all sorts of components. This is my code:
import javax.swing.*;
import java.awt.*;
public class Graph extends JFrame {
public void showFrame(){
setSize(400, 400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel plane = new JPanel();
add(plane);
setVisible(true);
repaint();
}
public static void main(String[] args){
Graph graph = new Graph();
graph.showFrame();
}
public void paintComponent(Graphics g){
super.paintComponent(g);
g.setColor(Color.black);
g.drawLine(200, 0, 200, 400);
g.drawLine(0, 200, 400, 200);
}
}
Any help is appreciated. Thank you in advance.
JFrame doesn't have this method. It has
public void paintComponents(Graphics g)
inherited from java.awt.Container
.