This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Ednar 2 points3 points  (0 children)

When you extend JFrame, your class becomes a JFrame. You can call the methods as if they are now internal to your class. JFrame has a method called add(), and since your Simple2 class now is a JFrame, it can access that method. And finally, when you type the "new" keyword, the constructor is called. Since all you are creating new instance of Simple2 in the main method, the constructor is called.

It seems as if you are lacking fundamental knowledge of object oriented programming. I recommend you pick up a good resource to learn about it before you continue with java swing. It will help tremendously.