title: Display an array of objects in a GUI
body: <p>I am working on a program that is supposed to track the inventory of Blu-ray movies.  I have stored the movies in an object array (the array stores the name, ID, number of discs, and price of each movie).  I know ArrayLists are a more efficient way of storing the objects in an array, but for the purpose of this assignment I am required to use an array.  I have previously had this program print out to the console with not problem, but I'm trying to add this program to a GUI.  I have already written a class for the GUI, but I cannot figure out how to add the arrays to the JPanel and JFrame.</p>
  
  <p>Here is my GUI class:</p>
  
  <pre><code>class TextInFrame extends JFrame {
  
      private JLabel greeting;
      private JLabel inventoryUnsorted;
      private JPanel panel;
  
      public TextInFrame(){
          super("Blu-ray Movie Inventory");
          setLayout(new FlowLayout());
          JFrame.setDefaultLookAndFeelDecorated(true);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setLocationRelativeTo(null);
          pack();
          setVisible(true);
  
          panel = new JPanel();
          greeting = new JLabel(BluRay.programGreeting());
          add(greeting);
          greeting.setVerticalTextPosition(JLabel.BOTTOM);
          greeting.setHorizontalTextPosition(JLabel.CENTER);
          panel.add(greeting);
          this.add(panel);
     }
  }
  </code></pre>
  
  <p>Here is a portion of my main method that has the</p>
  
  <pre><code>public class Inventory {
  
  public static void main(String[] args) {
  
      TextInFrame window = new TextInFrame();
      window.setSize(600, 600);
  
      BluRay[] movies = new BluRay[5];
  
      movies[0] = new BluRay("Man of Steel", "48461", 24, 17.99);
      movies[1] = new BluRay("Fast Five", "84624", 10, 12.99);
      movies[2] = new BluRay("Batman Begins", "15483", 19, 13.98);
      movies[3] = new BluRay("X-Men", "48973", 6, 15.99);
      movies[4] = new BluRay("The Outsiders", "01893", 16, 9.98);
  
      String[] stringArray = Arrays.copyOf(movies, movies.length, String[].class);
  
  
      // loop to print through the BluRay movies array
      for (String string : stringArray) {
          System.out.println(string);
      }
  </code></pre>
  
  <p>Every time I try to add the array into a JLabel or JPanel, I get the error "BluRay[] cannot be converted to String".  I am completely stumped on how to get this information in the GUI.  I am also having trouble with the greeting in the JPanel.  It is not wrapping when the JFrame is resized.  STUMPED.</p>