Hi, I'm reading the Head First
Java book and am having problems using the example regarding the paintComponent method (pg. 364 chapter 12). I've made a subclass of JPanel but cannot seem to call the paintComponent method. I've pasted my code below; any tips would be appreciated!
-----------------------------------------------------------
package mydrawpaneltest;
import java.awt.*;
import javax.swing.*;
public class MyJPanel extends JPanel {
/** Creates a new instance of MyJPanel */
public MyJPanel() {
}
public void paintComponent(Graphics g) {
g.setColor(Color.orange);
g.fillRect(20, 50, 100, 100);
}
}
----------------------------------------------------------
package mydrawpaneltest;
public class Main {
public Main() {
}
public static void main(
String[] args) {
MyJPanel myJPan = new MyJPanel();
myJPan.repaint();
}
}