1

Okay so I'm following a bunch of tutorials online for Java FX and FXML, but I'm not understanding what is an fx:controller and why does my code always say there's an error with it?

Can someone tell me why does Netbeans make three classes when I make a new JavaFX project? I don't want to use FX Builder or whatever it's called, I like coding it by hand.

Why does netbeans make 3 different classes when I create a new JavaFX project? Please help I'm trying to learn this but I'm having this problem with all the tutorials I try to follow.

Here's the code that I'm having problems with:

It's giving me an error saying: Class does not exist: fxmltableview.FXMLTableViewController Class does not exist: Insets

The three classes that my are in my project are: NotePadFX.java FXMLTableViewController.java fxml_tableview.fxml

<GridPane alignment="CENTER" hgap="1.0" vgap="10" 
          xmlns:fx="http://javafx.com/fxml"fx:controller="fxmltableview.FXMLTableViewController">
    <padding>
        <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
    </padding>

</GridPane>

This is the tutorial I'm trying to follow: http://docs.oracle.com/javafx/2/fxml_get_started/fxml_tutorial_intermediate.htm

user3505901
  • 408
  • 1
  • 6
  • 19

1 Answers1

2

For the second error:

Class does not exist: Insets

make sure you have the correct import near the top of the FXML file:

<?import javafx.geometry.Insets?>

The first error:

Class does not exist: fxmltableview.FXMLTableViewController

might be a bit trickier. Make sure you have defined a class called FXMLTableViewController, and make sure the first statement is

package fxmltableview ;
James_D
  • 201,275
  • 16
  • 291
  • 322
  • This isn't an issue in the Java Code though, only in the FXML code :/ – user3505901 Jul 05 '14 at 08:17
  • If the class doesn't exist (ie it's not in the correct package and on the classpath), then parsing the `fx:controller` attribute in the FXML will throw an exception. – James_D Jul 06 '14 at 10:02