Skip to main content

Problem with removing HContainer from HScene

3 replies [Last post]
Joined: 2007-06-11


Could anybody please help me with this problem.
I am using HContainers to create menus and subMenus.
Adding these HContainers to the HScene works great, but setting the HContainer
invisible or removing it from the HScene is impossible.
Everything works alright in the Sonic BD-Emulator, but it doesn't work on hardware players.

I've tried the following approaches.
- HContainer.setVisible(false) and HScene.repaint()
- HScene.remove(HContainer) and HScene.repaint() and also
- HScene.removeAll() and HScene.repaint()

Does anybody have a solution for this problem?

I've also been trying to find a similar approach in the GRID framework, but i did
not succeed. Maybe someone can point me to the right source file, where i can
find an implementation that i can use in my classes.

Many thanks in advance for your help.


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2007-06-11

Hi Chihiro,

Thanks for your reply. I've already tried HScene.validate() before, which doesn't make
a change.
But in the meantime i found a workaround that works on all players.

I simply override the paint()-method of the HContainer and change the AlphaComposite.
So my code looks like this:

public void paint(Graphics g){
   Graphics2D g2 = (Graphics2D)g;
      //if visible set alpha=1 and draw all child elements via super.paint()
      g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, 1.0f));
      //if not visible set alpha=0 and just draw a rect with the size of the container.
      //no child element will be drawn.
      g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, 0.0f));
      g2.fillRect(0,0, getWidth(), getHeight());

This workaround makes it possible to show/hide the container and all its components.
Just to make things clear: So far i am not using the GRIN framework for my current project, just the standard HAVi components.


Joined: 2007-04-10

Hi Bjoern,
meanwhile I am also using a workaround for this problem.
It seems that only elements that are directly in front of the scene show this behaviour. Components that have another component between them and the scene are hiding without problems.
Therefore my workaround consists in just creating a new empty full screen HTextBox with a 100% transparent backgroundcolor and adding this directly to the scene. All other elements are added in front of this.

- Philipp

Joined: 2006-11-08


I don't think GRIN uses any HAVi components other than HScene; xlets there are probably adding pure java.awt.Container instance to it.

Could validating the HScene after the removal help, by any chance?