Jump to content
macalroy

JavaFX

Recommended Posts

JavaFX applications need a no-args constructor and the controller class doesn't take the argument and act as a controller for some reason

 

I see, I've never touched JavaFX so I'm not exactly sure how to do this the best way.

Have you seen this? http://stackoverflow.com/questions/30814258/javafx-pass-parameters-while-instantiating-controller-class

 

Alternatively, if you don't really care about the code design you could just have a static getter in your main class, or in some sort of data class.

Link to comment
Share on other sites

// don't forget the manifest
public class Unicorns extends Script {

    public static Script script;

    @ Override
    public void onStart() {
        script = this;
    }
    
    @ Override
    public int onLoop() {
        return 69;
    }

}

This wonderful piece of code solves all your OOP problems

Edited by Token
Link to comment
Share on other sites

I see, I've never touched JavaFX so I'm not exactly sure how to do this the best way.

Have you seen this? http://stackoverflow.com/questions/30814258/javafx-pass-parameters-while-instantiating-controller-class

 

Alternatively, if you don't really care about the code design you could just have a static getter in your main class, or in some sort of data class.

 

Alright, well I can't pass arguments to the Controller/Test classes properly so I'll have to do that. How can I go about doing that because it won't let me reference Script from a static context

 

// don't forget the manifest
public class Unicorns extends Script {

    public static Script script;

    @ Override
    public void onStart() {
        script = this;
    }
    
    @ Override
    public int onLoop() {
        return 69;
    }

}
This wonderful piece of code solves all your OOP problems

 

I think I'm retarded

Edited by Orient
  • Like 1
Link to comment
Share on other sites

// don't forget the manifest
public class Unicorns extends Script {

    public static Script script;

    @ Override
    public void onStart() {
        script = this;
    }
    
    @ Override
    public int onLoop() {
        return 69;
    }

}

This wonderful piece of code solves all your OOP problems

 

 

Feel like starting a debate so Ill go ahead and say that I wouldn't call it wonderful, bad code design and lack of encapsulation.

 

Your turn.

Link to comment
Share on other sites

Feel like starting a debate so Ill go ahead and say that I wouldn't call it wonderful, bad code design and lack of encapsulation.

 

Your turn.

 

Well, there's really no alternative in this case unless you can somehow pass a constructor to an application class to retrieve the Script methods.

Link to comment
Share on other sites

Well, there's really no alternative in this case unless you can somehow pass a constructor to an application class to retrieve the Script methods.

 

As a further note, I don't think you should be accessing Script methods in your JavaFX, instead of creating a Script instance, create a Unicorns instance (as demonstrated in @@Token's demonstration) and use that to pass the needed data into main.

Just a thought, don't have to do it but I think its better practice

  • Like 1
Link to comment
Share on other sites

As a further note, I don't think you should be accessing Script methods in your JavaFX, instead of creating a Script instance, create a Unicorns instance (as demonstrated in @@Token's demonstration) and use that to pass the needed data into main.

Just a thought, don't have to do it but I think its better practice

 

Well, I'm just grabbing things like name among other things, I just needed to gain access to those

 

Nope, still retarded. Just going to pull the data from a separate class like a good little boy. Don't know what I'm talking about.

Edited by Orient
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...