How do I get these windos to communicate? I am lost...

I am a computer science student who was not happy with the scope of entry level programming classes. I am taking it on my self to learn the nuts and bolts of Java. Right now, I am working with GUIs for the first time and I am lost with this (probably simple) concept.
I have a class Main Menu which creates a window with several options; one of these options is to open a second window which allows a user to make a selection. I want for this selection to be imported back into the main menu.
The following code is from the Main Menu class, it launches the window and imports selected information
               if ( action == "Food Facts"){
                    FoodFacts food = new FoodFacts();
                    food.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                    food.setSize(300,300);
                    food.setVisible(true);
                    /*This opens the next window. It works fine; however,
                      the code below, which sets the information, executes
                      immediately after the window opens. This results in
                      the return of null values. */
                    name.setText(food.name());
                    calsPerServing.setText(food.cals());
                    servingSize.setText(food.Serving());
                    convertList.setSelectedIndex(food.indexOut());}This is from the other class (Food Facts). It determines selection and prepares the selection to be passed on:
                    if ( action == "Import"){
                         format = que.toCharArray();
                         toNumber = Character.getNumericValue(format[1]) - 1;
                              switch(format[0]){
                                   case 'M':
                                        nameOut = MeatTypes[toNumber];
                                        calsOut = MeatCals[toNumber];
                                        servOut = MeatMeasure[toNumber];
                                        sizeOut = index[toNumber];
                                        break;
                                   case 'L':
                                        nameOut = LiquidTypes[toNumber];
                                        calsOut = LiquidCals[toNumber];
                                        servOut = LiquidMeasure[toNumber];
                                        sizeOut = index4[toNumber];
                                        break;
                                   case 'S':
                                        nameOut = SpiceTypes[toNumber];
                                        calsOut = SpiceCals[toNumber];
                                        servOut = SpiceMeasure[toNumber];
                                        sizeOut = index5[toNumber];
                                        break;
                                   case 'P':
                                        nameOut = PlantCals[toNumber];
                                        calsOut = PlantCals[toNumber];
                                        servOut = PlantMeasure[toNumber];
                                        sizeOut = index2[toNumber];
                                        break;
                                   default:
                                           JOptionPane.showMessageDialog(null,"Please make a selection or click cancel.",
                                             "No Selection Found",JOptionPane.ERROR_MESSAGE);
                                        break;};
                              if(format[0] != 'N')
                                   dispose();}
          public String name(){
               return nameOut;}
          public String cals(){
               return calsOut;}
          public String Serving(){
               return  servOut;}
          public int indexOut(){
               return sizeOut;}}If anyone has any suggestions on how I can get these values set it would be greatly appreciated.
Thanks
Joseph

Well, considering that the posts are 3 weeks apart and that your earlier post (on 18 April) didn't include any code, it's not, strictly speaking, a cross post. But I don't blame morgalr for being peeved that you didn't respond to the advice given on your [earlier post|http://forum.java.sun.com/thread.jspa?threadID=5287276].
Around here, that's a very good way not to get help.
db

Similar Messages

Maybe you are looking for