New to Java and need some help...I am getting several Errors and I am not sure why here is the code and the error messages:

import java.io.*;
import java.util.Scanner;
import javax.swing.JOptionPane;

import java.util.*;

import java.text.*;
import java.lang.*;
import java.math.*;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.URL;


public class dvdInvGui extends JFrame
{
	
	dvdInventory theInventory;
	
	private int index=0;
	
	public void additem(dvd2 in_item)
	{
		theInventory.addItem(in_item);
	}
	
	private final JLabel stockNumberLabel = new JLabel("Stock Number:");
	private JTextField stockNumberText;
	
	private final JLabel dvdTitleLabel = new JLabel("DVD Title:");
	private JTextField dvdTitleText;
	
	private final JLabel movieGenreLabel = new JLabel("Movie Genre:");
	private JTextField movieGenreText;
	
	private final JLabel dvdStockLabel = new JLabel("Items in Stock:");
	private JTextField dvdStockText;
	
	private final JLabel dvdPriceLabel = new JLabel("Item Price:");
	private JTextField dvdPriceText;
	
	private final JLabel stockValueLabel = new JLabel("Stock Vaue:");
	private JTextField stockValueText;
	
	private final JLabel reStockValueLabel = new JLabel("Re-Stock Fee:");
	private JTextField reStockValueText;
	
	
	//Add First Button
	private Action firstAction = new AbstractAction("First")
	{
		public void actionPerformed(ActionEvent evt)
		{
		index = 0;
		
		repaint();
		}
	};
	
	private JButton firstButton = new JButton(firstAction);
		
	
	//Add Next Button
	private Action nextAction = new AbstractAction("Next")
	{
		public void actionPerformed(ActionEvent evt){
			index++;
			if(index == theInventory.numberOfProducts() )
				{
					index = 0;
				}
			repaint();
		}
	};
	
	private JButton nextButton = new JButton(nextAction);
	
	
	//Add Previous Button
	private Action previousAction = new AbstractAction("Previous")
	{
		public void actionPerformed(ActionEvent evt)
		{
			index--;
			if(index < 0)
			{
				index = theInventory.numberOfProducts() -1;
			}
		repaint();
		}
	};
	
	private JButton previousButton = new JButton(previousAction);
	
	
	//Add Last Button
	private Action lastAction = new AbstractAction("Last")
	{
		public void actionPerformed(ActionEvent evt)
		{
			index = theInventory.numberOfProducts() -1;
		
		repaint();
		}
	};
	
	private JButton lastButton = new JButton(lastAction);
	
	
	
	//Add help button
	private Action helpAction = new AbstractAction("Help")
	{
		public void actionPerformed(ActionEvent evt)
		{
					repaint();
		}
		
	};
	
	private JButton helpButton = new JButton(helpAction);
	
	

	//Add the Add Button
	private Action addAction = new AbstractAction("Add")
	{
		public void actionPerformed(ActionEvent evt)
		{
			dvd2 temp = (dvd2) theInventory.getitem(index);
			int numitems = theInventory.numberOfProducts() +1;
			index = (numitems -2) % numitems;
			repaint();
			
			if(dvdTitleText.getText().equals("Add DVD Title")){
			JOptionPane.showMessageDialog(null, "Fill out the blank entry before adding more...Press Modify when you are finished", JOptionPane.ERROR_MESSAGE);
			}
			
			if(dvdTitleText.getText().equals("Add DVD Title") !=true){
			dvd2 product = new dvd2("Add DVD Title", Integer.parseInt(stockNumberText.getText()) +1, 0, 0.0, "Add DVD Title");
			index = (numitems -1) % numitems;
			theInventory.addItem(product);
			repaint();
			}
		
		}
	};
	
	private JButton addButton = new JButton(addAction);
	
	
	//Add the Delete Button
	private Action deleteAction = new AbstractAction("Delete")
	{
		public void actionPerformed(ActionEvent evt)
		{
			int numitems = theInventory.numberOfProducts();
			dvd2 temp = (dvd2) theInventory.numberOfProducts(index);
			
			if(numitems !=0){
			
				if(Integer.parseInt(dvdStockText.getText()) != numitems){
				theInventory.removeItem(index);
				repaint();
				int i = Integer.parseInt(dvdStockText.getText());
				index = (++index) % numitems;
				repaint();
				int j = Integer.parseInt(dvdStockText.getText());
					if(i>j){
						index = (--index) % numitems;
						repaint();
						temp = (dvd2) theInventory.numberOfProducts(index);
						temp.getStockNumber(j-1);
						index = (++index) % numitems;
						repaint();
						}
				}
				
			
			if(Integer.parseInt(stockNumberText.getText()) == numitems){
				theInventory.reduceItem(temp);
				index = (++index) % numitems;
				repaint();
			}
			
			}
			if(numitems == 1){
				dvd2 product = new dvd2(numitems, "Add DVD Title", 0, 0.0, "Add movie Genre");
				theInventory.addItem(product);
				JOptionPane.showMessageDialog(null, "Delete Process Complete", JOptionPane.ERROR_MESSAGE);
				repaint();
			}
		}
	};
	
