I am learning Java gui. The way I learnt to create a window is to inherit or Extend JFrame
class and it is good to use it, as JFrame
contains all the properties of a Window. Now If I want to add something to this window, I need to use add()
method. But Today I came across JPanel
which also creates a windows and we can add stuff by jpanelObjec.add()
.
What is the difference between the two methods? Are they somehow related?
JFrame
is the window; it can have one or more JPanel
instances inside it. JPanel
is not the window.
You need a Swing tutorial:
Source: Stackoverflow.com