Z-Order with Component and Graphics


#1

Is there a way to send a component BEHIND a graphic object?

For example, I have a kidney-shaped component that gives me a nice transparent non-rectangular area to hold my foreground components.

I have a need, however, to create a few additional components that “slide out” from behind the main kidney-shaped irregular “window” area.

At least in Jucer when I send-to-back, it’s only applicable to the editing mode you are in-- graphics or components.

Any suggestions would be appreciated.


#2

you can use the paintOverChildren method, that will let you paint after the child component have been painted in the current one.


#3

bear in mind though, that paintOverChildren will paint over all child components.

do you have a component with a kidney shape drawn in paint()? and i presume your child components are placed in that. if you want stuff to come from behind, then you’ll really want to actually place them behind. you don’t have to do that by putting the components into the kidney component’s parent - you could just fiddle with your component structure a bit…

  • Make a clear component to act as the container (the one your kidney is currently drawn in)
  • Make another component with your kidney shape drawn in
  • Have the new kidney shape as a child component in your main one, positioned behind the other children

This means you can place the other children behind the kidney ‘layer’ when necessary, keeping them in the same parent as the others.


#4

Ahh good idea. I’ll give this a shot.


#5