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 {

public void bind(Nifty nifty, Screen screen) {

public void onStartScreen() {
public void onEndScreen() {
public void buttona() {


public void buttonb() {

public void buttonc() {



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.