Main method in Jframe?

Asked

Viewed 87 times

1

I have a question: When creating a new Jframe in Netbeans, a main method is placed inside it, I thought it was necessary and therefore never touched it. Today I deleted it and the program continued working normally. The question is: WHEN is the main method of a Jframe used in the program? Detail that the main method of the project is of a control class and therefore theoretically the main Jframe is not executed. I am right?

  • 1

    On the first level of an application there should only be one Jframe, so this main method would be the input of your application. It is bad practice for programming to use more than one Jframe. All Java programs start in the method main.

  • After using Jframe how would you proceed? Using Jpanel?

  • Behold here.

1 answer

0

The main method is required for your main jFrame, or its class responsible for instantiating a jFrame..

it is good to have a main() in jFrames, since when trying to compile only that jFrame itself it needs that main to start. Unless every test you want to do you need to compile the entire project and from your main jFrame go opening the others...

  • Thank you now I understand! Thank you for the answers!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.