I’m getting an error saying that the methods are not applicable for the type Graphics? I don’t fully understand whats going on here – could anyone explain what I’m doing wrong and why its wrong? Thanks,
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Peach extends JPanel {
public void paintComponent(Graphics g) {
super.paintComponent(g);
this.setBackground(Color.WHITE);
g.setColor(Color.BLUE);
g.fillRect(25, 25, 100, 30);
g.setColor(new Color(190, 82, 45));
g.fillRect(25, 65, 100, 30);
g.setColor(Color.RED);
g.drawString("this is text", 25, 100);
}
}
A guess: You’ve got another class that you’ve created in the same classpath called Graphics, and the compiler is confusing your class with the java.awt.Graphics class. If so, you could find out by using the fully qualified class name:
And if so, then rename your own Graphics class to something else, say MyGraphics.
But again, you’ll want to post the actual error message (see comments above).