I have 2 JComboBoxes that are using an itemListener, right now the code I have compiles but when I call for tankSize and fuelCost to complete my calculations nothing is returned and my answer is always zero. What do I need to change so the variables transfer to tankSize and fuelCost? Thanks for any help you can offer.
Here is the part of the code I'm trying to get to work:
JComboBox vehicleBox= (JComboBox)ie.getSource();
String tank = (String)ie.getItem();
if(tank == "Compact")
{
tankSize = compactTank;
}
else if(tank == "Mid-Size")
{
tankSize = midSizeTank;
}
else if(tank == "Luxury")
{
tankSize = luxuryTank;
}
else if(tank == "SUV")
{
tankSize = suvTank;
}
JComboBox fuelBox = (JComboBox)ie.getSource();
String fuelType = (String)ie.getItem();
if(fuelType == "Leaded")
{
fuelCost = leadedCost;
}
else if(fuelType == "Unleaded")
{
fuelCost = unleadedCost;
}
else if(fuelType == "Super Unleaded")
{
fuelCost = superUnleadedCost;
}
else if(fuelType == "Diesel")
{
fuelCost = dieselCost;
}