-1

I'm using JavaFX since a couple of days, so the code I'm complaining with is just copy pasted (it's only one line though), and I don't know why I can't add more than this one parameter to the method.

first picture

When I only write args to the parameters, it's working. Here's the method I want to use:

enter image description here

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • 4
    Please read [ask]. Please post your code as code, not as images. Also please read the code carefully. The error message is telling you all that you need to know. Basically that the method you are trying to use does not exist. – JustAnotherDeveloper Oct 22 '21 at 07:33
  • 1
    I think the error message is clear enough: your `Gui` class has no method `launch()` that takes two parameters. Since `Gui` is your class you are the one to write such a method. – Thomas Kläger Oct 22 '21 at 08:24
  • 1
    Thomas’s comment is slightly wrong, [launch()](https://openjfx.io/javadoc/16/javafx.graphics/javafx/application/Application.html#launch(java.lang.String...)) is inherited from the framework application code, it is not user code. It takes a [varargs](https://docs.oracle.com/javase/8/docs/technotes/guides/language/varargs.html) parameter callable with with any number of parameters including two. But they must all be the correct type (a string or, if just one, it could be an array of strings). You could pass just a string array instead of both the string and map. – jewelsea Oct 22 '21 at 09:15
  • 1
    I advise not doing the file read in `main()`, only call launch from main passing the baths from main to launch with no change. An alternative to what you have is to implement the logic as a function of a utility class and call it from an [`init()`](https://openjfx.io/javadoc/17/javafx.graphics/javafx/application/Application.html#init()) method you implement in the application, saving the data read somewhere, e.g. in an instance variable in the application. – jewelsea Oct 22 '21 at 09:27
  • 2
    no screenshots of plain text, please - they are unreadable and unsearchable. Instead c&p (errors/stacktraces formatted as code), and best make any code a [mcve]. Also make sure you are familiar with java language basics ... – kleopatra Oct 22 '21 at 09:28

1 Answers1

1

This is because launch(args); is a "predefined" JavaFX method, located in an abstract class.

Take a look at the following:
As you can see, the method only accepts one argument.

public static void launch(String... var0) {
      // Heres the logic
}

To Fix that, you could do the following:

  1. Declare your Map<String, String> outside of your main()
  2. Only initialize it in your main method
  3. Access it via this.userInformation in your start-method
    To visualize everything, heres some code
public class Gui {

   private static Map<String, String> userInformation;

   public static void main(String[] args) {
      
      // All the other logic
      userIformation = scanDocument(file);
      launch(args);
   }

   public static void start(Stage primaryStage) {
      
      // All the other logic
      // Here you can access your Map<> by
      // simply using userInformation.blablabla();
   
}

I hope this helped you a at least a little bit.

And also... Please never use german words or none of the english letters (like öäü) in variablenames...

Sidenote: Uhrzeitmacher?

Z-100
  • 518
  • 3
  • 19
  • 1
    Instead of "predefined", one might say "`static` method located in an `abstract` class," discussed [here](https://stackoverflow.com/q/17407203/230513). – trashgod Oct 22 '21 at 16:25