	private JButton deleteButton = new JButton(deleteAction);
	
	
	//Add the Modify Button
	private Action modifyAction = new AbstractAction("Modify")
	{
		public void actionPerformed(ActionEvent evt)
		{
			if(dvdTitleText.getText().equals("")){
			JOptionPane.showMessageDialog(null, "Please complete the entry.", JOptionPane.ERROR_MESSAGE);
			repaint();
			}
			
			if(movieGenreText.getText().equals("")){
			JOptionPane.showMessageDialog(null, "Please complete the entry.", JOptionPane.ERROR_MESSAGE);
			repaint();
			}
			
			try
			{
				Integer.parseInt(dvdStockText.getText());
				Double.parseDouble(dvdPriceText.getText());
			}
			
			catch (Exception d)
			{
				JOptionPane.showMessageDialog(null, "Re-Check entry. Use numbers for price and items in stock.", JOptionPane.ERROR_MESSAGE);
				repaint();
			}
				
			String name;
			int number;
			int amount;
			double price;
			String genre;
			
			name = dvdTitleText.getText();
			number = Integer.parseInt(stockNumberText.getText());
			amount = Integer.parseInt(dvdStockText.getText());
			price = Double.parseDouble(dvdPriceText.getText());
			genre = movieGenreText.getText();
			
			dvd2 modify = (dvd2)	theInventory.numberOfProducts(index);
			
			modify.getStockNumber(number);
			modify.getdvdTitle(name);
			modify.getdvdStock(amount);
			modify.getdvdPrice(price);
			modify.getMovieGenre(genre);
		
		repaint();
		
		}
	};
	
	private JButton modifyButton = new JButton(modifyAction);
	
	
	//Add the Save Button
	private Action saveAction = new AbstractAction("Save")
	{
		public void actionPerformed(ActionEvent evt)
		{
		
		repaint();
		
		}
		
	};
	
	private JButton saveButton = new JButton(saveAction);
	
	
	//Add Search Button
	private Action searchAction = new AbstractAction("Search")
	{
		public void actionPerformed(ActionEvent evt)
		{
			String search = searchText.getText();
			String name = dvdTitleText.getText();
			int number = Integer.parseInt(stockNumberText.getText());
			int numitems = theInventory.numberOfProducts();
			int currentRecord = 0;
			
			do
			{	
				index = (++index) % numitems;
				repaint();
				name = dvdTitleText.getText();
				number = Integer.parseInt(stockNumberText.getText());
				search = searchText.getText();
				currentRecord = (++currentRecord);
				
					if(name.equalsIgnoreCase(search))
					repaint();
					
					if(searchText.getText().equals("")){
					JOptionPane.showMessageDialog(null, "You cannot search for a blank entry", JOptionPane.ERROR_MESSAGE);
					index = (--index) % numitems;
					break;
					}
					
					if(currentRecord == numitems +1){
					JOptionPane.showMessageDialog(null, "No search results found", JOptionPane.ERROR_MESSAGE);
					break;
					}
					
					}while(name.equalsIgnoreCase(search) != true);
		
		}
		
	};
	
	
	private JButton searchButton = new JButton(searchAction);
	
	
	public void dvdInvGui()
	{
		theInventory = new dvdInventory();
		
		//grid layout for panel
		JPanel buttonPanel = new JPanel(new GridLayout(2, 5, 0, 5) );
		buttonPanel.add(firstButton);
		buttonPanel.add(previousButton);
		buttonPanel.add(nextButton);
		buttonPanel.add(lastButton);
		buttonPanel.add(helpButton);
		buttonPanel.add(addButton);
		buttonPanel.add(deleteButton);
		buttonPanel.add(modifyButton);
		buttonPanel.add(saveButton);
		buttonPanel.add(searchButton);
		getContentPane().add(buttonPanel, BorderLayout.SOUTH);
		
		//stock Number Display
		JPanel centerPanel = new JPanel(new GridLayout(12, 2, 0, 4) );
		centerPanel.add(stockNumberLabel);
		stockNumberLabel.setBorder(BorderFactory.createEmptyBorder(1,3,1,3) );
		stockNumberText = new JTextField("");
		stockNumberText.setEditable(false);
		centerPanel.add(stockNumberText);
		
		//DVD Title display
		
		centerPanel.add(dvdTitleLabel);
		dvdTitleLabel.setBorder(BorderFactory.createEmptyBorder(1,3,1,3) );
		dvdTitleText = new JTextField("");
		dvdTitleText.setEditable(false);
		centerPanel.add(dvdTitleText);
		
		
		//Movie Genre display
		
		centerPanel.add(movieGenreLabel);
		movieGenreLabel.setBorder(BorderFactory.createEmptyBorder(1,3,1,3) );
		movieGenreText = new JTextField("");
		movieGenreText.setEditable(false);
		centerPanel.add(movieGenreText);
		
	
		//Units in Stock display
		
		centerPanel.add(dvdStockLabel);
		dvdStockLabel.setBorder(BorderFactory.createEmptyBorder(1,3,1,3) );
		dvdStockText = new JTextField("");
		dvdStockText.setEditable(false);
		centerPanel.add(dvdStockText);
		
		
		//DVD Price display
		
		centerPanel.add(dvdPriceLabel);
		dvdPriceLabel.setBorder(BorderFactory.createEmptyBorder(1,3,1,3) );
		dvdPriceText = new JTextField("");
		dvdPriceText.setEditable(false);
		centerPanel.add(dvdPriceText);
		
		
		//Value of Stock display
		
		centerPanel.add(stockValueLabel);
		stockValueLabel.setBorder(BorderFactory.createEmptyBorder(1,3,1,3) );
		stockValueText = new JTextField("");
		stockValueText.setEditable(false);
		centerPanel.add(stockValueText);
		
		
		
		//Re-Stock Value display
		
		centerPanel.add(reStockValueLabel);
		reStockValueLabel.setBorder(BorderFactory.createEmptyBorder(1,3,1,3) );
		reStockValueText = new JTextField("");
		reStockValueText.setEditable(false);
		centerPanel.add(reStockValueText);
		
		//setup the logo for the GUI
		URL url = this.getClass().getResource("logo.jpg");
		Image img = Toolkit.getDefaultToolkit().getImage(url);
		Image scaledImage = img.getScaledInstance(205, 125, Image.SCALE_AREA_AVERAGING);
		Icon logoIcon = new ImageIcon(scaledImage);
		JLabel companyLogoLabel = new JLabel(logoIcon);
		companyLogoLabel.setBorder(BorderFactory.createEmptyBorder(1,1,1,1));
		getContentPane().add(companyLogoLabel, BorderLayout.WEST);
		
		getContentPane().add(centerPanel, BorderLayout.CENTER);
	}
	
