JLayeredPane Trouble

I have a class that extends JPanel that I use Java2D to draw on and a thread to update the image and repaint it. When I add it to the JFrame it works perfectly, but if I try to put it in a JLayeredPane it completely ignores the repaints! It’s never painted, not once, ever! Any ideas as to why that is? ???

I have tried repainting the JLayeredPane, repainting the JPanel, repainting the whole JFrame, but the repaint method of the JPanel is never invoked while it’s in the JLayeredPane, but again, it works fine if I add it to the JFrame outside of the JLayeredPane! >:(

This doesn’t help massively, but:

  1. Make sure you are using Swing semantics and not AWT semantics (i.e. don’t override repaint()!)

  2. Last time I used JLayeredPane it was a world of trouble and I concluded that its sufficiently rarely used that its had relatively little bugfixing and attention from Sun (for obvious reasons) - and I eventually gave up completely and just wrote my own equivalent. It only takes a couple of minutes. I was particularly annoyed that all the layout managers are broken with JLP and you have to do all layout manually. This took away a lot of the point as far as I was concerned at the time (although for most peoople I’m sure it’s irrelevant)

Yeah, I finally gave up on it too! It is definately something that Sun should look into though!