Sunday, 15 February 2009

Java Brain Damage

I don't generally buy into bashing Java, a trend all-too-fashionable among dynamic language programmers (and even C++ programmers, for some reason). But I just stumbled across something when writing Clojure that annoyed me: with a JFrame, getLayout doesn'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 getLayout is looking at.

Now, I remember the days where JFrame.add triggered a runtime exception: "Don't use add! 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 add made sense on a JFrame by deferring to the content pane, but symmetry has been broken in the process. Nice!

No comments:

Post a Comment