Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JavaFX
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
JavaFX
Cannot find controller class
John Morgan
Ranch Hand
Posts: 205
2
posted 5 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
For some reason my FXML file will not find the controller class.
Project Set Up
src
+--gov.nv.dwss.controller.AddMergeController.java
|
+--gov.nv.dwss.view.MergeListAdd.fxml
|
+--Main.java
main.java
import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.BorderPane; import javafx.scene.layout.Pane; public class Main extends Application { @Override public void start(Stage primaryStage) { try { BorderPane root = new BorderPane(); Scene scene = new Scene(root,400,400); //scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm()); Pane addPane = (Pane)FXMLLoader.load(getClass().getResource("gov/nv/dwss/view/MergeListAdd.fxml")); Scene myScene = new Scene(addPane); primaryStage.setScene(myScene); primaryStage.show(); } catch(Exception e) { e.printStackTrace(); } } public static void main(String[] args) { launch(args); } }
MergeListAdd.fxml
<?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.control.Button?> <?import javafx.scene.control.DatePicker?> <?import javafx.scene.control.Label?> <?import javafx.scene.control.Separator?> <?import javafx.scene.control.SplitPane?> <?import javafx.scene.control.TableColumn?> <?import javafx.scene.control.TableView?> <?import javafx.scene.control.TextField?> <?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.ColumnConstraints?> <?import javafx.scene.layout.GridPane?> <?import javafx.scene.layout.RowConstraints?> <?import javafx.scene.text.Font?> <AnchorPane prefHeight="500.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="AddMergeController.java"> <children> <SplitPane dividerPositions="0.12449799196787148" layoutX="14.0" layoutY="14.0" orientation="VERTICAL" prefHeight="300.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <items> <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0"> <children> <Label layoutX="383.0" layoutY="20.0" text="Add Merge"> <font> <Font name="System Bold Italic" size="24.0" /> </font> </Label> </children></AnchorPane> <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0"> <children> <SplitPane dividerPositions="0.2550335570469799" layoutX="265.0" layoutY="42.0" prefHeight="244.0" prefWidth="598.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <items> <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0"> <children> <TextField fx:id="userName" focusTraversable="false" layoutX="15.0" layoutY="14.0" onAction="#getUserName" promptText="User Name" /> <Label layoutX="15.0" layoutY="42.0" text="User Name" /> <TextField fx:id="userPwd" focusTraversable="false" layoutX="15.0" layoutY="72.0" promptText="Password" /> <Label layoutX="15.0" layoutY="100.0" text="Password" /> <Separator layoutY="123.0" prefHeight="7.0" prefWidth="200.0" /> <TextField fx:id="srcUpi" layoutX="15.0" layoutY="149.0" promptText="Source UPI" /> <Label layoutX="15.0" layoutY="177.0" text="Source UPI" /> <TextField fx:id="tgtUpi" layoutX="15.0" layoutY="215.0" promptText="Target UPI" /> <Label layoutX="15.0" layoutY="243.0" text="Target UPI" /> <DatePicker fx:id="mrgEqstDt" layoutX="18.0" layoutY="270.0" prefHeight="28.0" prefWidth="170.0" /> <Label layoutX="15.0" layoutY="298.0" text="Merge Request Date" /> </children> </AnchorPane> <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0"> <children> <TableView focusTraversable="false" layoutX="46.0" layoutY="34.0" prefHeight="368.0" prefWidth="589.0" AnchorPane.bottomAnchor="62.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <columns> <TableColumn prefWidth="140.0" /> <TableColumn prefWidth="198.0" text="Source" /> <TableColumn prefWidth="250.0" text="Target" /> </columns> </TableView> <GridPane alignment="CENTER" layoutY="365.0" prefHeight="67.0" prefWidth="596.0"> <columnConstraints> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> <ColumnConstraints halignment="CENTER" hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> <ColumnConstraints halignment="CENTER" hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> </columnConstraints> <rowConstraints> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> </rowConstraints> <children> <Button fx:id="btnConfirm" focusTraversable="false" mnemonicParsing="false" text="Confirm" GridPane.columnIndex="1" /> <Button fx:id="btnReset" focusTraversable="false" mnemonicParsing="false" text="Reset" GridPane.columnIndex="3" /> </children> </GridPane> </children> </AnchorPane> </items> </SplitPane> </children> </AnchorPane> </items> </SplitPane> </children> </AnchorPane>
AddMergeController.java
package gov.nv.dwss.controller; import java.awt.event.ActionEvent; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.fxml.FXML; import javafx.scene.control.Button; import javafx.scene.control.DatePicker; import javafx.scene.control.TextField; public class AddMergeController { @FXML private TextField userName; @FXML private TextField userPwd; @FXML private TextField srcUpi; @FXML private TextField tgtUpi; @FXML private DatePicker mrgEqstDt; @FXML private Button btnConfirm; @FXML private Button btnReset; @FXML void getUserName(ActionEvent event) { String textFieldValue = userName.getText(); System.out.println("User Name: " + textFieldValue); } }
John Morgan
Ranch Hand
Posts: 205
2
posted 5 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Found the problem....
In the AddMergeController I had
import java.awt.event.ActionEvent;
but what I needed was
import javafx.event.ActionEvent;
Knute Snortum
Sheriff
Posts: 7125
184
I like...
posted 5 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Yeah, those are nasty. I've seen a lot of posts in JavaFX that have Swing or AWT imports. Easy to do. Good job finding it.
All things are lawful, but not all things are profitable.
Right! We're on it! Let's get to work tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
starting a small development, scene builder and netbeans(mysql) horrible screen
LoadException with FXML created with Scene Builder 2.0
(FXML) How do I do to give two labels different positions on the same row, using GridPane.
JavaFX with Scenebuilder Error resolving onDragDetected='#setOnDragDetected'
JavaFX memory leak
More...