title: Custom Control ClassNotFoundException in Scene Builder
body: <p>I have created a new control by extending an existing one, and I would like to use this new control in my JavaFX scenes. I would like to be able to edit my scenes using Scene Builder, but after adding the new control to the FXML file, I am encountering a <code>ClassNotFoundException</code> when opening Scene Builder.</p>
  
  <p>For example, here is a class I made which extends <code>TextField</code>:</p>
  
  <p><code>RegexLimitingTextField.java</code></p>
  
  <pre><code>public class RegexLimitingTextField extends TextField {
  
      private String regexLimiter = ".*";
  
      public void setRegexLimiter(String regex) {
          this.regexLimiter = regex;
      }
  
      @Override
      public void replaceText(int start, int end, String text) {
          if (text.matches(regexLimiter))
              super.replaceText(start, end, text);
      }
  
      @Override
      public void replaceSelection(String replacement) {
          if (replacement.matches(regexLimiter))
              super.replaceSelection(replacement);
      }
  }
  </code></pre>
  
  <p>After adding this control to my FXML file...</p>
  
  <p><code>sample.fxml</code></p>
  
  <pre><code>&lt;?import javafx.scene.layout.GridPane?&gt;
  &lt;?import sample.RegexLimitingTextField?&gt;
  &lt;GridPane fx:controller="sample.Controller"
            xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10"&gt;
      &lt;RegexLimitingTextField fx:id="textField" text="Test" /&gt;
  &lt;/GridPane&gt;
  </code></pre>
  
  <p>... I get this error when loading Scene Builder 2.0:</p>
  
  <pre><code>Caused by: java.lang.ClassNotFoundException: sample.RegexLimitingTextField
      at java.lang.ClassLoader.findClass(ClassLoader.java:530)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      at javafx.fxml.FXMLLoader.loadTypeForPackage(FXMLLoader.java:2920)
      at javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:2909)
      at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2850)
      ... 23 more
  </code></pre>
  
  <p>Why can't Scene Builder find my new control? What do I need to do in order for it to find and be able to use my new control?</p>
  
  <p>Here are the other files if needed:</p>
  
  <p><code>Main.java</code></p>
  
  <pre><code>public class Main extends Application {
  
      public static void main(String[] args) {
          launch(args);
      }
  
      @Override
      public void start(Stage primaryStage) throws Exception {
          Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
          primaryStage.setScene(new Scene(root, 200, 200));
          primaryStage.show();
      }
  }
  </code></pre>
  
  <p><code>Controller.java</code></p>
  
  <pre><code>public class Controller implements Initializable {
      public RegexLimitingTextField textField;
  
      @Override
      public void initialize(URL url, ResourceBundle resourceBundle) {
          textField.setRegexLimiter("\\w*");
      }
  }
  </code></pre>