Jump to content

gui question


Joseph

Recommended Posts

i have an Enum i would like to add into my gui combo box. im to lazy to retype them in a array string. i also no if i do this

JComboBox<CraftingTable> craftingTableList = new JComboBox(CraftingTable.values());

 i will get all my variable in my Enum in the combo box but the only problem is that they all in caps with and underscore and that looks unprofessional. i also no that you could add

JComboBox<String> craftingTableList = new JComboBox(arrayString);

and they will be in an the combo box. So i thought maybe if i create a String array method with the names of the Enum i could easly add them in my gui.

 

my Method:

	public static String[] getAll()	{
		List<String> list = new ArrayList<String>();
		for (CraftingTable c: values())
			if (c!=null)
				list.add(c.getName());
		return (String[]) list.toArray();
	}

//in my enum
this.name = super.name().charAt(0) + super.name().substring(1).toLowerCase().replace("_", " ");

my gui:

JComboBox<String> craftingTableList = new JComboBox(CraftingTable.getAll());

 but it doesnt show anything in my gui. Any way i could do what i want. 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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