I'm fairly new to java, but I'm sure I've done this before and now it's not working right. What am I forgetting here?
LeftPanel class
Inventory inventory;
JTextField txtMoney = new JFormattedTextField(inventory.getInvWallet());
Inventory class
public class Inventory {
public int invId = 0;
public int invPrice = 0;
public String invName = "";
public double invWallet=100;
public Inventory(int invId, int invPrice, String invName, double invWallet){
this.invId = invId;
this.invPrice = invPrice;
this.invName = invName;
this.invWallet = invWallet;
}
public double getInvWallet(){
return invWallet;
}
public void setInvWallet(double invWallet){
this.invWallet = invWallet;
}
}
The error I get
Exception in thread "main" java.lang.NullPointerException
at LeftPanel.<init>(LeftPanel.java:14)
at Sim.main(Sim.java:17)
Thanks muchly to those who answer