February 9, 20196 yr 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 ?
February 9, 20196 yr Author 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
Create an account or sign in to comment