Positioning Text + MenuBar for the main window

Hi all, its me again. The new member of jME!

I have another problem. I am trying to move a text which i created using:

Text t1 = Text.createDefaultTextLabel("t1","Hello!");//new Text("t1", "Hello!");

to somewhere on the middle of the screen, say (30,30) - How can I do this? (I have already tried setLocalTranslation(30,30,0); but that didn't work)....

Any solutions?
Also, I need to add a menubar to the main window of the game. I am using the BaseGame implementation. Please advice on that as well...



What did not work? Does the text show up, but not at the position you wanted to? For sure

With positioning in ortho you have to know that the point (0,0,0) is lower-left. the middle is x=width/2 , y=width/2,z=0 (where width and height are from display)

If you want have a text like you said you can subtract half of the width of the middle and should

reach what you wanted to. And this works for every resolution…

A menu-bar would be positioned the same way…a bit playing around and you will get this easily…

Good Luck

package jme.scene.text;

import com.jme.app.SimpleGame;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.Renderer;
import com.jme.scene.Node;
import com.jme.scene.Text;

public class TextTest extends SimpleGame{

   protected void simpleInitGame() {
      Text t = Text.createDefaultTextLabel("text","Hi There!");

   public static void main(String[] args)
      new TextTest().start();


hey ttrocha!

Thanks for the reply. I completely forgot that in ORTHO mode, the positions are treated pixel-wise… thanks i managed to fix it!..

Also, whilst we are here, can you tell me how to get the menu bar onto the main window (jframe or whatever) just like a normal Swing JFrame. How do i get the JMenuBar attached to the

display.createWindow(width, height, depth, freq, fullscreen);


Actually I'm not so sure! There might me 2 options (both I didn't use yet). You can use normal swing and and jME-Canvas for the 3d-stuff! Or use jME-Desktop! For jME-Desktop (swing insdie of jme) have a look at the TestJMEDesktop-Class in the jmetest-package.