Question about application settings

I don’t understand why the following code doesn’t work:



[java]

public void initAnimation (String filePath)

{



myApp = new AnimatorVisualizer(filePath); // myApp is an instance of my main that extends simpleApplication



myApp.setShowSettings(false);

AppSettings setting = new AppSettings(true);



// set window title

setting.setTitle(“jME ROCKS!”);



// set window height and width

setting.setHeight(722);

setting.setWidth(1282);





myApp.setSettings(setting);





//Mouse control

myApp.mouseControl= false;



}

[/java]



nothing happens…

Thats correct, this code doesn’t do anything but prepare an application, it doesn’t start it. What do you epect to happen?

MyApp is an instance of the main that extend simple app and therefore running the application is not the problem ;the problem is there are no settings getting updated, for example u cant see the title.

Huh :?

so u cant see jME ROCKS! as the title of the jME window u will see the default jMonkey…

Where do you call myApp.start()?

It would be easier to see the problem if you’d post a little more code.

its going in another class heres some code:



[java]

/** MAIN thats starts the visualizer /

public static void main(String[] args){

AnimatorVisualizer app = new AnimatorVisualizer();



// initialize internal settings

app.setShowSettings(true);

AppSettings defaultSetting = new AppSettings(true);



// set window title

defaultSetting.setTitle("bla bla");



// set window height and width

defaultSetting.setHeight(640);

defaultSetting.setWidth(800);



// Vsynch - Set vertical synching to true to time the frame buffer

// to coincide with the refresh frequency of the screen.

// VSync prevents ugly page tearing artifacts, but is a bit slower.

defaultSetting.setVSync(false);

defaultSetting.setFrequency(60);



// take off settings after putting them into effect

app.setShowSettings(false);

app.setSettings(defaultSetting);



try {

defaultSetting.save("com.animationSettings.SettingNo1");

} catch (BackingStoreException ex) {

/
* could not save settings */

}



// start the application

app.start();

}

[/java]





this is obviously using settings that r different

You’re creating two applications instances in the same VM instance.

I’m not sure that’s a good idea and probably not what you want.

Why don’t you just pass that filePath variable to your already running application?

As for the title, you set it to “bla bla” in your first instance, change it to what you want it to be there instead.

By the way, there’s no need to call app.setShowSettings(true); if you don’t want to show the settings screen.

no no the 2nd instance (jME rocks) is just an adapter for other tasks, so might have many of these, they are in different classes. Think of it as different classes or places (regular small classes) to call the main visualizer that extends simpleApplication. It’s a small portion of a larger design.

So for example bla bla bla is the default title if I run the main directly (for debugging purposes) and jME ROCKS is what I want to show when I am ruing the main from a different class





make sense?

Ah, I see.

So you might run a different class with a main method which in turn calls the initAnimation method in the class you’ve shown parts of here?

In that case you’re still missing the myApp.start() in the initAnimation method.

No no in eag of these classes I create an instance of myApp which is te main app which already contains the stsrt() do again using my code I can start the app just fine, the issue is changing the settings properties between different classes. All I’m trying todo is to have different SETI gs for each class

You said “in eag of these classes I create an instance of myApp which is te main app”…



Do you really mean you are creating a new application instance in all of these cases or just passing the reference around?



An application should have exactly one SimpleApplication subclass and exactly one instance of that class… though you can, of course, pass that reference around wherever you want.

Guys, you’re missing the point Dont worry about my design the question is how can I. Set the settings of my application in a different class?



On a given run I only create one instance of the main an not more

Dude, you miss the point in using jme3 right.

why? I don’t understand why is it that complicated to create settings from a place OTHER than the main??

Okay, do whatever you want.

??? It’s my first week using jME I’m sorry if the question is silly but I really don’t understand. Can you at least explain what is wrong with my approach?

I think there are misunderstandings on both sides as to what you are doing.



It is probably best if you create a simple single-class test case that shows the issue. Either we see the bug in your code or the bug in JME… either way everyone wins in the end. :slight_smile:

I’ll try to write one but it’s definitely not a bug in jME. It was a simple question that I probably didn’t know how to state it, so I apologize to everyone for that, English isn’t my first language and didn’t express myself well here.





let me try again and if that doesn’t work, testCase, it is, cz I do think the question is simple.



Question- Can I have a main jME class (that extends simpleApplication) and call this main class from another class and also change its settings? So if a main class jMETEST.java has settings where window title is “jME ROCKS” can I change that title by calling the main class from another class (by creating a reference to it or whatever method)?



thanks in advance guys and sorry for the misunderstanding

Indeed you can.

If you have the following (pseudo code):

[java]public class MyGame extends SimpleApplication {

[… some application logic here …]

}[/java]

and then you have the main method in another class:

[java]public class MyMainRunner {

public static void main(String[] args) {

MyGame game = new MyGame();

AppSettings settings = new AppSettings(true);

settings.setTitle("MyGameTitle");

game.setSettings(settings);

game.start();

}

}[/java]

that would work fine and the title would be set.