Extends JFrame vs. creating it inside the program

后端 未结 6 765
没有蜡笔的小新
没有蜡笔的小新 2020-11-22 04:39

When making an application using Swing, I\'ve seen people do one of the two things to create a JFrame. Which is a better approach and why?

I\'m a beginner at Java an

6条回答
  •  执笔经年
    2020-11-22 05:17

    It does not matter.

    There are reasons why you might do one or the other, but absent any of those reasons it makes no difference whatsoever.

    Now, if you were writing something that might operate from the command line or might be a GUI program, obviously you could want a 'main' class that was not a GUI class.

    If you worked in a programming shop where one or the other was the standard, by all means follow the standard. There is no right answer to this one, and in fact very little to choose between them.

提交回复
热议问题