# Creating User Interfaces with Nifty GUI

Although it is possible to embed a jME3 canvas in a Swing GUI app, a 3D game typically runs full-screen, or in a window of its own. This soon raises the question of how to add a user interface: Most games respond to the escape key by displaying buttons that allow users to switch to different screens – for example to view high scores, customize settings, or load saved games.

This doc introduces you to
, a Java library for graphical user interfaces (GUIs). Nifty GUI (`de.lessvoid.nifty` package) is well integrated with jME3 via the `com.jme3.niftygui` package. You define the GUI layout in XML and call it from your Java code. All the JAR libraries that you need are already included in your jME3 download, so you do not need to install anything extra (Just make sure they are on the classpath).

Typically, you lay out the Nifty GUI using XML, but using Java will soon be a second option.

## Overview

There are three steps needed to add a GUI to your jME3 game:

1. Lay out the GUI in XML
2. Integrate the GUI into the Game
   - Overlay the User Interface Over the Screen, or
   - Project the User Interface Onto a Texture
3. Interact with the GUI from Java

## Sample Code

- You can find more sample code in the nifty-examples-1.3-SNAPSHOT.jar file.

## Pro Tip: Use XML Schema

If you include the following XML schema in the first lines of your NiftyGUI XML files, your IDE will give you helpful hints and code completion.

    <?xml version="1.0" encoding="UTF-8"?>
    <nifty xmlns="http://nifty-gui.sourceforge.net/nifty.xsd"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://nifty-gui.sourceforge.net/nifty.xsd
                               http://nifty-gui.sourceforge.net/nifty.xsd">

         <!-- Example: The IDE will now tell you that one <screen></screen> element is expected here, etc. -->

    </nifty>

## Nifty Documentation

Learn more from the NiftyGUI page!

documentation, gui, input

view online version