Question JavaFX Combo Box Event Handler Help

Discussion in 'Developer Support' started by Ipwnu2day, May 26, 2016.

  1. I am really new to this JavaFX and I've been following a couple tutorials, I finally made my GUI and was able to load it up. The next step would be handling events which I have no idea how it works. I kind of get the idea on how it works, but I'm not too sure how you would properly add an event.

    I'm using this tutorial ---> Tutorial - JavaFX for Beginners

    But that only explains how the button event is handled.

    I have a combo box of tree types and another combo box with tree locations. I'm trying to make it where if the user selects a tree, there will be limited options of locations on where they can cut.

    So for example if someone selects Oak Tree then location combo box has only 3 options of locations. Or if someone selects Normal Tree there are 5 options of locations.

    Does anyone know a way of implementing the events to the combo boxes?
  2. Nevermind, slash knows.
    #2 Serene, May 27, 2016
    Last edited: May 27, 2016
  3. You'll need to add a listener to the combobox, a ChangeListener would work well for what you're suggesting. In the ChangeListener event, you'd set the items of the other combobox.
    Serene likes this.
  4. Tried adding change listener but I keep getting multiple errors...

    I need a source of a bot that handles the same process as I'm trying to do so I can understand it better. The tutorial that I'm using is not helping me what so ever and still don't understand. Also when you start the bot how do you perform the functions of the bot?

    For example:
    - Select Tree Type
    - Select Location
    - Select Banking

    Then the bot performs the following action given with those 3 options <EXAMPLE: Normal Tree, Varrock, West Bank>
    - Cuts nearest Normal Tree
    - Banks near Location of cutting

    User updates bot settings <EXAMPLE: Willows, Draynor, Draynor's Bank>
    - Bot ends last settings and is updated with new settings
    - Cuts nearest Willow Tree
    - Banks near Location of cutting

    Like I said before I'm new to this whole JavaFX thing.
  5. Put very simple, you could make 3 strings in your main class, create setters for them, then set values for them in your actionevent handler.

    Only showing options based on what a user selects could be done (I assume) by just checking for what option is set and then just adding certain objects to the combobox based on that.
  6. In regards to this, I presume creating arrays with locations per tree would do the trick.

    The event listener grabs the tree and gets the right array of locations to place in the other combo, right?
  7. Well does anyone want to skype me then and show me how its done? Cause I want it done the right way and not end up screwing up.

    Skype User: beastly-scape
  8. Have each enum extend an interface Woodcutting, set combobox Type to Woodcutting ComboBox<Woodcutting>.
    Have a static method getLocations() within your tree enum which pulls an array of Locations and returns it as an ArrayList.

    So for example:
    OAK("Oak", new Location[]{ Location.LUMBRIDGE, Location.DRAYNOR})
    public static ArrayList<Location> getLocations() { ... }
    Then on change:
    --- Double Post Merged, May 27, 2016, Original Post Date: May 27, 2016 ---
    Sorry for the super shitty response I'm at work. Jump on the development Slack chat though.
  9. okay a little more convenient and understandable but I would join the chat but I'm getting no email
  10. Re-navigate to the page and there will be a link to resend the email confirmation. Be sure to check your spam folder too, though I doubt it would be sent there.

Share This Page