A good answer might be:Yes. It is a static method and does not really need a separate class definition. | |
main() Defined in the myFrame ClassHere is a modification of the previous program. Now there are only two class definitions. The program starts running with the static main() method (as always.) Remember that a static method exists when the program starts up and is not part of any object.
The program behaves exactly the same way as before. When you copy and run this program, name the source file myFrame.java (recall:the source file must have the same name as the one public class in that file.) Most text books do it this way. There are other tricks that make a GUI program even shorter, and some books use those, too. But the three parts of a GUI program will always be there. Sometimes all three parts will be combined into one object. | |
QUESTION 13:Is it OK for main() to ask for a new myFrame() when it is part of the myFrame class definition? Click Here after you have answered the question |