I need some assistance with three things in my code. My problems are: Next and Previous buttons do not loop through the array, instead they throw exception errors when they get to the end of the array. Second my image that is required does not show up, my instructor said that I needed to resize the logo, which I have and have also added another .java file to give the logo a preferred size. Third which is not as important is that I need to have the total value of the inventory added with each pass through each part of the array. I have never been able to get this to work. I have taken full advantage of all resource before coming here this is my last resource, and my instructor is not helping me with this anymore.
Thank you in advance for all of the assistance.

package inventory;//Imortation of all required actions.
import java.awt.GridLayout;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.util.Arrays;
import java.text.NumberFormat;
import javax.swing.ImageIcon;


public class FrameHelper extends JFrame{//Begin Frame Helper class
    private JPanel gridPanel=new JPanel();//sets the grid
    private JPanel panel=new JPanel();//sets the panels

    //Establishes all buttons
    JButton firstButton;
    JButton nextButton;
    JButton lastButton;
    JButton prevButton;

    //Establishes the Text output Field
    JTextField nameField;
    JTextField numberField;
    JTextField ratingField;
    JTextField priceField;
    JTextField unitsinInventoryField;
    JTextField inventoryPriceField;
    JTextField totalValueField;
    JTextField restockfeeField;

    //Establishes the Left Label Panel
    JLabel lblName;
    JLabel lblNumber;
    JLabel lblRating;
    JLabel lblPrice;
    JLabel lblUnitsinInventory;
    JLabel lblInventoryPrice;
    JLabel lblTotalValue;
    JLabel lblRestockFee;
    JLabel lblLogo;
    JLabel lblCName;

    //Establishes the DVD collection
    DVD dvd1;
    DVD dvd2;
    DVD dvd3;
    DVD dvd4;
    DVD dvd5;

    //Establishes the Array
    public static final int Max_DVD=5;
    DVD[] item=new DVD[Max_DVD];
    static int ArrayIndex=0;
    NumberFormat nf=NumberFormat.getCurrencyInstance();//Formats all Currency
    
    public FrameHelper(){//Begin DVD Setup

        //DVD 1 setup
        dvd1=new DVD();
        dvd1.setName("National Security DVD");
        dvd1.setNumber(43396782);
        dvd1.setPrice(14.99);
        dvd1.setUnitsinInventory(203);
        dvd1.setRating("PG-13");
        dvd1.sumTotalValue(dvd1.getTotalValue());

        //DVD 2 setup
        dvd2=new DVD();
        dvd2.setName("StarGate Atlantis: Rising DVD");
        dvd2.setNumber(27616924);
        dvd2.setPrice(14.99);
        dvd2.setUnitsinInventory(351);
        dvd2.setRating("Not Rated");
        dvd2.sumTotalValue(dvd2.getTotalValue());

        //DVD 3 setup
        dvd3=new DVD();
        dvd3.setName("The X-Files DVD");
        dvd3.setNumber(24543195);
        dvd3.setPrice(9.99);
        dvd3.setUnitsinInventory(193);
        dvd3.setRating("PG-13");
        dvd3.sumTotalValue(dvd3.getTotalValue());

        //DVD 4 setup
        dvd4=new DVD();
        dvd4.setName("Trapped in Paradise DVD");
        dvd4.setNumber(24543122);
        dvd4.setPrice(9.99);
        dvd4.setUnitsinInventory(69);
        dvd4.setRating("PG-13");
        dvd4.sumTotalValue(dvd4.getTotalValue());

        //DVD 5 setup
        dvd5=new DVD();
        dvd5.setName("Left Behind II: Tribulation Force");
        dvd5.setNumber(43396851);
        dvd5.setPrice(19.99);
        dvd5.setUnitsinInventory(371);
        dvd5.setRating("Not Rated");
        dvd5.sumTotalValue(dvd5.getTotalValue());
        

        //Set array and corresponding DVD number
        item[0]=dvd1;
        item[1]=dvd2;
        item[2]=dvd3;
        item[3]=dvd4;
        item[4]=dvd5;
        
        //Adds the Inventory Value at each Item for a Complete Inventory Value
        for(int i = 0; i<item.length; i++){
            item[i].getTotalValue();
        }
            
        //Create GUI Layout of Grid
        gridPanel.setLayout(new BorderLayout());
        gridPanel.add(this.createLabelPanel(), BorderLayout.WEST);
        gridPanel.add(this.createTextPanel(), BorderLayout.CENTER);
        gridPanel.add(this.createButtonPanel(), BorderLayout.SOUTH);
        add(gridPanel);
    }
    private JPanel createButtonPanel(){//Create the Buttons
        ActionListener btnListen=new ButtonListener();

        //Creates First Button
        firstButton=new JButton("First Item");
        firstButton.setActionCommand("First");
        firstButton.addActionListener(btnListen);

        //Creates Next Button
        nextButton=new JButton("Next Item");
        nextButton.setActionCommand("Next");
        nextButton.addActionListener(btnListen);

        //Creates Previous Button
        prevButton=new JButton("Previous Item");
        prevButton.setActionCommand("Previous");
        prevButton.addActionListener(btnListen);

        //Create Last Button
        lastButton=new JButton("Last Item");
        lastButton.setActionCommand("Last");
        lastButton.addActionListener(btnListen);

        //Adds the Buttons into the GUI
        JPanel panel=new JPanel();
        panel.add(firstButton);
        panel.add(nextButton);
        panel.add(prevButton);
        panel.add(lastButton);
        return panel;//Returns the Button Panel
    }

