Move int size = Integer.parseInt(number);
inside actionPerformed:
public void actionPerformed(ActionEvent e){
number = NumtextField.getNumtextField().getText();
int size = Integer.parseInt(number);
}
When the program starts, its trying to parse ""
, which is not a valid number string hence why you are getting an exception.
Also maybe you should put that inside a try{}catch{} block, so in case you get an exception in real time you can handle it:
try {
int size = Integer.parseInt(number);
}
catch (NumberFormatException e) {
System.out.println("Thats not a valid number");
}