1

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?

vondip
  • 13,809
  • 27
  • 100
  • 156
  • 2
    Please include a code sample. – finnw Sep 21 '09 at 18:51
  • 1
    This is now a separate question so post a proper question with a proper SSCCE showing the code you are using. If you don't know what a SSCCE is then search the web. We can't waste our time guessing what your code looks like all the time. – camickr Sep 22 '09 at 03:03

2 Answers2

2

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,656
  • 1
  • 17
  • 21
2

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
  • 321,443
  • 19
  • 166
  • 288
  • ok, this is a great help. though now I find another problem that occurs. I am updating my question accordingly – vondip Sep 21 '09 at 20:24