    private JPanel createLabelPanel(){//Begin Label panel
        ImageIcon logo=new ImageIcon(".\\src\\Logo.jpeg ");//Logo source
        lblLogo=new JLabel(logo);//Logo
        //Product label information
        lblName=new JLabel("Name:");
        lblNumber=new JLabel("Number:");
        lblRating=new JLabel("Rating:");
        lblPrice=new JLabel("Price:");
        lblUnitsinInventory=new JLabel("Units in Inventory:");
        lblInventoryPrice=new JLabel("The Price of the Inventory is:");
        lblTotalValue=new JLabel("The Total Value of the Inventory is:");
        lblRestockFee=new JLabel("The Restock Fee is:");
        //End of Product label information

        panel=new JPanel();
        panel.setLayout(new GridLayout(10,1));
        
        //Add Panel Labels
        panel.add(lblLogo);
        panel.add(lblName);
        panel.add(lblNumber);
        panel.add(lblRating);
        panel.add(lblPrice);
        panel.add(lblUnitsinInventory);
        panel.add(lblInventoryPrice);
        panel.add(lblTotalValue);
        panel.add(lblRestockFee);
        
        return panel;//Returns the left collum panel
    }//End Panel Creation

    private JPanel createTextPanel(){//Begins the Text Panel
        lblCName=new JLabel("Deuce Unlimited");//Company Name
        
        //Sets all of the product information into the Text Field
        nameField=new JTextField();
        nameField.setEditable(false);

        numberField=new JTextField();
        numberField.setEditable(false);

        ratingField=new JTextField();
        ratingField.setEditable(false);

        priceField=new JTextField();
        priceField.setEditable(false);

        unitsinInventoryField=new JTextField();
        unitsinInventoryField.setEditable(false);

        inventoryPriceField=new JTextField();
        inventoryPriceField.setEditable(false);

        totalValueField=new JTextField();
        totalValueField.setEditable(false);

        restockfeeField=new JTextField();
        restockfeeField.setEditable(false);
        //End of Text Field Set

        panel=new JPanel();
        panel.setLayout(new GridLayout(10,1));
        
        //Adds all Product Text Fields
        panel.add(lblCName);
        panel.add(nameField);
        panel.add(numberField);
        panel.add(ratingField);
        panel.add(priceField);
        panel.add(unitsinInventoryField);
        panel.add(inventoryPriceField);
        panel.add(totalValueField);
        panel.add(restockfeeField);
        return panel;//Returns the text field
    }//Ends the creation of the Text Field

