I know this has been asked several times before but none of the answers were a solution for me. I just updated the JDK to java-8-openjdk-amd64 (from jdk7) and these errors just appeared:
javafx.fxml.LoadException: Error resolving onAction='#changeStyle', either the event handler is not in the Namespace or there is an error in the script./myapp.fxml:1778
Line 1778:
<Button layoutX="250.0" layoutY="170.0" mnemonicParsing="false" onAction="#changeStyle" text="Reset Style" />
Controller .java:
public void changeStyle(){
String url_orig = CUSTOM_HTMLEditor.class.getClassLoader().getResource(pathToOrigCss).toExternalForm();
String url_1 = CUSTOM_HTMLEditor.class.getClassLoader().getResource(pathToStyle_1Css).toExternalForm();
String url_tango = CUSTOM_HTMLEditor.class.getClassLoader().getResource(pathToStyle_tangoCss).toExternalForm();
String url_tango_invers = CUSTOM_HTMLEditor.class.getClassLoader().getResource(pathToStyle_tangoInversCss).toExternalForm();
root_AnchorPane.getStylesheets().clear();
final Toggle selectedToggle = styleToggle.getSelectedToggle();
int selectedToggleIndex = styleToggle.getToggles().indexOf(selectedToggle);
switch(selectedToggleIndex)
{
case 0:
root_AnchorPane.getStylesheets().add(url_orig);
System.out.println("Style changed to original.");
currentPathToCSS = url_orig;
break;
case 1:
root_AnchorPane.getStylesheets().add(url_1);
System.out.println("Style changed to style_1.");
currentPathToCSS = url_1;
break;
case 2:
root_AnchorPane.getStylesheets().add(url_tango);
System.out.println("Style changed to tango.");
currentPathToCSS = url_tango;
break;
case 3:
root_AnchorPane.getStylesheets().add(url_tango_invers);
System.out.println("Style changed to tango_invers.");
currentPathToCSS = url_tango_invers;
break;
default:
root_AnchorPane.getStylesheets().add(url_orig);
System.out.println("Style changed to original.");
currentPathToCSS = url_orig;
}
}
Setting of the controller:
<AnchorPane id="root" fx:id="root_AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="500.0" minWidth="700.0" prefHeight="680.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.semproc.hergarten.gui.MemotrainerController">
EDIT: Thanks for the help. It was the static in the method.