Even more problems with my program and a new newbie question
Recently I started with Nifty.
My application runs in a swing frame, but i need some button events on the JME canvas.
So I started with the nifty tutorials and tried o put the example one my JME canvas.
Shown in: [nifty gui xml layout][1]
The problem I have is, that the screen is shown, but the size don’t correlated with the JME canvas.
Only after changing the window size, the size of my nifty screen is displayed correctly.
Is this because im using the JME canvas embedded in Swing frame?
Do I have something special to do?
Here my code part where I do this stuff:
First I exended my application with ScreenController (interface)
Than I do the nifty stuff in the simpleInitApp()
after this I create the methods wich are necessary for the ScreenController Interface
This method returns the JmeCanvasContext:
And finally the main method: create an instance of JFrame and the JME App and put it together
Last but not least here the corresponding xml file for the screen.
Maybe one of you knows what’s wrong here.
A nice evening to all of you and happy programming
I’m pitty that I have no solution for you. In my case it was a strange relationship between Nifty, JME and the swing frame. I played arround with different panels where I add my JME canvas. At the one time the error was disappeard and at the other time it cames back
At the current time I don’t use Nifty and and have been searching for a solution shifted backwards.
If you find something I should be very glad if you could post it here. I will write you too if I find something. :}
...
// 1.Canvas
createCanvas();
Canvas cv = ((JmeCanvasContext) getContext()).getCanvas();
cv.setPreferredSize(new Dimension(800, 600));
// 2.Frame
JFrame jf = new JFrame();
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.add(cv);
jf.pack();
// !Window to the center.
jf.setLocationRelativeTo(null);
jf.setVisible(true);
// 3. A task object
enqueue(new Callable<Object>() {
@Override
public Object call() throws Exception {
// The size of my window 800/600, but it can be any value.
reshape(800, 600);
return null;
}
});
because jme rendering in a separate thread, perhaps therefore occur: