Veligkekas G.
Veligkekas G.

Reputation: 43

What does a JFrame do?

First of all, I would like you to know that I'm new in Java world; so please forgive me if my question is basic.

I'm working with a team, and we are trying to create a browser using Java.
To begin with, we are watching some tutorials, and all of them begin with a class that extends JFrame. What does this JFrame do?

Upvotes: 0

Views: 5036

Answers (1)

user5549921
user5549921

Reputation:

This could easily be answered in a 10 second Google search... But to answer your question anyway, a JFrame is an extension of java.awt.Frame, which displays a graphical window to the user, in which you can house components and graphics on.

These components range from JButton's JLabel's all the way to Menu bars, etc.

Also, extending a JFrame is never a good idea. It works fine, but for the best code readability, and usage, do not do it. There are plenty of reasons why, and they are explained thoroughly here:
Why shouldn't you extend JFrame and other components?

Extract:

Generally speaking, extending the component tends to be done strictly to use the component. This severely limits your options in unnecessary ways in terms of design, so that your classes can't extend different classes, you can't hide the JFrame's methods causing it to be more difficult to maintain and easier to trigger unexpected bugs when using the class.

More can be found below in the links provided:

JavaDoc for JFrame
How to use a JFrame

Upvotes: 2

Related Questions