	public void showGUI()
	{
		this.setDefaultCloseOperation( EXIT_ON_CLOSE );
		this.pack();
		this.setSize(600, 425);
		this.setResizable(false);
		this.setLocationRelativeTo( null );
		this.setVisible(true);
		repaint();
	}
	
	
	//repaint Gui
	
	public void repaint()
	{
		dvd2 temp = theInventory.getitem(index);
		
		if (temp != null){
		
		stockNumberText.setText( ""+temp.getstockNumber() );
		dvdTitleText.setText( temp.getdvdTitle() );
		movieGenreText.setText( temp.getMovieGenre() );
		dvdStockText.setText( ""+temp.getstockNumber() );
		dvdPriceText.setText( ""+temp.getdvdPrice() );
		stockValueText.setText( ""+temp.getStockValue() );
		reStockValueText.setText( ""+temp.getreStockValue() );
		}
		
	}
	
	public void addToInventory(dvd2 temp)
	{
		theInventory.addItem(temp);
	}
		
		
		
}
public class dvd
			{
	
					protected String p_dvdTitle;
					protected int p_stockNumber;
					protected double p_dvdPrice;
					protected int p_dvdStock;
	
					public dvd(String dvdTitle)
					{
						p_dvdTitle = dvdTitle;
					}
					
					public dvd( int stockNumber, String dvdTitle, int dvdStock, double dvdPrice )	
					{
						p_dvdTitle = dvdTitle;
						p_stockNumber = stockNumber;
						p_dvdPrice = dvdPrice;
						p_dvdStock = dvdStock;
					}	
					
					
					public String getdvdTitle()
					{
						return p_dvdTitle;
					}
	
					public int getstockNumber()
					{
						return p_stockNumber;
					}
	
					public double getdvdPrice ()
					{
						return p_dvdPrice;
					}
					
					
					public int getdvdStock()
					{
						return p_dvdStock;
					}					
				
					public double getStockValue()
					{
						return p_dvdStock * p_dvdPrice;
					}
										
									
				} //end class dvd
				
			class dvd2 extends dvd
			{
			
				public String movieGenre;
				public double stockValue;
				public double reStockValue;
		
				
				public dvd2(int p_stockNumber, String p_dvdTitle, String genre, int p_dvdStock, double p_dvdPrice)
				{       
				 super( p_stockNumber, p_dvdTitle, p_dvdStock, p_dvdPrice );
				 movieGenre = genre;
				 stockValue = 0;
				 reStockValue = 0;
				} 
				
				
				
				public String getMovieGenre()
				{
					return movieGenre; 
				}
				
				public int getStockNumber()
				{
					return p_stockNumber;
				}
				
				public double getStockValue()
				{
					return p_dvdPrice * p_dvdStock * 1.05;
				}
					
				public double getreStockValue()
				{
					double reStockValue = getStockValue() * .05;
					        
					return reStockValue;
				}
			
			}//ends Extened class dvd2
import java.util.Scanner;

public class dvdInventory
	{

		//array of items from dvd class
		protected dvd2 dvdInv[] = new dvd2 [100];
		
		//variable to keep the maximum location
		protected int p_maxLocation=0;
		
		protected int index=0;
		
		//add constructor
	
		
		//method to add items to inventory
		public void addItem(dvd2 in_item)
		{
			dvdInv[p_maxLocation] = in_item;
			p_maxLocation++;
			
		}
		
		public void removeItem()
		{
			dvdInv[index] = dvdInv[p_maxLocation -1];
			--p_maxLocation;
		}
		
		public void reduceItem(dvd2 out_item)
		{
			dvdInv[p_maxLocation] = out_item;
			--p_maxLocation;
		}
		
		public dvdInventory(){
		}
			
		public int numberOfProducts()
		{
			return p_maxLocation;	
		}
		
		public dvd2 getitem(int in_index)
		{
			return dvdInv[in_index];
		}
		
		public void sort()
		{
			for( int loc=0;loc<p_maxLocation; loc++)
			{	int index=loc;
					dvd2 hold=dvdInv[index];
						while( index>0 && hold.getdvdTitle().compareTo(dvdInv[index-1].getdvdTitle())<0 )
						{
							dvdInv[index]=dvdInv[index-1];
									index--;
						}
						
					dvdInv[index]=hold;
					
			}
		}
		
		public double inventoryValue()
		{
			double addinv=0;
				for( int loc=0; loc<p_maxLocation; loc++ )
					addinv=addinv+dvdInv[loc].getStockValue();
						return addinv;
		}

	
	}//end Inventory
