Local translation needed for Swing in jME?

Hello all, I'm running Windows Vista and it seems I need to apply the following local translation to the desktop of JMEDesktopState in order to let (0,0) be at the top-left corner:


desktopState.getDesktop().getLocalTranslation().set(80, -60, 0);



Is this a bug, a Vista problem or something that needs to be done on some platforms (such as Vista)? If so, is there a platform independent way I could detect and set these values? I'm guessing it's some quirky behaviour though. Edit: see message below code too.

Full code:


      final JMEDesktopState desktopState = new JMEDesktopState();
      GameStateManager.getInstance().attachChild(desktopState);
      desktopState.setActive(true);
      
      GameTaskQueueManager.getManager().update(new Callable<Object>() {
         public Object call() throws Exception {
            JButton button = new JButton("test");
            button.setSize(100, 100);
            button.setLocation(0, 0);
            desktopState.getDesktop().getJDesktop().add(button);
            
            desktopState.getDesktop().getLocalTranslation().set(80, -60, 0); // ?
            
            return null;
         }
      });



Edit: the following may or may not be related but it also occurs elsewhere in the game. For example, the "mouse sensitive border" (to navigate the map with the mouse) at the edge of the screen is smaller at the top and left side of the window. So perhaps it's a setting elsewhere. The bottom left corner is (16,-16,0) when I check the coordinates of the absolute mouse.

Right, I solved one of the two issues: the local translation of (80, -60, 0) was necessary because the default window size of the game is 640480 but the default of jMEDesktop seems to be 800600 so it was rendering a larger desktop. This also explains the offset: 800 - 640 = 160 and 160 / 2 = 80 (on both sides) and 600 - 480 = 120 and 120 / 2 = 60 (on both sides).



For others who may find this topic in a search: the constructor of JMEDesktopState should be changed to the following (or equivalent) to fix it:



            final JMEDesktopState desktopState = new JMEDesktopState(
            DisplaySystem.getDisplaySystem().getWidth()
            , DisplaySystem.getDisplaySystem().getHeight());



To developers: I think the JMEDesktopState() constructor should be removed, it's a bit misleading because it defaults to 800*600 which may not be the case.

Edit: it also happens in TestJMEDesktopState, the quit button is invisible when the default window size is 640*480.

Ok, the (16,-16,0) offset is just the default hotspot offset of a 32*32 texture… just need to adjust for that :smiley: