All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.lessvoid.nifty.examples.test.TestScreen Maven / Gradle / Ivy

Go to download

Lots of Nifty example code! You can find the source for nearly all demos/tutorials in here.

There is a newer version: 1.4.3
Show newest version
package de.lessvoid.nifty.examples.test;

import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.elements.Element;
import de.lessvoid.nifty.examples.NiftyExample;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;

import javax.annotation.Nonnull;

public class TestScreen implements ScreenController, NiftyExample {
  private Nifty nifty;
  private Screen screen;

  @Override
  public void bind(@Nonnull final Nifty nifty, @Nonnull final Screen screen) {
    this.nifty = nifty;
    this.screen = screen;
  }

  @Override
  public void onStartScreen() {
  }

  @Override
  public void onEndScreen() {
  }

  public void popup() {
    Element element = nifty.createPopup("popupExit");
    nifty.showPopup(screen, element.getId(), null);
  }

  public void popupExit(final String exit) {
    if ("yes".equals(exit)) {
      Element element = nifty.createPopup("popupExit");
      nifty.showPopup(screen, element.getId(), null);
    } else if ("no".equals(exit)) {
      nifty.closePopup(screen.getTopMostPopup().getId(), null);
    }
  }

  @Nonnull
  @Override
  public String getStartScreen() {
    return "start";
  }

  @Nonnull
  @Override
  public String getMainXML() {
    return "test/test-popup.xml";
  }

  @Nonnull
  @Override
  public String getTitle() {
    return "Nifty General Test";
  }

  @Override
  public void prepareStart(Nifty nifty) {
    // nothing to do
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy