Mac Problem: Swing not drawing on top of Xith3D

Hello all.

I’m fairly new to Xith and Java development. I was trying to have an easy swing GUI just come up on top of Xith. While I can get it to work on my PC, the Mac has problems.

Relevant code is pretty short:



                JFrame mainFrame = new JFrame();
		mainFrame.setVisible(true);
		mainFrame.setSize(1000,500);
		mainFrame.getContentPane().setLayout(new BorderLayout());
		
		Panel panel = new Panel();
		panel.setLayout(new BorderLayout());
		Button button = new Button("click me");
		panel.add(button);
		panel.setVisible(true);
		panel.setSize(100,100);
		panel.setLocation(600,100);
		mainFrame.getLayeredPane().add(panel);
		mainFrame.validate();
		
		RenderPeer rp = new RenderPeerImpl();
		CanvasPeer cp = rp.makeCanvas(mainFrame.getLayeredPane(),640,480,32,false);
		Canvas3D canvas = new Canvas3D();
		canvas.set3DPeer(cp);
		view.addCanvas3D(canvas);


You should see your Xith render on the left of the frame with the button on the right side - half over the render and half not. On the PC this works fine, the whole button is drawn on top of Xith. But on the Mac Xith is always drawn on top - you only see the half of the button.

Any thoughts on why they’d be diffrent or what I could do to fix it?

Thanks

mmh you’re not drawing swing on top of it. Button and Panel are both AWT.
If they would have been swing, I wouldn’t have been surprised. (Lightweight/Heavyweight problems)
I do a similar hack and it works on my computer. (I put the swing components into an AWT Panel to make them heavyweight).
But I’ve only tested my code on Windows and Linux…

How far did that Gui-Project go? Maybe there’s no need anymore to use swing.

If you’re not tied to java 1.4, there’s a new method in 1.5 : Component.setComponentZOrder() that should fix your problem.

Lilian

I tried the setComponentZOrder() method with no luck. I think I’m going to have to abandon having full-screen mode for the mac. Just have the swing elements pop-up in new frames.

Just bugs me that the Mac and Window would be different.

Thanks though.

Can you try exactly as specified on
http://www.java-gaming.org/forums/index.php?topic=12882.0

…this heavy/lightweight subject is tricky sometimes, so little things might make the difference…