First, get the string from JTextField (getText()). Second, test if string is empty (equals to "" or length is 0). If it's empty, you can assign to your int/long/etc. variable a "default" value (0, or...