I am writing a java program where you input a length and you input a width of a rectangle and it outputs the perimeter and area. But now, I want to draw the figure as well. But I don't know how to draw it when the button is pressed. Should it look like this?:
public void paintComponent(Graphics g) {
paintComponent(g);
g.setColor(Color.blue);
g.drawRect(10, 10, 80, 30);
}
public void actionPerformed(ActionEvent e) {
paintComponent();
}
Because when I do that it gives me an error saying:
method paintComponent in class Rectangles cannot be applied to given types;
required: Graphics
found: no arguments
So I don't really know what to do.