0

I have a main class which extends JFrame, and its content is contained in other classes which extend JPanel.

Now, in those other classes, I want to use several panels to group the content in a good order.

Is it possible to use many panels( by creating several JPanel objects in that class) in this class that extends JPanel?

4

1 回答 1

1

JPanelextends JComponent,它 extends Container,所以JPanel是一个容器,所以它包含 other Component

所以,是的,你可以这样做,事实上,根据上下文和要求,这实际上是一个好主意。

你可以看看这个例子这个例子

mKorbel 提出了一个有效的观点。JFrame通常不建议从顶级容器(JPanelJFrame

于 2013-10-09T06:48:00.013 回答