I have problem when trying to do create Sql statement using netbeans, javFX and MySQL. Here is my main method:
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("Create Product");
Pane myPane = (Pane)FXMLLoader.load(getClass().getResource
("createProduct.fxml"));
Scene myScene = new Scene(myPane);
primaryStage.setScene(myScene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
I design my user interface using javaFX and I store the whole panel as myPane as the code above. And here is my createProduct.fxml. It only contains a text field and a button.
<AnchorPane id="AnchorPane" prefHeight="200.0" prefWidth="320.0" xmlns:fx="http://javafx.com/fxml" fx:controller="it2297proj.SampleController">
And this is my event handler class. When button is on click, it will pass the whole panel into CreateProductController.
public class SampleController implements Initializable {
private SampleController myPane = null;
@FXML
private void handleButtonAction(ActionEvent event) {
System.out.println("You clicked me!");
}
@FXML
private void createProduct(ActionEvent event){
CreateProductController controller = new CreateProductController();
boolean result = controller.create(myPane); //Error here
}
And inside my CreateProductController class, I just simply get the text and pass it into an entity.
public class CreateProductController {
public boolean create(SampleController panel){
String name = panel.getnameTextField.getText();
}
}
However, there is an error at the event handler class, boolean result = controller.create(myPane); this line. The error message is The type of create(Sample Controller) class is erroneous. I have no idea why because it works fine in eclipse. Any help would be appreciated.
Thanks in advance.