Last night I solved my problem with a JLayeredPane merely by preparing the SSCCE (or whatever the acronym is). But this time I seem to be well and truly stuck. Here's the basic code, which does in fact compile and produce results that are not what I think they should be:
I have stripped out a bunch of radio buttons that accompanied godButton. I made the background of rightLowerPanel pink so that it would stand out against homeImage.
Some background information: homeImage.jpg fills mainFrame; rightLowerPanel contains JRadioButtons, but only one in this example. I tried three different variations of the layer depths of the two JComponents: (0,0); (0,1); and (1,0), just to make sure that I didn't have the layer depth interpretations backwards (The documentation describes two interpretations that are opposed to each other -- I'd love to hear how the Java designers got themselves into that mess!)
The results: homeImage shows up in all three combinations of depth settings; rightLowerPanel never shows up in any of the depth settings. My expectation is that rightLowerPanel should show up on top of homeImage.
My guess is that I am leaving out one of the myriad enabling settings. If this be so, then one of you folks will ask "Did you remember to use setFlopDoodle(true)?" and I'll answer "Oops! Sorry, I shoulda thought of that."
Thank you, thank you, thank you! Your solution worked perfectly! I had been confused about whether to use a new JLayeredPane instead of the one belonging to mainFrame, but one of the topics I found here on a search for JLayeredPane used the latter approach, so I decided to go with that. And I've always been confused about the best time to include the mainFrame.setVisible(true) call; henceforth I'll always put it at the END of all the other setup code.
I must confess, I've never really "gotten the feel of" Swing. I've been using it in a putzy way for some years now, and most of the time my stuff works, but I seldom can figure out why when it doesn't work. I've read about its internal processes, but they're a bit too complicated for me to truly grasp.
moose poop looks like football shaped elk poop. About the size of this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss