Hi guys, im just new to both these forms and
Java and I was wondering if someone could help me out. I am currently trying to teach myself a bit of Java and was looking at a tutorial with the following code:
What this does is creates a frame and displays the text "this is my custom panel" but what I dont get is how is the text displayed. I know I create the panel MyPanel with one constructor and two methods, getPreferredSize() and paintComponent(). I understand paintComponent is responsible for printing the text "this is my custom Panel" on to the panel but when I am adding the panel the code simply calls the constructor f.add(new MyPanel());. This constructor only creates the border. Nowhere in the code am I calling the paintComponent method so how is the code here getting executed?
Sorry if this is a silly question but I just dont seem to get it.
Thanks for any help I may get.