to initialize it, in the declaration, just set it to a certain value..
for example -1
:
int x = -1;
or, optionally you can also use Integer
instead of int
Integer x = null;
just remember before calling function abspeichern()
, you also need to handle this further..
(this -1
or null
value); unless it might cause an error
like:
if(ae.getSource() == this.buttonOK){
label.setText(" ");
buttonOK.setEnabled(false);
tfName.setEnabled(false);
if(x!=null){
abspeichern(name[x]);
}
}