I am new to java.I created a JFrame class in netbeans, then i did
public class Tela extends javax.swing.JFrame{
...
public Tela(){
Status st;
lblCarism.setText("Carisma: "+st.getCarism());
}
}
Then I have the Class Jogo:
public class Jogo{
static Status st;
public static void main(String[] args){
int[] vida = {12,12};
st = new Status("Diegolo","todos","Libertado","espirito",vida,8,4,2,2,8,0,7,5,20,13,16,0,40,1,0);
Tela.start();
}
}
And The class Status
public class Status {
String nome;
String Sex;
String Classe;
String Raca;
int[] Vida = new int[2];
int forca;
int vel;
int pontoVel;
int percep;
int furt;
int impac;
int mira;
int intel;
int carism;
int defCort;
int defPerf;
int defMag;
int Xp;
int lvl;
int ouro;
int poder;
public Status(String nom, String Sex, String Classe, String Raca, int vida[], int forca, int vel, int percep, int furt, int impac, int mira, int intel, int carism, int defCort, int defPerf, int defMag, int poder, int Xp, int lvl, int ouro) {
pontoVel = (int) vel / 10;
this.nome = nom;
this.Sex = Sex;
this.Classe = Classe;
this.Raca = Raca;
for (int i = 0; i <= 1;i++) {
this.Vida[i] = vida[i];
}
this.forca = forca;
this.vel = vel;
this.percep = percep;
this.furt = furt;
this.impac = impac;
this.mira = mira;
this.intel = intel;
this.carism = carism;
this.defCort = defCort;
this.defMag = defMag;
this.defPerf = defPerf;
this.Xp = Xp;
this.lvl = lvl;
this.ouro = ouro;
this.poder = poder;
}
//getters and setters
}
The Problem is, when i compile the code, it returns a Null exception because of the
lblCarism.setText("Carisma: "+st.getCarism());
line, but I ititialized the Carism already.Is there a way to tell the Jframe class that i updated the Carisma?(I didn't find anything about it on internet)
Edit:Even if i try lblCarism.setText("Carisma: "+Jogo.st.getCarism()); it returns Null Exception, and this question isn't a duplicate.I'm asking about swing and not about Null Exceptions.