I am having problems with my program. I am altering it to show the GUI which should display the information one product at a time, including the item number, the name of the product, the number of units in stock, the price of each unit, the value of the inventory of that product, the entire inventory, the additional attribute, and the restocking fee. Here is what I've got so far:

package inventory4;

import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class Inventory4 extends JFrame implements ActionListener {

    private class MyPanel extends JPanel {

        ImageIcon image = new ImageIcon("Sample.jpg");
        int width = image.getIconWidth();
        int height = image.getIconHeight();
        long angle = 30;

        public MyPanel() {
            super();
        }

        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2d = (Graphics2D) g;
            g2d.rotate(Math.toRadians(angle), 60 + width / 2, 60 + height / 2);
            g2d.drawImage(image.getImage(), 60, 60, this);
            g2d.dispose();
        }
    }//end class MyPanel
    int currentIndex; //Currently displayed Item
    Product[] supplies = new Product[4];
    JLabel name;
    JLabel number;
    JLabel title;
    JLabel quantity;
    JLabel price;
    JLabel fee;
    JLabel totalValue;
    JTextField nameField = new JTextField(20);
    JTextField numberField = new JTextField(20);
    JTextField titleField = new JTextField(20);
    JTextField quantityField = new JTextField(20);
    JTextField priceField = new JTextField(20);
    JPanel display;
    JPanel displayHolder;
    JPanel panel;

    public Inventory4() {


        setSize(500, 500);
        setTitle("Bob's CD Inventory Program");
//make the panels
        display = new JPanel();
        JPanel other = new JPanel();
        JPanel picture = new MyPanel();
        JPanel centerPanel = new JPanel();
        displayHolder = new JPanel();
        display.setLayout(new GridLayout(7, 1));
//other.setLayout(new GridLayout(1, 1));

//make the labels
        name = new JLabel("Name :");
        number = new JLabel("Number :");
        title = new JLabel("Title :");
        quantity = new JLabel("Quantity :");
        price = new JLabel("Price :");
        fee = new JLabel("Restocking Fee :");
        totalValue = new JLabel("Total Value :");


//Add the labels to the display panel
        display.add(name);
        display.add(number);
        display.add(title);
        display.add(quantity);
        display.add(price);
        display.add(fee);


//Add the panels to the frame

        getContentPane().add(centerPanel, "Center");
        getContentPane().add(other, "South");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
    }
    }

class CD extends Product {

    String genre;
    double restockingFee;

    public CD(String genre, double restockingFee, int item, String title, double stockQuantity,
            double price) {
        //super(title,item, stockQuantity, price);
        this.genre = genre;
        this.restockingFee = restockingFee;

    // TODO Auto-generated constructor stub
    }

    //returns the value of the inventory, plus the restocking fee
    public double getInventoryValue() {
        // TODO Auto-generated method stub
        return super.getItemPrice() + restockingFee;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer("Genre      \t").append(genre).append("\n");
        sb.append(super.toString());

        return sb.toString();
    }
}

//Inventory4.java
class Product implements Comparable {

    private String title;   // class variable that stores the item name
    private int item;     // class variable that stores the item number
    private double stockQuantity;   // class variable that stores the quantity in stock
    private double price;     // class variable that stores the item price
    private String genre;

    public Product() {
        title = "";
        item = 0;
        stockQuantity = 0;
        price = 0.0;
        genre = "";
    }

    public Product(String title, String genre, int item, double stockQuantity, double price) {
        this.title = title;
        this.item = item;
        this.stockQuantity = stockQuantity;
        this.price = price;
        this.genre = genre;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public void setItem(int item) {
        this.item = item;
    }

    public int getItem() {
        return item;
    }

    public void setStockQuantity(double quantity) {
        stockQuantity = quantity;
    }

    public double getStockQuantity() {
        return stockQuantity;
    }

    public void setItemPrice(double price) {
        this.price = price;
    }

    public double getItemPrice() {
        return price;
    }

    public void setGenre(String genre) {
        this.genre = genre;
    }

    public String getGenre() {
        return genre;
    }

    public double calculateInventoryValue() {
        return price * stockQuantity;
    }

    public int compareTo(Object o) {
        Product p = null;
        try {
            p = (Product) o;
        } catch (ClassCastException cE) {
            cE.printStackTrace();
        }
        return title.compareTo(p.getTitle());
    }

    public String toString() {
        return "CD Title: " + title + "\nGenre: " + genre + "\nItem #: " + item + "\nPrice: $" + price + "\nQuantity: " + stockQuantity + "\nValue with restocking fee: $" + (calculateInventoryValue() + (calculateInventoryValue() * .05));
    }
}

public class Inventory4 {

    Product[] supplies;

    public static void main(String[] args) {
        Inventory4 inventory = new Inventory4();
        inventory.addProduct(new Product("Mozart", "Classical", 1, 54, 11.50));
        inventory.addProduct(new Product("Beethoven", "Classical", 2, 65, 12.00));
        inventory.addProduct(new Product("Tiny Tim", "Classical", 3, 10, 1.00));

        System.out.println("Inventory of CD's:\n\n");


        System.out.println();
        inventory.showInventory();
        System.out.println();

        double total = inventory.calculateTotalInventory();
        System.out.println("Total Value is: $" + (total + (total * .05)));


    }

    public void sortByName() {
        for (int i = 1; i < supplies.length; i++) {
            int j;
            Product val = supplies[i];
            for (j = i - 1; j > -1; j--) {
                Product temp = supplies[j];
                if (temp.compareTo(val) <= 0) {
                    break;
                }
                supplies[j + 1] = temp;
            }
            supplies[j + 1] = val;
        }
    }

    //creates a String representation of the array of products
    public String toString() {
        String s = "";
        for (Product p : supplies) {
            s = s + p.toString();
            s = s + "\n\n";
        }
        return s;
    }

    //Using an array so adding an item requires us to increase the size of the array first
    public void addProduct(Product p1) {
        if (supplies == null) {
            supplies = new Product[0];
        }
        Product[] p = supplies; //Copy all products into p first
        Product[] temp = new Product[p.length + 1]; //create bigger array
        for (int i = 0; i < p.length; i++) {
            temp[i] = p[i];
        }
        temp[(temp.length - 1)] = p1; //add the new product at the last position
        supplies = temp;
    }

    //sorting the array using Bubble Sort
    public double calculateTotalInventory() {
        double total = 0.0;
        for (int i = 0; i < supplies.length; i++) {
            total = total + supplies[i].calculateInventoryValue();
        }
        return total;
    }

    public void showInventory() {
        System.out.println(toString()); //call our toString method
    }
}

here are the error msgs:
[Compiling 1 source file to C:\Documents and Settings\Bob Jefferson\My Documents\NetBeansProjects\Inventory4_4\build\classes
C:\Documents and Settings\Bob Jefferson\My Documents\NetBeansProjects\Inventory4_4\src\inventory4\Inventory4.java:201: duplicate class: inventory4.Inventory4
public class Inventory4 {
C:\Documents and Settings\Bob Jefferson\My Documents\NetBeansProjects\Inventory4_4\src\inventory4\Inventory4.java:8: inventory4.Inventory4 is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
public class Inventory4 extends JFrame implements ActionListener {
/TEX]

you have 2 classes with the same name in that package. That's not allowed.
Keep classes one to a sourcefile, much easier (and as in that case the file should have the name of the class you can't create more than one class with the same name per package any longer).

The other is clear. You define your class to implement an interface or abstract class but don't actually implement the methods you need to.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.