Change Variable with NIFTY Panel (Help...)

Hi all,

i have a severe beginners problem. I created a little app, with Nifty GUI.
The panels (created via an xml file) should allow basic change of camera
position (in the update loop). I used a controller in the Nifty XML file (controller=“mygame.GUI”), with “interact onClick (e.g )”.

For my camera-changing varaible, I have an integer defined as protected in my main method.

A separate java class (within “mygame” / the package) has the screen controller and should change the variable, but it doesnt work (save putting out the strings to the console).

The class is:

public class GUI extends TestNiftyGui implements ScreenController {

@Override
public void bind(Nifty nifty, Screen screen) {

}
@Override
public void onStartScreen() {
}
@Override
public void onEndScreen() {
}
public void buttona() {
System.out.println(“AAAAAAAAAAA”);
funk=1;

}

public void buttonb() {
System.out.println(“BBBBBBBBBBBBBBB”);
funk=2;
}

public void buttonc() {
System.out.println("CCCCCCCCCCCCCCC");
funk=3;

}

}

Would be great if you could give any help!!

I am a bit confused.

if your variable is in the class of the main method and it’s protected… are you using a setter method of the main class or just setting the value of a variable (“funk” in your example)?

Basic java knowledge:
To access a variable in class Main (which btw can’t be protected for this) you need a reference to the main object.
Then you just do:
main.funk = 1

I prefer a setter method while keeping the funk variable private/protected.

main.setFunk(1);