Scaling of swing overlay

Hi

I am using a swing gui in my xith3d application. I have created the gui by subclassing the UIWindow class, and then I draw it to my canvas using:


UIWindowManager windowMgr = new UIWindowManager(canvas);
            window = new InfoWindow(120, 200);
            windowMgr.addOverlay(window);
            windowMgr.setPosition(window,10, 10);
            windowMgr.setVisible(window, true);
            UIEventAdapter eventAdapter = new UIEventAdapter(windowMgr);
//        canvas.get3DPeer().getComponent().addKeyListener(eventAdapter);
        canvas.get3DPeer().getComponent().addMouseListener(eventAdapter);
        canvas.get3DPeer().getComponent().addMouseMotionListener(eventAdapter);
        canvas.get3DPeer().getComponent().setFocusable(true);


The gui is drawn, but with very noticeble artifacts, as if it has been scaled up or down. When trying to interact with the components, I constantly have to click a few pixels to the left of the component.

If I scale the window up or down, the gui is also scaled, but the “hotspots” for the interaction stay in the same location, so the more I scale the window up, the further away from the buttons I have to click.

Is this a bug, or is it like that by design? Did I miss something?

btw, I tried using the TestWindow class from the TerrainTest instead of my own, and I get the same results.

Terje

Update:

When setting fullscreen to true in the makeCanvas method of RenderPeer, everything seems to work ok.

This is of course a workaround, but I would like to be able to scale the window…

Terje

I think I understand the bug, but I don’t know how to fix it in the XithCode.

When you create a fullscreen canvas of 800x600, it is really 800 by 600.

However, when you create a windowed canvas of 800 by 600, it is realy about 770 by 590, after counting in the topbar and the borders.

So when the UI is initializes, it uses a calcPlate() or something like this to calculate the size of the window and figures out the scaling factor of the screen. Since its does not take into account the new size of the screen (770 by 590), it scales improperly.

Any ideas on this?

Yes, Xith GUI is buggy… I don’t know what and how, but look at these posts - there is pretty easy solution (seems to work on Linux & Windows only, but no go on Mac):

http://www.java-gaming.org/forums/index.php?topic=12882.0
http://www.java-gaming.org/forums/index.php?topic=12872.0

Bohdan