I have been stuck on this for days! I am trying to call some methods once a button is pressed but i keep getting errors that the methods cant be found, I have tried a lot of different stuff but nothing is working. Here is the main class with the methods as well as the GUI class (where the problem of calling methods from the main class is happening.) and the last one is the Test class to run everything.
GUI
Test class
any help here would be SERIOUSLY appreciated. thanks in advance.
Your method setScores(double[] score) belongs to the Judging class. You are trying to invoke it from the JudgingGUI class.
Hint: Can you invoke a method without having a reference to the object which is the owner of the method?
Imagine a User class with a method getMailID() which returns the mail ID of that user.
Now imagine two users Andrew and Maneesh
Now imagine some class invoking the method getMailID() like the way you have coded.
Would the JVM know whose mail ID you are asking for? Andrew's or Maneesh's?
Just remember, whenever you invoke setScores() you would want to invoke it on the same instance. So it the judge should be stored as a class variable in your JudgingGUI
Maneesh Godbole wrote:No. What you have there is a static method
What you need to do is obtain an instance of the Judging class and then invoke the setScores on it.
Just remember, whenever you invoke setScores() you would want to invoke it on the same instance. So it the judge should be stored as a class variable in your JudgingGUI
this is obviously not that clear to me, I'm not 100% sure where to put
Judging judge=new Judging(); I tried a couple places but i get an error "cannot find symbol - variable judge" in the same place where i was getting errors before
Maneesh Godbole wrote:No. What you have there is a static method
What you need to do is obtain an instance of the Judging class and then invoke the setScores on it.
Just remember, whenever you invoke setScores() you would want to invoke it on the same instance. So it the judge should be stored as a class variable in your JudgingGUI
this is obviously not that clear to me, I'm not 100% sure where to put
Judging judge=new Judging(); I tried a couple places but i get an error "cannot find symbol - variable judge" in the same place where i was getting errors before