I receive error at camera.Camera.<init>(Camera.java:19)
at camera.Camera.init(Camera.java:32)
at camera.Camera.<init>(Camera.java:21)
at camera.Camera.init(Camera.java:32)
at camera.Camera.<init>(Camera.java:21)
at camera.Camera.init(Camera.java:32)
at camera.Camera.<init>(Camera.java:21)
at camera.Camera.init(Camera.jav
and continues. Please help, last day

package camera;
import javax.swing.*;
import java.awt.event.*;
import java.awt.event.ActionListener;


/**
 *
 * @author FDR
 */
public final class Camera extends JFrame{

        private JTextArea txt;
	private Camera inv;
	private int currentDisplay = 0;

	public Camera() {
		super("Camera Program");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
		init();
	}

	public void init() {
	
		ActionElectronics p1 = new ActionElectronics(1, "Action Product 1", 3, 59.99, "Misc");
		ActionElectronics p2 = new ActionElectronics(2, "Action Product 2", 1, 28.99, "Other");
		ActionElectronics p3 = new ActionElectronics(3, "Drama Product 1", 4, 25.49, "Other");
		ActionElectronics p4 = new ActionElectronics(4, "Drama Product 2 ", 4, 21.49, "Other");

	
		inv = new Camera();
		inv.add(p1);
		inv.add(p2);
		inv.add(p3);
                inv.add(p4);

		inv.sort();

//	Output

		for (int i = 0; i < inv.size(); i++) {
			System.out.println("Product number: " + inv.get(i).getItem());
			System.out.println("Product name: " + inv.get(i).getName());
			System.out.println("Units in stock: " + inv.get(i).getUnits());
			System.out.println("Price: $" + String.format("%.2f",inv.get(i).getPrice()));
			System.out.println("Total value: $" + String.format("%.2f",inv.get(i).value()));
			System.out.println("Fee: $" + String.format("%.2f",inv.get(i).fee()));
			System.out.println();
		}

		//total
		System.out.println("Total value: $" + String.format("%.2f",inv.value()));

		//GUI
		JPanel panel = new JPanel();
		txt = new JTextArea(15,20);
		txt.setEditable(false);
		panel.add(txt);

		JPanel buttonpanel = new JPanel();
		buttonpanel.setLayout(new BoxLayout(buttonpanel,BoxLayout.Y_AXIS));


		JPanel anotherbuttonpanel = new JPanel();
		anotherbuttonpanel.setLayout(new BoxLayout(anotherbuttonpanel,BoxLayout.Y_AXIS));


		JButton first = new JButton("First");
		first.addActionListener(new ActionListener() {
            @Override
			public void actionPerformed(ActionEvent e) {
				currentDisplay = 0;// go to the beginning
				displayProduct();
			}
		});
		buttonpanel.add(first);
		JButton previous = new JButton("Previous");
		previous.addActionListener(new ActionListener() {
            @Override
			public void actionPerformed(ActionEvent e) {
				if (currentDisplay > 0) {
                    currentDisplay--;
                }
				else {
                    currentDisplay = inv.size() - 1;
                }
				displayProduct();
			}
		});
		buttonpanel.add(previous);
		JButton next = new JButton("Next");
		next.addActionListener(new ActionListener() {
            @Override
			public void actionPerformed(ActionEvent e) {
				if (currentDisplay < inv.size()-1) {
                    currentDisplay++;
                } //advance to the end
				else {
                    currentDisplay = 0;
                }
				displayProduct();
			}
		});
		buttonpanel.add(next);
		JButton last = new JButton("Last");
		last.addActionListener(new ActionListener() {
            @Override
			public void actionPerformed(ActionEvent e) {
				currentDisplay = inv.size()-1;
				displayProduct();
			}
		});
		buttonpanel.add(last);

		// new buttons
		JButton save = new JButton("Save");
		save.addActionListener(new ActionListener() {
            @Override
			public void actionPerformed(ActionEvent e) {
				inv.save();
			}
		});
		anotherbuttonpanel.add(save);
		JButton search = new JButton("Search");
		search.addActionListener(new ActionListener() {
            @Override
			public void actionPerformed(ActionEvent e) {
				String str = JOptionPane.showInputDialog(Camera.this,"Enter Product name to search for");
				int result = inv.searchForActionElectronics (str);
				if (result == -1) {
                    JOptionPane.showMessageDialog(Camera.this, "Sorry Nothing found");
                } // do nothing
				else { // show the item
					currentDisplay = result;
					displayProduct();
				}
			}
		});
		anotherbuttonpanel.add(search);
		JButton add = new JButton("Add");
		add.addActionListener(new ActionListener() {
            @Override
			public void actionPerformed(ActionEvent e) {
				String name = JOptionPane.showInputDialog(Camera.this,"Enter Product name");
				int units = Integer.parseInt(JOptionPane.showInputDialog(Camera.this,"Enter units in stock"));
				double price = Double.parseDouble(JOptionPane.showInputDialog(Camera.this,"Enter the price of each item"));
				String stu = JOptionPane.showInputDialog(Camera.this,"Enter the Category if known");

				// create object
				ActionElectronics ap = new ActionElectronics(inv.highestNumber()+1, name, units, price, stu);

				//input
				inv.addNewActionElectronics(ap);

				currentDisplay = inv.size()-1;
				displayProduct();
			}
		});
		anotherbuttonpanel.add(add);
		JButton modify = new JButton("Modify");
		modify.addActionListener(new ActionListener() {
            @Override
			public void actionPerformed(ActionEvent e) {
				// get new values and set them
				ActionElectronics ap = (ActionElectronics) inv.get(currentDisplay);
				ap.setItem(Integer.parseInt(
						JOptionPane.showInputDialog(Camera.this,"Enter new item number",ap.getItem())));
				ap.setName(
						JOptionPane.showInputDialog(Camera.this,"Enter new Product name",ap.getName()));
				ap.setUnits(Integer.parseInt(
						JOptionPane.showInputDialog(Camera.this,"Enter new units in stock",ap.getUnits())));
				ap.setPrice(Double.parseDouble(
						JOptionPane.showInputDialog(Camera.this,"Enter new price of each item",ap.getPrice())));
				ap.setCategory(
						JOptionPane.showInputDialog(Camera.this,"Enter new category if known",ap.getCategory()));

				
				displayProduct();
			}
		});
		anotherbuttonpanel.add(modify);
		JButton delete = new JButton("Delete");
		delete.addActionListener(new ActionListener() {
            @Override
			public void actionPerformed(ActionEvent e) {
				if (inv.size() > 0) { // else there is nothing to delete
					inv.deleteActionElectronics(inv.get(currentDisplay));
					currentDisplay--;
					if (currentDisplay < 0) {
                        currentDisplay = 0;
                    }
					displayProduct();
				}
			}
		});
		anotherbuttonpanel.add(delete);

		buttonpanel.add(new Logo());

		panel.add(buttonpanel);
		panel.add(anotherbuttonpanel);

		getContentPane().add(panel);

		displayProduct();
	}

	// display
	public void displayProduct() {
		txt.setText("Product Details:\n");
		txt.append("Item number: " + inv.get(currentDisplay).getItem() + "\n");
		txt.append("Product name: " + inv.get(currentDisplay).getName() + "\n");
		txt.append("Units in stock: " + inv.get(currentDisplay).getUnits() + "\n");
		txt.append("Price: $" + String.format("%.2f",inv.get(currentDisplay).getPrice()) + "\n");
		txt.append("Total value: $" + String.format("%.2f",inv.get(currentDisplay).value()) + "\n");
		txt.append("Fee: $" + String.format("%.2f",inv.get(currentDisplay).fee()) + "\n\n");

		txt.append("Total value: $" + String.format("%.2f",inv.value()));

	}

	public static void main(String args[]) {
		Camera gui = new Camera();
		gui.pack();
		gui.setVisible(true);
	}
//
package camera;

/**
 *
 * @author FDR
 */
public class ActionElectronics extends Electronics {
private String category = "category";

	public ActionElectronics(int item, String name, int units, double price, String category) {
		super(item, name, units, price);
		this.category = category;
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

//	total value
        /**
         *
         * @return
         */
        @Override
	public double value() {
		return getUnits()*getPrice();
	}

//	fee
	public double fee() {
		return 0.05*getUnits()*getPrice();
	}

}
package camera;

/**
 *
 * @author FDR
 */


import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.*;

public class DigitalCamera {
	private ArrayList<ActionElectronics> prodlist;

	public DigitalCamera() {
		prodlist = new ArrayList<ActionElectronics>();
	}

	// adding and getting items

	public void add(ActionElectronics p) {
		prodlist.add(p);
	}

	public int highestNumber() {
		int numb = 0;
		for (int i = 0; i < prodlist.size(); i++) {
			if (get(i).getItem() > numb) {
				numb = get(i).getItem();
			}
		}
		return numb;
	}

	public ActionElectronics get(int i) {
		return prodlist.get(i);
	}

	public int size() {
		return prodlist.size();
	}

	public void sort() {
		// bubble sort
		int n = prodlist.size();
		for (int search = 1; search < n; search++) {
			for (int i = 0; i < n-search; i++) {
				if (prodlist.get(i).getName().compareToIgnoreCase(prodlist.get(i+1).getName()) > 0) {
					// swap
					ActionElectronics temp = prodlist.get(i);
					prodlist.set(i,prodlist.get(i+1));
					prodlist.set(i+1,temp);
				}
			}
		}
	}

//	value
	public double value() {
		double total = 0.0;
		for (int i = 0; i < prodlist.size(); i++) {
			total += get(i).value();
		}
		return total;
	}


	public void save() {
		save(true);
	}

	// save it to C:/data/camera.dat
	public void save(boolean saveagain) {
		try {
			BufferedWriter w = new BufferedWriter(new FileWriter("c:\\data\\camera.dat"));
			for (int i = 0; i < size(); i++) {
				ActionElectronics ap = get(i);
				w.write("Product number: " + ap.getItem() + "\n");
				w.write("Item name: " + ap.getName() + "\n");
				w.write("Items in stock: " + ap.getUnits() + "\n");
				w.write("Type: " + ap.getCategory() + "\n");
				w.write("Price: $" + ap.getPrice() + "\n");
				w.write("Fee: $" + ap.fee() + "\n");
				w.write("Value (including the fee): $" + ap.value() + "\n");
				w.newLine();
			}
			// total value of it
			w.write("Total fee: $" + (value() - value()/0.00) + "\n");
			w.write("Total value (including the fee): $" + value() + "\n");
			w.close();
		} catch (Exception ex) {
			if (saveagain) {
				new File("c:\\data\\").mkdir(); // create file
				save(false); // save error
			}
		}
	}

	// search by Product Name
	public int searchForActionElectronics(String name) {
		for (int i = 0; i < size(); i++) { // search records
			if (get(i).getName().equalsIgnoreCase(name)) return i;
		}
		return -1; // item not found
	}

	// add a new product
	public void addNewActionElectronics(ActionElectronics ap) {
		prodlist.add(ap);
	}

	// remove product
	public void deleteActionElectronics(ActionElectronics ap) {
		prodlist.remove(ap);
	}
}
package camera;

public class Electronics {
        private int item;
	private String name;
	private int units;
	private double price;

//	constructor
	public Electronics(int item, String name, int units, double price) {
		this.item = item;
		this.name = name;
		this.units = units;
		this.price = price;
	}

//	total
	public double value() {
		return units*price;
	}

//	get and set

	public int getItem() {
		return item;
	}

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

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getUnits() {
		return units;
	}

	public void setUnits(int units) {
		this.units = units;
	}

	public double getPrice() {
		return price;
	}

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

}
package camera;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JPanel;

//
public class Logo extends JPanel {
	public Logo() {
		super();
		setPreferredSize(new Dimension(200,200));
	}
    @Override
	public void paint(Graphics g) {
		g.setColor(Color.red);
		g.fillRoundRect(60,60,110,90,5,5);
		g.setColor(Color.blue);
		g.drawString("Camera Program", 70, 105);
	}
}

your camera class does not contain an 'add' method, so that's where you're having trouble.

also, wouldn't it be easier to read if you added all the 'actionPerformed' methods in one big actionPerformed, and run the code based on the component that triggered it?

public Camera() {
   ...
   init();
}
 
public void init() {
   ...
   inv = new Camera();

When you create a new instance of Camera it calls the constructor, which calls init, which creates a new instance, which calls its constructor, which calls init ...

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.