I am trying to utilize the Graphics object for my method, but it returns an error. It is due to the fact that I can't use g.fillOval in the actionPerformed method, but I must use it there or else my code won't work.
Class Code:
public class CityPanel extends JPanel implements ActionListener{
int[] sunPos = {};
int[] x = {50,100, 150, 200, 250, 300, 350, 400, 450};
int[] y = {200, 150, 100, 50, 25, 50, 100, 150, 200};
int tracker = 0;
//more defined variables here
public CityPanel(Color c) {
//code in here
}
public void paintComponent(Graphics g){
Graphics2D ga = (Graphics2D)g;
super.paintComponent(g);
g.drawLine(0,300,500,300);
}
public void actionPerformed(ActionEvent e){ // what happens
if (e.getSource() == time) {
g.fillOval(x[tracker],y[tracker], 50, 50); //error here
super.repaint();
}
}
}