Best way to create JFrame

What is the best way to create a JFrame and process it?

  • Create a class and create a JFrame object inside it
  • Inherit from JFrame as class MyClass extends JFrame
+8
java swing jframe
source share
2 answers

If possible, do not use inheritance (your is-a JFrame class), but select a composition (for example, your has-a JFrame class). This is a general design principle.

And this does not have a significant impact on performance.

+9
source share

Basically, only the time you need to extend the JFrame, you need to overload any methods in it.

In this case, there should not be noticeable performance, anyway.

+6
source share

All Articles