• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Perhaps this time the fleet needs to sail

 
Ranch Hand
Posts: 133
1
Mac OS X
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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."

As always, thanks in advance for your help.
 
Rancher
Posts: 3267
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It doesn't compile when I try to copy/paste/compile the code.
 
Chris Crawford
Ranch Hand
Posts: 133
1
Mac OS X
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops -- sorry, I forgot that you need all the core definitions. Here we go:



I hope this covers it for you. Thanks again.
 
Rob Camick
Rancher
Posts: 3267
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A layered pane doesn't use a layout manager so you need to set the size/location of all components you add to the layered pane:



I included my version which helps with other little coding problems as well:

 
Chris Crawford
Ranch Hand
Posts: 133
1
Mac OS X
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Thanks again.
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic