I wrote the code for the following 2 combo boxes which display a drop-down list of dorm buildings and meal plans for a college student. The code works, and both boxes are displayed. I have completed what I have to do, but want to find a way to get the total of both categories, and display that value. I am confused as to how to display that value when the array that holds the information is a String.... Is there a way to assign a value to each array item? Here is what I have....

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class Main extends JFrame
    private JPanel dormPanel;
    private JPanel selectedDormPanel;
    private JComboBox dormBox;
    private JLabel dormLabel;
    private JTextField selectedDorm;
    private JPanel mealPanel;
    private JPanel selectedMealPanel;
    private JComboBox mealBox;
    private JLabel mealLabel;
    private JTextField selectedMeal;
    private String[] dorm = { "Allen Hall: $1500/semester", "Pike Hall: $1600/semester", "Farthing Hall: $1200/semester", "University Suites: $1800/semester"};
   private String[] meal = {"7 meals per week: $560/ semester", "14 meals per week: $1,095/ semester", "Unlimited meals: $1,500/ semester"};

public Main()
        setLayout(new BorderLayout());

        add(dormPanel, BorderLayout.CENTER);
        add(selectedDormPanel, BorderLayout.SOUTH);
        add(mealPanel, BorderLayout.CENTER);
        add(selectedMealPanel, BorderLayout.SOUTH);

 private void buildDormPanel()
        dormPanel = new JPanel();
        dormBox = new JComboBox(dorm);
        dormBox.addActionListener(new DormListener());
 private void buildMealPanel()
        mealPanel = new JPanel();
        mealBox = new JComboBox(meal);
        mealBox.addActionListener(new MealListener());
    private void buildSelectedDormPanel()
        selectedDormPanel = new JPanel();
        dormLabel = new JLabel("Dorm: ");
        selectedDorm = new JTextField (25);
    private void buildSelectedMealPanel()
        selectedMealPanel = new JPanel();
        mealLabel = new JLabel("Meal: ");
        selectedMeal = new JTextField (25);
    private class DormListener implements ActionListener

        public void actionPerformed(ActionEvent e) 
            String selection = (String) dormBox.getSelectedItem();
    private class MealListener implements ActionListener
        public void actionPerformed(ActionEvent e)
            String selection = (String) mealBox.getSelectedItem();

    public static void main(String[] args)
        new Dorm();
        new Meal();

Yes, that's what objects are for and you can place any object type you want into a combo box. The toString() value of the object will be displayed as the text if the object is not itself a String. So consider how a small class like this could be used

class DormPlan {

    private String name;
    private int cost;

    public DormPlan(String name, int cost) {
        this.name = name;
        this.cost = cost;

    public String toString() {
        return name + ": $" + cost + "/semester";

    public int getCost(){
        return cost;

(Edit: Example class intentionally left a little bit incomplete.)

@cproud21 why do you have always create new post just continue with same question? Same topic you started here