views:

270

answers:

2

Hi all,

when I try putting my JLayeredPane inside a JScrollPane I get a blank window (with white background) instead of the content I am trying to render (it could be an image, a button, a canvas). Does anyone know of a problem with layout managers that might cause it? Is it possible?

EDIT: thanks to camickr help, I can now put a JLayeredPane inside a JScrollPane, though now I am facing a different problem:

I am using a very large image and I am trying to put it inside my JLayeredPane that's inside the JScrollPane. From some reason when I use this large image (I am not receiving a heap overflow exception) I get this blank (white screen). Has anyone experienced something like this?

+2  A: 

Well this is pretty much a guess because you haven't provided much information, but it sounds to me like the JLayeredPane's preferred size is (0,0), and the "white" you're seeing is the background of the JScrollPane's JViewport child. Try setting a preferred size on the JLayeredPane as a start.

CarlG
+1  A: 

Read the Swing tutorial on How to Use Layered Panes for a working example.

Change the following line:

// add(layeredPane);
add(new JScrollPane(layeredPane));
camickr
ok, this is a great help. though now I find another problem that occurs. I am updating my question accordingly
vondip