title: Check for empty textfield
body: <p>Okay, so, what I have, is supposed to be a simple dice roller. 2 textfields, one for the number of die you want to roll, and the other for the total. (Well, and a third for each individual die rolled, but that's besides the point) This works fine, as long as the number of die text field isn't empty. When the field is empty, I just get a <code>NumberFormatException</code></p>
  
  <p>My code:</p>
  
  <pre><code>        Button d4 = new Button("d4  ");
      d4.setLayoutX(240);
      d4.setLayoutY(90);
      d4.addEventHandler(ActionEvent.ACTION, new EventHandler&lt;ActionEvent&gt;() {
          @Override
          public void handle(ActionEvent actionEvent) {
              tooltip.setText("");                
              int d4_num = Integer.parseInt(d4_text.getText()); //d4_text is for the number of die
              d4_num = d4_num + 1;
              int sum = 0;
              for (int i = 1; i &lt; d4_num; i++){
                  int result = 1 + (int)(Math.random() *4);
                  sum = sum += result;
                  tooltip.appendText((String.valueOf("d4_" + i + " =" + result + "\n")));
  
              }
              d4_result.setText(String.valueOf(sum));
          }
      });
  </code></pre>
  
  <p>I've tried checking the value of <code>d4_text</code> in different ways, each one either giving an error because I can't check for null, or a string, or whatever.</p>