I started coding two weeks ago and I´m trying java higgledy-piggledy.
I wrote a Java Fibonacci Sequence program, which let´s you select the start of your sequence and the length.
I build my first JavaFx Gui with code, but then changed to SceneBuilder.
Since then I´m trying to get my code implemented in the sample.fxml and Controller.java. I figured out how to call methods and link them with my gui with scene builder, but I can´t quite figure out how to call a method with parameters, like my fibonacci method.
Sorry, this is my first question. Don´t hate me for making mistakes. Thanks in advice.
This worked perfectly fine with my hand coded gui, because i could just use my method on an Object and call a triggering event with the method.
Google is my friend, but I can´t find any solutions about this topic yet.
I was thinking about using a declared variable in my code instead of the parameters and then call them with a setter, but I have no idea how to implement it in Scene Builder.
i only can link methods without parameters (events work) (
void fibonacci(int start, int length) { while (i <= start) { (not everything due to understainding) //the syntax of my method in "original" javafx getting called by if (actionEvent.getSource() == sub_button) { FibMain fibMain = new FibMain(); while (true) { try { length = Integer.parseInt(fib_length.getText()); start = Integer.parseInt(fib_start.getText()); break; } catch (NumberFormatException e) { System.out.println("ERROR!"); fib_out.setText("ERROR! ONLY NUMBERS ARE ALLOWED!"); throw e; fibMain.fibonacci(start, length); } This is my working code and i would love to simple call the method with the start and length parameter.
I expect to be able to call the Method with the parameters start and length in SceneBuilder and link them to an ActionEvcent.
startparameter, so why bother passing it; same forlength. Also the compiler should complain about you adding a statement after exiting acatchblock using athrowstatement. Why don't you just parse the input in a event handler and call the originalfibonaccimethod with the results as parameter (you may need to do some work to get the output right).