Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JavaFX, Urgent compilation errors!

CaiqueMay 25 2017 — edited May 25 2017

Hello everyone, I need an urgent help, I'm doing a JavaFX course, and in it we have to do a calculator using Scene Builder, I was able to do everything that was requested, but when I put it to onAction, when generating the execution method Button, in XML it appears with a "#", example: onAction = "# onClickNumeros", and I believe that for this reason Netbeans is not compiling the code, nor even finding the method in the control file.

On the lines that have the "#" appears the following message: "The controller is not defined in the root component", I'm already searching for three days to solve this, I need a lot of help with this to be able to evolve in the course

Thanks so much if anyone can help me !!

This is the code:

FXML:

Controller:

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package calculadorafx;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;

/**
*
* @author cteles
*/
public class cenaCalculadoraFXController implements Initializable {

@FXML private Button btnNumZero; 
private Button btnNum1;
private Button btnNum2;
private Button btnNum3;
private Button btnNum4;
private Button btnNum5;
private Button btnNum6;
private Button btnNum7;
private Button btnNum8;
private Button btnNum9;
private TextField txtVisor;    

@FXML
private void onClickNumeros(ActionEvent event) {
Button btnNumerico = ((Button)event.getTarget()); 
String _id = btnNumerico.getId(); 
switch(_id){
case "btnNumZero": txtVisor.appendText("0"); break;
case "btnNum1": txtVisor.appendText("1"); break;
case "btnNum2": txtVisor.appendText("2"); break;
case "btnNum3": txtVisor.appendText("3"); break;
case "btnNum4": txtVisor.appendText("4"); break;
case "btnNum5": txtVisor.appendText("5"); break;
case "btnNum6": txtVisor.appendText("6"); break;
case "btnNum7": txtVisor.appendText("7"); break;
case "btnNum8": txtVisor.appendText("8"); break;
case "btnNum9": txtVisor.appendText("9"); break;       } } 


@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}

}

Main:

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package calculadorafx;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

/**
*
* @author cteles
*/
public class CalculadoraFX extends Application {

@Override public void start(Stage stage) 

throws
Exception
{
Parent root = FXMLLoader.load(getClass().getResource("cenaCalculadoraFX.fxml")); 
Scene scene = new Scene(root);  stage.setScene(scene);
stage.show();
/** * @param args the command line arguments */

public
static void main(String[] args)
{ launch(args); }

}

Compiler Errors Output:

ant -f C:\Users\cteles\Documents\NetBeansProjects\CalculadoraFX jfxsa-run

init:
deps-jar:
Created dir: C:\Users\cteles\Documents\NetBeansProjects\CalculadoraFX\build
Updating property file: C:\Users\cteles\Documents\NetBeansProjects\CalculadoraFX\build\built-jar.properties
Created dir: C:\Users\cteles\Documents\NetBeansProjects\CalculadoraFX\build\classes
Created dir: C:\Users\cteles\Documents\NetBeansProjects\CalculadoraFX\build\empty
Created dir: C:\Users\cteles\Documents\NetBeansProjects\CalculadoraFX\build\generated-sources\ap-source-output
Compiling 2 source files to C:\Users\cteles\Documents\NetBeansProjects\CalculadoraFX\build\classes
Copying 1 file to C:\Users\cteles\Documents\NetBeansProjects\CalculadoraFX\build\classes
compile:
Created dir: C:\Users\cteles\Documents\NetBeansProjects\CalculadoraFX\dist
Detected JavaFX Ant API version 1.3
Launching task from C:\Program Files\Java\jdk1.8.0_131\jre..\lib\ant-javafx.jar
Warning: From JDK7u25 the Codebase manifest attribute should be used to restrict JAR repurposing.
Please set manifest.custom.codebase property to override the current default non-secure value '*'.
Launching task from C:\Program Files\Java\jdk1.8.0_131\jre..\lib\ant-javafx.jar
No base JDK. Package will use system JRE.
No base JDK. Package will use system JRE.
jfx-deployment-script:
jfx-deployment:
jar:
Copying 12 files to C:\Users\cteles\Documents\NetBeansProjects\CalculadoraFX\dist\run742861444
jfx-project-run:
Executing C:\Users\cteles\Documents\NetBeansProjects\CalculadoraFX\dist\run742861444\CalculadoraFX.jar using platform C:\Program Files\Java\jdk1.8.0_131\jre/bin/java
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: javafx.fxml.LoadException: No controller specified.
file:/C:/Users/cteles/Documents/NetBeansProjects/CalculadoraFX/dist/run742861444/CalculadoraFX.jar!/calculadorafx/cenaCalculadoraFX.fxml:13

at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2597) at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:103) at javafx.fxml.FXMLLoader$Element.getControllerMethodHandle(FXMLLoader.java:557) at javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:599) at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:770) at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2823) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2532) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104) at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097) at calculadorafx.CalculadoraFX.start(CalculadoraFX.java:22) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326) at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191) ... 1 more

Exception running application calculadorafx.CalculadoraFX
Java Result: 1
Deleting directory C:\Users\cteles\Documents\NetBeansProjects\CalculadoraFX\dist\run742861444
jfxsa-run:
CONSTRUÍDO COM SUCESSO (tempo total: 19 segundos)

Comments

userBDBDMS-Oracle

What version of Database Mobile Server are you using?

What system are you running on?

What is the version of the JVM that you are using?

Is this reproducible?  if yes, what are the steps.

thanks

mike

1 - 1
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 22 2017
Added on May 25 2017
1 comment
3,517 views