I'm trying to insert a key of type String and a value of type LinkedList (which itself is of type Sprite) into a TreeMap. However, when my code calls the put() method, it throws a null pointer exception and I cannot figure out why.
Here is my Treemap declaration (I'm using Java 7, so it likes the diamond.
TreeMap<String, LinkedList<Sprite>> paneSprites = new TreeMap<>();
Here is part of my method (the rest does the same thing with other sprites and commenting out the put() method here just throws another exception later on at another put() method.
public void initGUIControls()
{
canvas = new RambleOnPanel(this, (RambleOnDataModel)data);
LinkedList<Sprite> spriteList = new LinkedList<>();
//Sprite for Welcome Pane
SpriteType st = new SpriteType(settings.WELCOME_BACKGROUND_TYPE);
BufferedImage img = loadImage(settings.WELCOME_IMAGE_PATH);
st.addState(settings.DEFAULT_STATE, img);
st.addState(settings.INVISIBLE_STATE, img);
int x = 0;
int y = 0;
int vX = 0;
int vY = 0;
Sprite s = new Sprite(st,x,y,vX,vY, settings.DEFAULT_STATE);
spriteList.add(s);
guiButtons.put(st.getSpriteTypeID(), s);
//put sprite types for this pane in the hash map and clear the list
getPaneSprites().put(settings.WELCOME_PANE_TYPE, spriteList); //EXCEPTION THROWN HERE
spriteList.clear();
//Sprites for Select Account Pane
Also, all Strings used here are instantiated in another class as follows
package ramble_on;
public class Settings
{
//Game Settings
public final String APP_TITLE = "Ramble On!";
public final int FRAME_RATE = 30;
public final int GAME_HEIGHT = 700;
public final int GAME_WIDTH = 1200;
//Sprite States
public final String INVISIBLE_STATE = "INVISIBLE STATE";
public final String DEFAULT_STATE = "DEFAULT STATE";
//Pane Types
public final String WELCOME_PANE_TYPE = "WELCOME PANE TYPE";
public final String SELECT_ACCOUNT_PANE_TYPE = "SELECT ACCOUNT PANE TYPE";
public final String CURRENT_ACCOUNT_PANE_TYPE = "CUTTENT ACCOUNT PANE TYPE";
//Sprite Types
public final String WELCOME_BACKGROUND_TYPE = "WELCOME BACKGROUND TYPE";
public final String SELECT_ACCOUNT_BACKGROUND_TYPE = "SELECT ACCOUNT TYPE";
public final String NEW_USER_BUTTON_TYPE = "NEW USER BUTTON TYPE";
public final String CURRENT_ACCOUNT_BACKGROUND_TYPE = "CURRENT ACCOUNT BACKGROUND TYPE";
public final String LARGE_RETURN_BUTTON_TYPE = "LARGE RETURN BUTTON TYPE";
//Sprite Image paths
public final String IMAGES_PATH = "./data/images/";
public final String WELCOME_IMAGE_PATH = IMAGES_PATH + "welcome.png";
public final String SELECT_ACCOUNT_BACKGROUND_IMAGE_PATH = IMAGES_PATH + "selectAccount.png";
public final String NEW_USER_BUTTON_PATH = IMAGES_PATH + "newUser.png";
public final String Current_Account_SCREEN_BACKGROUND_IMAGE_PATH = IMAGES_PATH + "currentAccount.png";
public final String LARGE_RETURN_BUTTON_IMAGE_PATH = IMAGES_PATH + "newUser.png";
}