i have to make this food selector for a uni project and i was wondering if someone could help me i need it to when i click on the desert list it puts the information in to some lables.
this is what i have so far but it genarates a error :/
C:\Users\houlahan\MenuApplication\src\FoodSelectorGUI.java:84: cannot find symbol
symbol : method getSelectedValue()
location: class FoodList
Food selectedfood = (Food)foodlist.getSelectedValue();
C:\Users\houlahan\MenuApplication\src\FoodSelectorGUI.java:86: setAllTextFields(Food) in FoodSelectorGUI cannot be applied to (FoodList)
setAllTextFields(foodlist);
any ideas please?
thanks in advanced masterhoulahan.
The 'foodlist' variable clearly isn't the type you think it is. Unfortunately, you haven't posted the declaration or code for foodlist', so it's not possible to say more.
I don't think Helstorm's suggestion has merit (i.e. is a 'foodlist' an instance of type 'Food'? unlikely - given the context, it's probably a list of type 'Food').
To arrive at the simple is difficult...
R. Elisha
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
ive uploaded what i have got so far basicly i want it to return the price of the food and the amount of calories in t a lable when an item is selected from the jlist and the data comes from the food class.
I was hoping you'd take my hint, but apparently not.
If you want to get the selected value, you should call getSelectedValue() on an object that has that method, e.g. desertlst.
Incidentally, it's not good practice to use floating-point types like double for money values. Use an integral type such as long or BigInteger and store the money in the lowest denomination.
Imagination is more important than knowledge...
A. Einstein
Last edited by dlorde; March 5th, 2009 at 06:16 AM.
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.