    class ButtonListener implements ActionListener
    {//Begins the Button and Action Listener Handling
        public void actionPerformed(ActionEvent e){

            Arrays.sort(item, new InventorySort());
            totalValueField.setText(String.valueOf(nf.format(
                    item[ArrayIndex].getTotalValue())));
            if (e.getActionCommand().equals("First"))
               {//All relevants to the First Button
                    nameField.setText(item[ArrayIndex].getName());
                    numberField.setText(String.valueOf(
                            item[ArrayIndex].getNumber()));
                    ratingField.setText(String.valueOf(
                            item[ArrayIndex].getRating()));
                    priceField.setText(String.valueOf(nf.format(
                            item[ArrayIndex].getPrice())));
                    unitsinInventoryField.setText(String.valueOf(
                            item[ArrayIndex].getUnitsinInventory()));
                    inventoryPriceField.setText(String.valueOf(nf.format(
                            item[ArrayIndex].getInventoryPrice())));
                    restockfeeField.setText(String.valueOf(nf.format(
                            item[ArrayIndex].reStockFee())));
                    ArrayIndex=0;
                }//End First Button
            if (e.getActionCommand().equals("Next")){//Next Button Actions
                if(ArrayIndex>item.length){ArrayIndex=0;}//Used to loop through
                //Inventory Array
                else{
                    nameField.setText(item[ArrayIndex].getName());
                    numberField.setText(String.valueOf(
                            item[ArrayIndex].getNumber()));
                    ratingField.setText(String.valueOf
                            (item[ArrayIndex].getRating()));
                    priceField.setText(String.valueOf(nf.format(
                            item[ArrayIndex].getPrice())));
                    unitsinInventoryField.setText(String.valueOf(
                            item[ArrayIndex].getUnitsinInventory()));
                    inventoryPriceField.setText(String.valueOf(nf.format(
                            item[ArrayIndex].getInventoryPrice())));
                    restockfeeField.setText(String.valueOf(nf.format(
                            item[ArrayIndex].reStockFee())));
                    ArrayIndex=ArrayIndex+1;
                }//End else
            }//End Next Button
            if (e.getActionCommand().equals("Previous")){//Previous Button Actions
                
                    nameField.setText(item[ArrayIndex].getName());
                    numberField.setText(String.valueOf(
                            item[ArrayIndex].getNumber()));
                    ratingField.setText(String.valueOf(
                            item[ArrayIndex].getRating()));
                    priceField.setText(String.valueOf(nf.format(
                            item[ArrayIndex].getPrice())));
                    unitsinInventoryField.setText(String.valueOf(
                            item[ArrayIndex].getUnitsinInventory()));
                    inventoryPriceField.setText(String.valueOf(nf.format(
                            item[ArrayIndex].getInventoryPrice())));
                    restockfeeField.setText(String.valueOf(nf.format(
                            item[ArrayIndex].reStockFee())));
                    ArrayIndex=ArrayIndex-1;
                
                }//End Previous
            if (e.getActionCommand().equals("Last"))
                {//Last Button Actions
                    nameField.setText(item[ArrayIndex].getName());
                    numberField.setText(String.valueOf(
                            item[ArrayIndex].getNumber()));
                    ratingField.setText(String.valueOf(
                            item[ArrayIndex].getRating()));
                    priceField.setText(String.valueOf(nf.format(
                            item[ArrayIndex].getPrice())));
                    unitsinInventoryField.setText(String.valueOf(
                            item[ArrayIndex].getUnitsinInventory()));
                    inventoryPriceField.setText(String.valueOf(nf.format(
                            item[ArrayIndex].getInventoryPrice())));
                    restockfeeField.setText(String.valueOf(nf.format(
                            item[ArrayIndex].reStockFee())));
                    ArrayIndex=4;
                }//End Last
        }//End Action Events

    }//End Button Class

    
}//End Frame Helper Class

This is where the problems are. The below is only of the image class that I created to help with resizing the file. If it is not needed please let me know.

package inventory;

import java.awt.Dimension;
import javax.swing.JPanel;
public class Logo extends JPanel {
	public Logo() {
		super();
		setPreferredSize(new Dimension(200,200));
        }
    }
Attachments Logo.jpg 4.07 KB

I have solved the problem with the buttons.
Next button:

if (ArrayIndex==(item.length-1)){ArrayIndex=0}

The previous button is the same logic reversed.
I still need some assistance with the image.

This question has already been answered. Start a new discussion instead.