converting my code to match gui

I am having trouble turning code that I have into strings so it can compile with the GUI I have written.  The code does what it needs to do but I just need it to complie with GUI so it can run properly.  I know I need to use strings but I am very shady on how to convert what to srtings and how.  I not sure if I can keep my arrays and add in the needed methods.  Any and all help is appreciated.  Here is my model code and my GUI.

Model Code:

import java.util.*;

public class test {    
     static String phonenumber="2334567";
     public static void main(String[] args){
          int i=transferr();
     }
     private static int transferr(){
          ArrayList a1=new ArrayList();
          ArrayList a2=new ArrayList();
          a2.add("a");
          a2.add("b");
          a2.add("c");
          ArrayList a3=new ArrayList();
          a3.add("d");
          a3.add("e");
          a3.add("f");
          ArrayList a4=new ArrayList();
          a4.add("g");
          a4.add("h");
          a4.add("i");
          ArrayList a5=new ArrayList();
          a5.add("j");
          a5.add("k");
          a5.add("l");
          ArrayList a6=new ArrayList();
          a6.add("m");
          a6.add("n");
          a6.add("o");
          ArrayList a7=new ArrayList();
          a7.add("p");
          a7.add("q");
          a7.add("r");
          a7.add("s");
          ArrayList a8=new ArrayList();
          a8.add("t");
          a8.add("u");
          a8.add("v");
          ArrayList a9=new ArrayList();
          a9.add("w");
          a9.add("x");
          a9.add("y");
          a9.add("z");
          ArrayList a0=new ArrayList();    

          ArrayList b=new ArrayList();
         
          for(int i=0;i<phonenumber.length();i++){
               char c=phonenumber.charAt(i);
               switch(c){
                    case '1':
                         System.out.println("Invalid number");
                         return -1;                                                  
                    case '2':
                         b.add(a2);
                         break;
                    case '3':
                         b.add(a3);
                         break;
                    case '4':
                         b.add(a4);
                         break;
                    case '5':
                         b.add(a5);
                         break;
                    case '6':
                         b.add(a6);
                         break;
                    case '7':
                         b.add(a7);
                         break;
                    case '8':
                         b.add(a8);
                         break;
                    case '9':
                         b.add(a9);
                         break;
                    case '0':
                         System.out.println("Invalid number");
                         return -1;                                            
               }              
          }    
         
          System.out.println(b);
          ArrayList result=new ArrayList();          
          ArrayList result1=new ArrayList();
          String s=new String();
          for(int m=0;m<b.size();m++){              
               ArrayList thisresult=(ArrayList)b.get(m);
               for(int n=0;n<thisresult.size();n++){                    
                    if(result.size()<thisresult.size()){
                         result.add(thisresult.get(n));
                    }else{          
                         int l=result.size();
                         for(int k=0;k<l;k++){
                              s=(String)result.get(k);
                              s=s+(String)thisresult.get(n);
                              result.add(s);    
                         }                        
                    }                    
               }              
               for (int mm=0;mm<result.size();mm++){
                    if(((String)result.get(mm)).length()==m+1){                        
                         result1.add(result.get(mm));
                    }
               }
               result=new ArrayList(result1);
               result1=new ArrayList();
          }
               
          System.out.println(result);
          return 0;
     }
}


GUI:

private TelephoneWordsModel theModel;

  /**
   * JButton to let the stuff go
   */
   private JButton goButton;

  /**
   * JTextArea to get the input from the user
   */
  private JTextArea inputArea;

  /**
   * JTextArea to show the output to the user
   */
  private JTextArea outputArea;

  /**
   * Default constructor to setup the window
   * @since 1.0
   */
  public MoneyGUI() {
    //For the application setup the window
    if (this instanceof JFrame) {
      setSize(500,200);
      setLocation(40,40);
      setTitle("Telephone Words");
      setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    //Initialize instance variables
    theModel = new TelephoneWordsModel();
    goButton = new JButton("Go");
    goButton.addActionListener(this);
    inputArea = new JTextArea(1,10);
    outputArea = new JTextArea(3,40);
    outputArea.setEditable(false);
    outputArea.setLineWrap(true);
    outputArea.setWrapStyleWord(true);

    //Setup top panel
    JPanel topPanel = new JPanel();
    JLabel numLabel = new JLabel("Number to translate: ");
    topPanel.add(numLabel);
    topPanel.add(inputArea);    

    //Setup center panel
    JPanel centerPanel = new JPanel();
    JLabel outLabel = new JLabel("Number as text: ");
    centerPanel.add(outLabel);
    centerPanel.add(outputArea);
   
    this.getContentPane().add(topPanel,BorderLayout.NORTH);
    this.getContentPane().add(centerPanel,BorderLayout.CENTER);
    this.getContentPane().add(goButton,BorderLayout.SOUTH);
  }

  public void actionPerformed (ActionEvent e) {
    try {
      String inText = inputArea.getText();
      double inValue = Double.parseDouble(inText);
      theModel.setPhonenumber(inValue);
      outputArea.setText(theModel.getTelephoneWords());
    }
    catch (NumberFormatException except) {
      outputArea.setText("You have input a non-numeric value");
      inputArea.setText("");
    }
  }

  /**
   * Main method to get stuff started
   * @since 1.0
   */
  public static void main (String args[]) {
    TelephoneWordsGUI myGUI = new TelephoneWordsGUI();
    myGUI.show();
  }
}
DreamWeaver777Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tdisessaCommented:
Change:

     private static int transferr(){
 

to:

     public static String transferr(String phoneNumber){
         this.phonenumber = phoneNumber;

In order to pass a string into the method and output a string from the method
----

Change:

          System.out.println(result);
          return 0;
     }

to:

          System.out.println(result);
          return result;
     }

in order to output your string
----

Change:

      theModel.setPhonenumber(inValue);
      outputArea.setText(theModel.getTelephoneWords());


to:

   outputArea.setText(test.transferr(inText ));

To input your new number and then send it to the testarea

----

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.