public class dvdTest
				{
					
					public static void main( String args[] )
					{
					
					dvdInvGui myInventory = new dvdInvGui();
					
					//create objects for Inventory
					
					myInventory.additem(new dvd2(1,"Wall E","Family",1,14.99));
					myInventory.additem(new dvd2(2,"Happy Feet","Family",2,19.99));
					myInventory.additem(new dvd2(3,"Solaris","Sci-Fi",3,16.99));
					myInventory.additem(new dvd2(4,"Golden Eye","Action",4,17.99));
					myInventory.additem

now here are the error messages:
dvdInvGui.java:139: cannot find symbol
symbol : method showMessageDialog(<nulltype>,java.lang.String,int)
location: class javax.swing.JOptionPane
JOptionPane.showMessageDialog(null, "Fill out the blank entry before adding more...Press Modify when you are finished", JOptionPane.ERROR_MESSAGE);
^
dvdInvGui.java:143: cannot find symbol
symbol : constructor dvd2(java.lang.String,int,int,double,java.lang.String)
location: class dvd2
dvd2 product = new dvd2("Add DVD Title", Integer.parseInt(stockNumberText.getText()) +1, 0, 0.0, "Add DVD Title");
^
dvdInvGui.java:161: numberOfProducts() in dvdInventory cannot be applied to (int)
dvd2 temp = (dvd2) theInventory.numberOfProducts(index);
^
dvdInvGui.java:166: removeItem() in dvdInventory cannot be applied to (int)
theInventory.removeItem(index);
^
dvdInvGui.java:175: numberOfProducts() in dvdInventory cannot be applied to (int)
temp = (dvd2) theInventory.numberOfProducts(index);
^
dvdInvGui.java:176: getStockNumber() in dvd2 cannot be applied to (int)
temp.getStockNumber(j-1);
^
dvdInvGui.java:191: cannot find symbol
symbol : constructor dvd2(int,java.lang.String,int,double,java.lang.String)
location: class dvd2
dvd2 product = new dvd2(numitems, "Add DVD Title", 0, 0.0, "Add movie Genre");
^
dvdInvGui.java:193: cannot find symbol
symbol : method showMessageDialog(<nulltype>,java.lang.String,int)
location: class javax.swing.JOptionPane
JOptionPane.showMessageDialog(null, "Delete Process Complete", JOptionPane.ERROR_MESSAGE);
^
dvdInvGui.java:208: cannot find symbol
symbol : method showMessageDialog(<nulltype>,java.lang.String,int)
location: class javax.swing.JOptionPane
JOptionPane.showMessageDialog(null, "Please complete the entry.", JOptionPane.ERROR_MESSAGE);
^
dvdInvGui.java:213: cannot find symbol
symbol : method showMessageDialog(<nulltype>,java.lang.String,int)
location: class javax.swing.JOptionPane
JOptionPane.showMessageDialog(null, "Please complete the entry.", JOptionPane.ERROR_MESSAGE);
^
dvdInvGui.java:225: cannot find symbol
symbol : method showMessageDialog(<nulltype>,java.lang.String,int)
location: class javax.swing.JOptionPane
JOptionPane.showMessageDialog(null, "Re-Check entry. Use numbers for price and items in stock.", JOptionPane.ERROR_MESSAGE);
^
dvdInvGui.java:241: numberOfProducts() in dvdInventory cannot be applied to (int)
dvd2 modify = (dvd2) theInventory.numberOfProducts(index);
^
dvdInvGui.java:243: getStockNumber() in dvd2 cannot be applied to (int)
modify.getStockNumber(number);
^
dvdInvGui.java:244: getdvdTitle() in dvd cannot be applied to (java.lang.String)
modify.getdvdTitle(name);
^
dvdInvGui.java:245: getdvdStock() in dvd cannot be applied to (int)
modify.getdvdStock(amount);
^
dvdInvGui.java:246: getdvdPrice() in dvd cannot be applied to (double)
modify.getdvdPrice(price);
^
dvdInvGui.java:247: getMovieGenre() in dvd2 cannot be applied to (java.lang.String)
modify.getMovieGenre(genre);
^
dvdInvGui.java:277: cannot find symbol
symbol: variable searchText
String search = searchText.getText();
^
dvdInvGui.java:289: cannot find symbol
symbol: variable searchText
search = searchText.getText();
^
dvdInvGui.java:295: cannot find symbol
symbol: variable searchText
if(searchText.getText().equals("")){
^
dvdInvGui.java:296: cannot find symbol
symbol : method showMessageDialog(<nulltype>,java.lang.String,int)
location: class javax.swing.JOptionPane
JOptionPane.showMessageDialog(null, "You cannot search for a blank entry", JOptionPane.ERROR_MESSAGE);
^
dvdInvGui.java:302: cannot find symbol
symbol : method showMessageDialog(<nulltype>,java.lang.String,int)
location: class javax.swing.JOptionPane
JOptionPane.showMessageDialog(null, "No search results found", JOptionPane.ERROR_MESSAGE);
^
22 errors

I know that this is alot to search through. But I am on a deadline tonight by 2am cst. Any help or guidance would be great. Thanks!

Welcome kg4cxl,

Use following syntax:

showMessageDialog(Component parentComponent, Object message, String title, int messageType)

Thanks,

That took care of 12 of the 22 error messages. Any Ideas for the other error codes? I am really at a loss.

I have narrowed it down to 6 errors... I cannot figure these out. I have been at it now for 5 straight hours. Please HELP!

dvdInvGui.java:179: getstockNumber() in dvd cannot be applied to (int)
temp.getstockNumber(j -1);
^
dvdInvGui.java:246: setstockNumber() in dvd cannot be applied to (int)
modify.setstockNumber(number);
^
dvdInvGui.java:247: setdvdTitle() in dvd cannot be applied to (java.lang.String)
modify.setdvdTitle(name);
^
dvdInvGui.java:248: setdvdStock() in dvd cannot be applied to (double)
modify.setdvdStock(amount);
^
dvdInvGui.java:249: setdvdPrice() in dvd cannot be applied to (double)
modify.setdvdPrice(price);
^
dvdInvGui.java:250: setMovieGenre() in dvd2 cannot be applied to (java.lang.String)
modify.setMovieGenre(genre);
^
6 errors

Function call:

temp.getstockNumber(j -1);

Function:

public int getstockNumber()

Function doesn't take a parameter. Function call provides a parameter. That doesn't match. Try changing the call to:

temp.getstockNumber();

All these errors appear to be the same. You have a bunch of functions that don't take any parameters, yet you are providing parameters in the function calls. generally, as a rule of thumb, any function that starts with set should take a parameter and be a void function. Any function that starts with get should take no parameters and NOT be a void function. Function CALLS must match the function specification.

thanks That helped alot!

Got one more question. if you guys have paitence for one more.

The program compiles but when I try to run the program I get two errors:

Exception in thread "main" java.lang.NullPointerException
at dvdInvGui.additem(dvdInvGui.java:27)
at dvdTest.main(dvdTest.java:17)


here is the revised code:

import java.io.*;
import java.util.Scanner;
import javax.swing.JOptionPane;

import java.util.*;

import java.text.*;
import java.lang.*;
import java.math.*;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.URL;


public class dvdInvGui extends JFrame
{
	
	dvdInventory theInventory;
	
	private int index=0;
	
	public void additem(dvd2 in_item)
	{
		theInventory.addItem(in_item);
	}
	
	private final JLabel stockNumberLabel = new JLabel("Stock Number:");
	private JTextField stockNumberText;
	
	private final JLabel dvdTitleLabel = new JLabel("DVD Title:");
	private JTextField dvdTitleText;
	
	private final JLabel movieGenreLabel = new JLabel("Movie Genre:");
	private JTextField movieGenreText;
	
	private final JLabel dvdStockLabel = new JLabel("Items in Stock:");
	private JTextField dvdStockText;
	
	private final JLabel dvdPriceLabel = new JLabel("Item Price:");
	private JTextField dvdPriceText;
	
	private final JLabel stockValueLabel = new JLabel("Stock Vaue:");
	private JTextField stockValueText;
	
	private final JLabel reStockValueLabel = new JLabel("Re-Stock Fee:");
	private JTextField reStockValueText;
	
	private final JLabel searchLabel = new JLabel("Search");
	private JTextField searchText;
	
	
	//Add First Button
	private Action firstAction = new AbstractAction("First")
	{
		public void actionPerformed(ActionEvent evt)
		{
		index = 0;
		
		repaint();
		}
	};
	
	private JButton firstButton = new JButton(firstAction);
		
	
	//Add Next Button
	private Action nextAction = new AbstractAction("Next")
	{
		public void actionPerformed(ActionEvent evt){
			index++;
			if(index == theInventory.numberOfProducts() )
				{
					index = 0;
				}
			repaint();
		}
	};
	
	private JButton nextButton = new JButton(nextAction);
	
	
	//Add Previous Button
	private Action previousAction = new AbstractAction("Previous")
	{
		public void actionPerformed(ActionEvent evt)
		{
			index--;
			if(index < 0)
			{
				index = theInventory.numberOfProducts() -1;
			}
		repaint();
		}
	};
	
	private JButton previousButton = new JButton(previousAction);
	
	
	//Add Last Button
	private Action lastAction = new AbstractAction("Last")
	{
		public void actionPerformed(ActionEvent evt)
		{
			index = theInventory.numberOfProducts() -1;
		
		repaint();
		}
	};
	
	private JButton lastButton = new JButton(lastAction);
	
	
	
	//Add help button
	private Action helpAction = new AbstractAction("Help")
	{
		public void actionPerformed(ActionEvent evt)
		{
			
			JOptionPane.showMessageDialog(null,
			"FIRST takes you to the first entry" +
			"NEXT takes you to the next entry" +
			"PREVIOUS takes you to the previous entry" +
			"LAST takes you to the Last entry" +
			"HELP you are in HELP! now" +
			"ADD allows you to add entries" +
			"DELETE allows you to delete entries" +
			"MODIFY allows you to modify entries" +
			"SAVE allows you to save the list of entries to a file" +
			"SEARCH allows you to search for an entry", "HELP!", JOptionPane.PLAIN_MESSAGE);	
					
					repaint();
		}
		
	};
	
	private JButton helpButton = new JButton(helpAction);
	
	

	//Add the Add Button
	private Action addAction = new AbstractAction("Add")
	{
		public void actionPerformed(ActionEvent evt)
		{
			dvd2 temp = (dvd2) theInventory.getitem(index);
			int numitems = theInventory.numberOfProducts() +1;
			index = (numitems -2) % numitems;
			repaint();
			
			if(dvdTitleText.getText().equals("Add DVD Title") ){
			JOptionPane.showMessageDialog(null, "Please fill out the blank form before adding more entries","ADD Entry", JOptionPane.ERROR_MESSAGE);
			}
			
			if(dvdTitleText.getText().equals("Add DVD Title") != true){
			dvd2 product = new dvd2(Integer.parseInt(stockNumberText.getText()) +1, "Add DVD Title", "Add Movie Genre", 0, 0.00);
			index = (numitems -1) % numitems;
			theInventory.addItem(product);
			repaint();
			}
			
		
		}
	};
	
	private JButton addButton = new JButton(addAction);
	
	
	//Add the Delete Button
	private Action deleteAction = new AbstractAction("Delete")
	{
		public void actionPerformed(ActionEvent evt)
		{
			int numitems = theInventory.numberOfProducts();
			dvd2 temp = (dvd2)theInventory.getitem(index);
				
			if(numitems !=0){
			
				if(Integer.parseInt(stockNumberText.getText()) != numitems){
				theInventory.removeItem();
				repaint();
				int i = Integer.parseInt(stockNumberText.getText());
				index = (++index) % numitems;
				repaint();
				}
				
			
			if(Integer.parseInt(stockNumberText.getText()) == numitems){
				theInventory.reduceItem(temp);
				index = (++index) % numitems;
				repaint();
			}
			
			}
			if(numitems == 1){
				dvd2 product = new dvd2(numitems, "Add DVD Title","Add Movie Genre", 0, 0.0);
				theInventory.addItem(product);
				JOptionPane.showMessageDialog(null, "Delete Process Complete", "Delete Complete", JOptionPane.ERROR_MESSAGE);
				repaint();
			}
		}
	};
	
	private JButton deleteButton = new JButton(deleteAction);
	
	
	//Add the Modify Button
	private Action modifyAction = new AbstractAction("Modify")
	{
		public void actionPerformed(ActionEvent evt)
		{
			if(dvdTitleText.getText().equals("")){
			JOptionPane.showMessageDialog(null, "Please complete the entry.", "Complete the entry", JOptionPane.ERROR_MESSAGE);
			repaint();
			}
			
			if(movieGenreText.getText().equals("")){
			JOptionPane.showMessageDialog(null, "Please complete the entry.", "Complete the entry",JOptionPane.ERROR_MESSAGE);
			repaint();
			}
			
			try
			{
				Integer.parseInt(dvdStockText.getText());
				Double.parseDouble(dvdPriceText.getText());
			}
			
			catch (Exception d)
			{
				JOptionPane.showMessageDialog(null, "Re-Check entry. Use numbers for price and items in stock.", "Re-Check entry", JOptionPane.ERROR_MESSAGE);
				repaint();
			}
				
			String name;
			int number;
			double amount;
			double price;
			String genre;
			
			name = dvdTitleText.getText();
			number = Integer.parseInt(stockNumberText.getText());
			amount = Integer.parseInt(dvdStockText.getText());
			price = Double.parseDouble(dvdPriceText.getText());
			genre = movieGenreText.getText();
			
			dvd2 modify = (dvd2) theInventory.getitem(index);
			
			modify.setstockNumber();
			modify.setdvdTitle();
			modify.setMovieGenre();
			modify.setdvdStock();
			modify.setdvdPrice();	
			repaint();
		
		}
	};
	
	private JButton modifyButton = new JButton(modifyAction);
	
	
	//Add the Save Button
	private Action saveAction = new AbstractAction("Save")
	{
		public void actionPerformed(ActionEvent evt)
		{
		
			int numitems = theInventory.numberOfProducts();
			InventoryStorage record = new InventoryStorage();
			record.openfile();
			int currentRecord = 0;
			
			do
			{
				record.addRecords();
				currentRecord = currentRecord +1;
				index = (++index) % numitems;
				
			}while (currentRecord < numitems);
			
			record.closeFile();
			
		
		}
		
	};
	
	private JButton saveButton = new JButton(saveAction);
	
	
	//Add Search Button
	private Action searchAction = new AbstractAction("Search")
	{
		public void actionPerformed(ActionEvent evt)
		{
			String search = searchText.getText();
			String name = dvdTitleText.getText();
			int number = Integer.parseInt(stockNumberText.getText());
			int numitems = theInventory.numberOfProducts();
			int currentRecord = 0;
			
			do
			{	
				index = (++index) % numitems;
				repaint();
				name = dvdTitleText.getText();
				number = Integer.parseInt(stockNumberText.getText());
				search = searchText.getText();
				currentRecord = (++currentRecord);
				
					if(name.equalsIgnoreCase(search))
					repaint();
					
					if(searchText.getText().equals("")){
					JOptionPane.showMessageDialog(null, "You cannot search for a blank entry", "Blank Search", JOptionPane.ERROR_MESSAGE);
					index = (--index) % numitems;
					break;
					}
					
					if(currentRecord == numitems +1){
					JOptionPane.showMessageDialog(null, "No search results found", "Results", JOptionPane.ERROR_MESSAGE);
					break;
					}
					
					}while(name.equalsIgnoreCase(search) != true);
		
		}
		
	};
	
	
	private JButton searchButton = new JButton(searchAction);
	
	
	public void dvdInvGui()
	{
		theInventory = new dvdInventory();
		
		//grid layout for panel
		JPanel buttonPanel = new JPanel(new GridLayout(2, 5, 0, 5) );
		buttonPanel.add(firstButton);
		buttonPanel.add(previousButton);
		buttonPanel.add(nextButton);
		buttonPanel.add(lastButton);
		buttonPanel.add(helpButton);
		buttonPanel.add(addButton);
		buttonPanel.add(deleteButton);
		buttonPanel.add(modifyButton);
		buttonPanel.add(saveButton);
		buttonPanel.add(searchButton);
		getContentPane().add(buttonPanel, BorderLayout.SOUTH);
		
		//stock Number Display
		JPanel centerPanel = new JPanel(new GridLayout(12, 2, 0, 4) );
		centerPanel.add(stockNumberLabel);
		stockNumberLabel.setBorder(BorderFactory.createEmptyBorder(1,3,1,3) );
		stockNumberText = new JTextField("");
		stockNumberText.setEditable(false);
		centerPanel.add(stockNumberText);
		
		//DVD Title display
		
		centerPanel.add(dvdTitleLabel);
		dvdTitleLabel.setBorder(BorderFactory.createEmptyBorder(1,3,1,3) );
		dvdTitleText = new JTextField("");
		dvdTitleText.setEditable(false);
		centerPanel.add(dvdTitleText);
		
		
		//Movie Genre display
		
		centerPanel.add(movieGenreLabel);
		movieGenreLabel.setBorder(BorderFactory.createEmptyBorder(1,3,1,3) );
		movieGenreText = new JTextField("");
		movieGenreText.setEditable(false);
		centerPanel.add(movieGenreText);
		
	
		//Units in Stock display
		
		centerPanel.add(dvdStockLabel);
		dvdStockLabel.setBorder(BorderFactory.createEmptyBorder(1,3,1,3) );
		dvdStockText = new JTextField("");
		dvdStockText.setEditable(false);
		centerPanel.add(dvdStockText);
		
		
		//DVD Price display
		
		centerPanel.add(dvdPriceLabel);
		dvdPriceLabel.setBorder(BorderFactory.createEmptyBorder(1,3,1,3) );
		dvdPriceText = new JTextField("");
		dvdPriceText.setEditable(false);
		centerPanel.add(dvdPriceText);
		
		
		//Value of Stock display
		
		centerPanel.add(stockValueLabel);
		stockValueLabel.setBorder(BorderFactory.createEmptyBorder(1,3,1,3) );
		stockValueText = new JTextField("");
		stockValueText.setEditable(false);
		centerPanel.add(stockValueText);
		
		
		
		//Re-Stock Value display
		
		centerPanel.add(reStockValueLabel);
		reStockValueLabel.setBorder(BorderFactory.createEmptyBorder(1,3,1,3) );
		reStockValueText = new JTextField("");
		reStockValueText.setEditable(false);
		centerPanel.add(reStockValueText);
		
		//setup the logo for the GUI
		URL url = this.getClass().getResource("logo.jpg");
		Image img = Toolkit.getDefaultToolkit().getImage(url);
		Image scaledImage = img.getScaledInstance(205, 125, Image.SCALE_AREA_AVERAGING);
		Icon logoIcon = new ImageIcon(scaledImage);
		JLabel companyLogoLabel = new JLabel(logoIcon);
		companyLogoLabel.setBorder(BorderFactory.createEmptyBorder(1,1,1,1));
		getContentPane().add(companyLogoLabel, BorderLayout.WEST);
		
		getContentPane().add(centerPanel, BorderLayout.CENTER);
	}
	
	public void showGUI()
	{
		this.setDefaultCloseOperation( EXIT_ON_CLOSE );
		this.pack();
		this.setSize(600, 425);
		this.setResizable(false);
		this.setLocationRelativeTo( null );
		this.setVisible(true);
		repaint();
	}
	
	
	//repaint Gui
	
	public void repaint()
	{
		dvd2 temp = theInventory.getitem(index);
		
		if (temp != null){
		
		stockNumberText.setText( ""+temp.getstockNumber() );
		dvdTitleText.setText( temp.getdvdTitle() );
		movieGenreText.setText( temp.getMovieGenre() );
		dvdStockText.setText( ""+temp.getstockNumber() );
		dvdPriceText.setText( ""+temp.getdvdPrice() );
		stockValueText.setText( ""+temp.getStockValue() );
		reStockValueText.setText( ""+temp.getreStockValue() );
		}
		
	}
	
	public void addToInventory(dvd2 temp)
	{
		theInventory.addItem(temp);
	}
		
		
		
}

class InventoryStorage
{

	dvdInventory theInventory;
	int index = 0;
	
	private Formatter output;
	
		public void openfile()
		{
			try
			{
				String strDirectory ="C://Data/";
				boolean sucess = (new File (strDirectory)).mkdir();
				
				if(sucess){
				JOptionPane.showMessageDialog(null, "Data Directory was created on your C Drive.", "Dir Creation", JOptionPane.PLAIN_MESSAGE);
				}
				
			}
			
			catch (Exception e)
			{
				JOptionPane.showMessageDialog(null, "You do not have write access to the C Drive", "File Access", JOptionPane.ERROR_MESSAGE);
			}
			
			
			try
			{
				output = new Formatter( "C:/data/inventory.dat");
			}
			
			catch (SecurityException securityException)
			{	
				JOptionPane.showMessageDialog(null,"You do not have write access to the C Drive", "File Access", JOptionPane.ERROR_MESSAGE);
				System.exit(1);
			
			}
			
			catch (FileNotFoundException filesNotFoundException)
			{
				JOptionPane.showMessageDialog(null, "Please Create a file named data on your C Drive.", "File Access", JOptionPane.ERROR_MESSAGE);
			}
			
			JOptionPane.showMessageDialog(null, "File Saved Successfully!", "File Saved", JOptionPane.PLAIN_MESSAGE);
			
		}
		
		
		public void addRecords()
		{
			dvd2 record = (dvd2) theInventory.getitem(index);
			
			
			if(record != null){
			output.format("StockNumber:%.0f, Dvd Title:%s, Items in Stock:%.0f, Price:$%.2f, %s, %s", record.getstockNumber(), record.getdvdTitle(), record.getdvdStock(), record.getdvdPrice(), record.getStockValue(), record.getreStockValue() );
			}
		}
			
			public void closeFile()
			{
				if(output != null){
				output.close();
				}
				
			}
public class dvdTest
				{
					
					public static void main( String args[] )
					{
					
					dvdInvGui myInventory = new dvdInvGui();
		
					//create objects for Inventory
					
					myInventory.additem(new dvd2(1,"Wall E","Family",1,14.99));
					myInventory.additem(new dvd2(2,"Happy Feet","Family",2,19.99));
					myInventory.additem(new dvd2(3,"Solaris","Sci-Fi",3,16.99));
					myInventory.additem(new dvd2(4,"Golden Eye","Action",4,17.99));
					myInventory.additem(new dvd2(5,"Dark Knight","Action",5,21.99));
					
               myInventory.showGUI();
				

				
					}//end main method	
						
				} //end class dvdTest
import java.util.Scanner;

public class dvdInventory
	{

		//array of items from dvd class
		public dvd2 dvdInv[] = new dvd2 [100];
		
		//variable to keep the maximum location
		public int p_maxLocation=0;
		
		public int index=0;
		
		//add constructor
	
		
		//method to add items to inventory
		public void addItem(dvd2 in_item)
		{
			dvdInv[p_maxLocation] = in_item;
			p_maxLocation++;
			
		}
		
		public void removeItem()
		{
			dvdInv[index] = dvdInv[p_maxLocation -1];
			--p_maxLocation;
		}
		
		public void reduceItem(dvd2 out_item)
		{
			dvdInv[p_maxLocation] = out_item;
			--p_maxLocation;
		}
		
		public dvdInventory(){
		}
			
		public int numberOfProducts()
		{
			return p_maxLocation;	
		}
		
		public dvd2 getitem(int in_index)
		{
			return dvdInv[in_index];
		}
		
		public void sort()
		{
			for( int loc=0;loc<p_maxLocation; loc++)
			{	int index=loc;
					dvd2 hold=dvdInv[index];
						while( index>0 && hold.getdvdTitle().compareTo(dvdInv[index-1].getdvdTitle())<0 )
						{
							dvdInv[index]=dvdInv[index-1];
									index--;
						}
						
					dvdInv[index]=hold;
					
			}
		}
		
		public double inventoryValue()
		{
			double addinv=0;
				for( int loc=0; loc<p_maxLocation; loc++ )
					addinv=addinv+dvdInv[loc].getStockValue();
						return addinv;
		}

	
	}//end Inventory
public class dvd
			{
	
					public String p_dvdTitle;
					public int p_stockNumber;
					public double p_dvdPrice;
					public int p_dvdStock;
	
					public dvd(String dvdTitle)
					{
						p_dvdTitle = dvdTitle;
					}
					
					public dvd( int stockNumber, String dvdTitle, int dvdStock, double dvdPrice )	
					{
						p_dvdTitle = dvdTitle;
						p_stockNumber = stockNumber;
						p_dvdPrice = dvdPrice;
						p_dvdStock = dvdStock;
					}	
					
					
					public void setdvdTitle()
					{
						p_dvdTitle = p_dvdTitle;
					}
					
					public String getdvdTitle()
					{
						return p_dvdTitle;
					}
	
					
					public void setstockNumber()
					{
						p_stockNumber = p_stockNumber;
					}
					
					
					public int getstockNumber()
					{
						return p_stockNumber;
					}
	
					public void setdvdPrice()
					{
						p_dvdPrice = p_dvdPrice;
					}
					
					public double getdvdPrice ()
					{
						return p_dvdPrice;
					}
					
					
					public void setdvdStock()
					{
						p_dvdStock = p_dvdStock;
					}
					
					
					public int getdvdStock()
					{
						return p_dvdStock;
					}					
				
					
							
					public double getStockValue()
					{
						return p_dvdStock * p_dvdPrice;
					}
										
									
				} //end class dvd
				
			class dvd2 extends dvd
			{
			
				public String movieGenre;
				public double stockValue;
				public double reStockValue;
		
				
				public dvd2(int p_stockNumber, String p_dvdTitle, String genre, int p_dvdStock, double p_dvdPrice)
				{       
				 super( p_stockNumber, p_dvdTitle, p_dvdStock, p_dvdPrice );
				 movieGenre = genre;
				 stockValue = 0;
				 reStockValue = 0;
				} 
				
				
				
				public void setMovieGenre()
				{
					movieGenre = movieGenre;
				}
				
				public String getMovieGenre()
				{
					return movieGenre; 
				}
										
				public double getStockValue()
				{
					return p_dvdPrice * p_dvdStock * 1.05;
				}
					
				public double getreStockValue()
				{
					double reStockValue = getStockValue() * .05;
					        
					return reStockValue;
				}
			
			}//ends Extened class dvd2

Hi,

I think the constructor in class dvdInv is incorrect, loose the void

public dvdInvGui() {
  }

Methods has returns types, constructors does not

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.