I am following the Java tutorial on 2D graphics and am playing with a class that creates a JFrame. Just for fun I want to print a message on a panel in the frame with the size of the frame after a user resizes the frame. As I have understood the tutorial, the method paintComponent is called eg. when the frame has been resized by a user.
However, in my code below, paintComponent seems to never be called after I resize the GUI. What am I missing ?
There's a bug in the code that causes the window to be sized incorrectly. You'll find it by using @Override annotations wherever applicable :-) (you should get in the habit of using that everywhere, both to prevent bugs like this one from happening, and as a reminder to whoever reads the code in future to know that something gets overwritten).