title: Displaying an array list item by item in GUI
body: <p>I am trying to display an array list with multiple types, item by item. So I suppose this is a two part question. First, how do I convert this array list to a string in order to print it out (I am not sure how important this is). And second how do I move from item to item using an ActionEvent. </p>
  
  <p>My Array list has String, int, int, double. I have already figured out how to format the double to be a string, however how do I do this for the entire arraylist? The arraylist is already sorted in order to display it in alphabetical order. </p>
  
  <p>Below is my array list and the sorting</p>
  
  <pre><code>inventory.add(new inventoryItem("Pencil", 1111, 50, .25));
      inventory.add(new inventoryItem("Pen", 2222, 50, 1.00));
      inventory.add(new inventoryItem("Marker", 3333, 5, 2.00));
      inventory.add(new inventoryItem("Notebook", 4444, 10, 2.50));
      inventory.add(new officeSupplyItem("Mechanical Pencil", 1112, 25, .50));
      inventory.add(new officeSupplyItem("Lead Pencil", 1113, 25, .25));
      inventory.add(new officeSupplyItem("Blue Pen", 2221, 25, 1.00));
      inventory.add(new officeSupplyItem("Black Pen", 2223, 5, 1.00));
      inventory.add(new officeSupplyItem("Red Pen", 2224, 20, 1.00));
      inventory.add(new officeSupplyItem("Steno Notebook", 4441, 5, 2.50));
      inventory.add(new officeSupplyItem("Legal Pad", 4442, 5, 2.50));
  
      inventory = sortInventory(inventory);
      for (int i = 0; i &lt; inventory.size(); i++) {
          inventory.get(i).output(outputText);
      }
      inventoryTotal(inventory, outputText);
      sortInventory(inventory);
  }
  
  static ArrayList sortInventory(ArrayList&lt;inventoryItem&gt; unsorted) {
      ArrayList&lt;inventoryItem&gt; sorted = new ArrayList&lt;&gt;(); //create new array list to sort
      inventoryItem alpha = null;
      int lowestIndex = -1;
      while (unsorted.size() &gt; 0) { //while my unsorted array is less than 0 do the following
          for (int i = 0; i &lt; unsorted.size(); i++) { //increment through 
              if (alpha == null) {
                  alpha = unsorted.get(i); //get the next line in the inventoryItem array
                  lowestIndex = i;
              } else if (unsorted.get(i).itemName.compareToIgnoreCase(alpha.itemName) &lt; 0) { //compare items to determine which has a higher value
                  alpha = unsorted.get(i);
                  lowestIndex = i;
              }
  
          }
          sorted.add(alpha); //reset the index so it will loop until there are no more items in the unsorted array
          unsorted.remove(lowestIndex);
          alpha = null;
          lowestIndex = -1;
      }
      return sorted; //return the sorted arraylist
  
  }
  </code></pre>
  
  <p>My buttons are set up like this</p>
  
  <pre><code> nextButton.addActionListener(new ActionListener() {
  
          @Override
          public void actionPerformed(ActionEvent e) {
              outputText.append("\n this should move me forward in the list");
  
          }
      });
      previousButton.addActionListener(new ActionListener(){
  
          @Override
          public void actionPerformed(ActionEvent e) {
              outputText.append("\n this should move me backward in the list");
  
          }
      });
  
      exitButton.addActionListener(new ActionListener() { //setup listener for the exit button
  
          @Override
          public void actionPerformed(ActionEvent ae) {
              System.exit(0); //once the exit button is pressed, exit the program
  
          }
  
      });
      thePanel.add(nextButton); //move forward in the arraylist
      thePanel.add(previousButton); //move to previous item in the arraylist
      thePanel.add(exitButton); //add exit button to the panel
  </code></pre>
  
  <p>Any help would be greatly appreciated. </p>