Java Swing Applet---JFormattedTextField

95 views Asked by At

I'm writing my first Java Swing Applet, and wanted to include a JFormattedTextField that only allowed integers greater than 0. The bit of my code is this;

try {
      SwingUtilities.invokeAndWait(new Runnable() {
          @Override
          public void run() {
              JFormattedTextField txt = new JFormattedTextField(Object 1);
              add(txt); //creating the JFormattedTextField
          }
      });
  } catch (Exception e) {
      System.err.println("Please enter new number."); //Catching any numbers less than one. 
  }
0

There are 0 answers