Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » onAction event handles is marked as error in FXML(Mared as error in Eclipse but works fine)
onAction event handles is marked as error in FXML [message #1474484] Sat, 15 November 2014 13:07 Go to next message
Yakov Fain is currently offline Yakov FainFriend
Messages: 2
Registered: November 2014
Junior Member
I have an FXML file that includes <Button> tags generated by Scene Builder. The name of the controller class is properly set in FXML and has the following code:

public class CalculatorController {

public void buttonClickHandler(ActionEvent evt){

Button clickedButton = (Button) evt.getTarget();
System.out.println("You clicked on " + clickedButton.getText());
}
}

When I add onAction="#buttonClickHandler" to FXML Button controls the program works fine, but Eclipse marks it red displaying the "error" as "The CalculatorController has no event slot 'buttonClickHandler'". The sample FXML button is shown next:

<Button onAction="#buttonClickHandler" mnemonicParsing="false" prefHeight="37.0" prefWidth="132.0" text="MC">
<GridPane.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</GridPane.margin>
</Button>
Re: onAction event handles is marked as error in FXML [message #1474647 is a reply to message #1474484] Sat, 15 November 2014 16:07 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
IIRC we mark it as an error because it we only honor @FXML - please file a bug requesting that we also treat public methods/fields as if the where annotated with @FXML and until fixed simply add the none mandatory annotation
Re: onAction event handles is marked as error in FXML [message #1572904 is a reply to message #1474647] Mon, 19 January 2015 12:02 Go to previous messageGo to next message
Yakov Fain is currently offline Yakov FainFriend
Messages: 2
Registered: November 2014
Junior Member
Submitted the bug with id=457825

bugs.eclipse.org /bugs/show_bug.cgi?id=457825
Re: onAction event handles is marked as error in FXML [message #1691457 is a reply to message #1474647] Tue, 07 April 2015 11:44 Go to previous message
shashank shekhar is currently offline shashank shekharFriend
Messages: 1
Registered: April 2015
Junior Member
Hi Thomas,
I am facing the same problem. I have three packages: Application,controller and GUI.The GUI has multiple .fxml files each for 1 tab and there is one more .fxml file which is Prime.fxml which will import all the other .fxml files.
All .fxml has one controller class each in controller package.I have two buttons in one of the .fxml files with which i have attached one method each and i have implemented them in one of the controller file pertaining to that .fxml(this .fxml is not Prime.fxml).And when i run the app i get this exception:
javafx.fxml.LoadException: Error resolving onAction='#setTestLocation', either the event handler is not in the Namespace or there is an error in the script.
And here in the below code i am getting compilation error for the method names of the buttons.
<Button fx:id="btn1" layoutX="529.0" layoutY="351.0" mnemonicParsing="false" onAction="#setTestLocation" text="Browse" />
<Button fx:id="btn2" layoutX="529.0" layoutY="409.0" mnemonicParsing="false" onAction="#setConfigFileLocation" text="Browse" />

Please help,its been two days.
Previous Topic:AddOn DND to new window
Next Topic:How to set WindowCloseHandler
Goto Forum:
  


Current Time: Wed Feb 05 15:53:53 GMT 2025

Powered by FUDForum. Page generated in 0.03838 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top