views:

29

answers:

0

I'm reading an introduction to Java book. I'm about three/fourths of the way through the GUI section, and learning about add different JComponents to a JFrame to create a UI.

I'm confused about one thing, though. The book (in the examples) created a Frame, and then added 4 panels by subclassing one after the other. (In other words: It extended JFrame, then Extended JPanel, then extended the class that extended JPanel, and so on.)

It seems more logical to me that you'd wanted to divide your frame up into panels. And then subclass JPanel several times. And then add those panels to the frame.

Why subclass? Why not go, what seems to me, the more logical route?