bigd123 Posted February 9, 2019 Share Posted February 9, 2019 I know its not TECHNICALLY restricted to just this client but it relates here anyway. I'm trying to have a simple gui where you choose what type of fishing you want done. Right now I just have it for net fishing and fly fishing. The first problem is, I want the enum to be displayed in the gui with a capitalized first letter and multi-line(Example "Fly Fishing".) I'm also having trouble getting what type the user selected in the main code and setting a variable depending on what it is. Here is the code: GUI enum enum Fish { NET, FLY; @Override public String toString() { return name().toLowerCase(); } } And the only code I have for the main part: fish = gui.getSelectedFish(); You can probably tell I'm using Explv's tutorial Quote Link to comment Share on other sites More sharing options...
bigd123 Posted February 9, 2019 Author Share Posted February 9, 2019 I've found the solution, and incase anyone find this and has the same issue, heres the solution: For the actuall enum thing is what I did: enum Fish { NET("Net fishing"), FLY("Fly fishing"); private String displayName; Fish(String displayName) { this.displayName = displayName; } @Override public String toString() { return displayName; } } This basically just uses the string in the parenthesis as what the name displayed in the gui dropdown. For using the value in the code, I did this: fish = gui.getSelectedFish(); if(fish == fish.FLY) { //code } Pretty self explanatory Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.