I have a Canvas subclass object that I'm trying to add, along with some other Canvas subclasses, to a JLayeredPane. In the documentation for JLayeredPane, the layer is given as an Integer, e.g.
layeredPane.add(child, new Integer(0));
However, when I use an Integer for the layer, I get some kind of runtime error. (I can't really tell what this error is because my IDE keeps complaining about the lack source for the Swing libraries.) Oddly, when I use the following form:
layeredPane.add(child, 0);
the line actually executes error-free. I'm very new to Java and still haven't figured out how autoboxing works other than to form the opinion that it doesn't work very well. I'm not sure if the bare 0 would be autoboxed in this case.
I wish I could add more detail about this error, but I'm not even seeing an exception. I will work on trimming my code down to a simple example, but I was hoping someone with experience with JLayeredPane has seen this before.