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!