getLayoutdoesn't return the object set by a previous
setLayout(aLayout)call. Why? Because the layout actually gets set on the
JFrame's content pane, and that's not what
getLayoutis looking at.
Now, I remember the days where
JFrame.addtriggered a runtime exception: "Don't use
getContentPane().add()instead!" or something like that. Somewhere down the line, someone appears to have had the great idea of changing that so that
JFrameby deferring to the content pane, but symmetry has been broken in the process. Nice!