473,387 Members | 1,611 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Inventory project

I've been trying to compile this program:

// Display The CDs.
import java.text.*;
import java.util.*;

import java.awt.*;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.*;


public class ButtonFrame extends JFrame
{
private JButton nextJButton; // button with just text
private JButton prevJButton; // button with icons
private JButton lastJButton; // button with just text
private JButton firstJButton; // button with icons
private JButton deleteJButton; // button with icons
private JButton addJButton; // button with icons


private JLabel logoLabel;
private JTextField space1;
private JTextField space2;
private JTextField lblActor; // text field with set size
private JTextField txtActor; // text field constructed with text
private JTextField lblItemNum; // text field with set size
private JTextField txtItemNum; // text field constructed with text
private JTextField lblTitle; // text field with set size
private JTextField txtTitle; // text field constructed with text
private JTextField lblQuantity; // text field with set size
private JTextField txtQuantity; // text field constructed with text
private JTextField lblUnitPrice; // text field with set size
private JTextField txtUnitPrice; // text field constructed with text
private JTextField lblRestockFee; // text field with set size
private JTextField txtRestockFee; // text field constructed with text
private JTextField lblItemValue; // text field with set size
private JTextField txtItemValue; // text field constructed with text
private JTextField lblInventoryValue; // text field with set size
private JTextField txtInventoryValue; // text field constructed with text


// Just keeping an a class variable to keep count of where I am in the array
// keeping a class variable of the myPlayer array that I passed
UsedDVD[] arrayDVDs;
private int currentArrayCounter;
private int arrayCount;
private String invTotal;
// public Image i;


// i = getImage(getDocumentBase(), "logo.gif");

// ButtonFrame adds JButtons to JFrame
public ButtonFrame(UsedDVD[] myDVDs, int totalArrayCount, String stringInventoryTotal)
{

super( "UsedDVD Inventory" );
arrayDVDs = myDVDs;
invTotal=stringInventoryTotal;
// drawImage(i,0,0);

// I am setting the local passed variable totalArrayCount
// to the class variable arrayCounter so I can see it in the setTextfields method
arrayCount = totalArrayCount;
currentArrayCounter = 0;
// Sertting the current array position to 0


setLayout( new FlowLayout() ); // set frame layout
// Load the next and previous icons
Icon logo = new ImageIcon( getClass().getResource( "logo.gif" ) );
Icon iconAdd = new ImageIcon( getClass().getResource( "add.gif" ) );
Icon iconNext = new ImageIcon( getClass().getResource( "forward.gif" ) );
Icon iconPrev = new ImageIcon( getClass().getResource( "back.gif" ) );
Icon iconLast = new ImageIcon( getClass().getResource( "last.gif" ) );
Icon iconFirst = new ImageIcon( getClass().getResource( "first.gif" ) );
Icon iconDelete = new ImageIcon( getClass().getResource( "Delete.gif" ) );



logoLabel = new JLabel("",logo,SwingConstants.LEFT);
add(logoLabel);



// construct Label Fields with default text and 25 columns
space1 = new JTextField( "", 20 );
space1.setEditable( false ); // disable editing
add( space1 );
space2 = new JTextField( "", 20 );
space2.setEditable( false ); // disable editing
add( space2 );
lblItemNum = new JTextField( "Item Number", 25 );
lblItemNum.setEditable( false ); // disable editing
add( lblItemNum );
txtItemNum = new JTextField("", 25 );
add( txtItemNum ); // add txtActor to JFrame
lblActor = new JTextField( "Actor ", 25 );
lblActor.setEditable( false ); // disable editing
add( lblActor );
txtActor = new JTextField("", 25 );
add( txtActor ); // add txtActor to JFrame
lblTitle = new JTextField( "Title", 25 );
lblTitle.setEditable( false ); // disable editing
add( lblTitle );
txtTitle = new JTextField("", 25 );
add( txtTitle ); // add txtActor to JFrame
lblQuantity = new JTextField( "Quantity", 25 );
lblQuantity.setEditable( false ); // disable editing
add( lblQuantity );
txtQuantity = new JTextField("", 25 );
add( txtQuantity ); // add txtActor to JFrame
lblUnitPrice = new JTextField( "Unit Price", 25 );
lblUnitPrice.setEditable( false ); // disable editing
add( lblUnitPrice );
txtUnitPrice = new JTextField("", 25 );
add( txtUnitPrice ); // add txtUnitPrice to JFrame
lblRestockFee = new JTextField( "Restocking Fee", 25 );
lblRestockFee.setEditable( false ); // disable editing
add( lblRestockFee );
txtRestockFee = new JTextField("", 25 );
add( txtRestockFee ); // add txtActor to JFrame
lblItemValue = new JTextField( "Total Item Value", 25 );
lblItemValue.setEditable( false ); // disable editing
add( lblItemValue );
txtItemValue = new JTextField("", 25 );
add( txtItemValue ); // add txtActor to JFrame
lblInventoryValue = new JTextField( "Total Inventory Value", 25 );
lblInventoryValue.setEditable( false ); // disable editing
add( lblInventoryValue );
txtInventoryValue = new JTextField(invTotal, 25 );
add( txtInventoryValue ); // add txtActor to JFrame
// construct textfield with default text

// Create the buttons
nextJButton = new JButton( "Next", iconNext ); // button with Next
prevJButton =new JButton( "Prev" , iconPrev ); // button with Prev
lastJButton = new JButton( "Last", iconLast ); // button with Last
firstJButton =new JButton( "First" , iconFirst ); // button with First
deleteJButton = new JButton("Delete",iconDelete);
addJButton = new JButton ( "Add",iconAdd);

add( addJButton );
add( firstJButton ); // add plainJButton to JFrame
add(prevJButton);
add( nextJButton ); // add plainJButton to JFrame
add(lastJButton);
add(deleteJButton);



// create new ButtonHandler for button event handling
ButtonHandler handler = new ButtonHandler();
addJButton.addActionListener ( handler );
firstJButton.addActionListener( handler );
prevJButton.addActionListener( handler );
nextJButton.addActionListener( handler );
lastJButton.addActionListener( handler );
deleteJButton.addActionListener( handler );


// Now I am going to call SetTextFields to set the text fields
setTextFields();

} // end ButtonFrame constructor


These are my error codes what am I doing wrong?


// inner class for button event handling
private class ButtonHandler implements ActionListener
{
// handle button event
public void actionPerformed( ActionEvent event )
{

System.out.println("In Action Command - Current Event is " + event.getActionCommand());

// See which button was pressed
if (event.getActionCommand()== "Next"){


currentArrayCounter++;
}
else if (event.getActionCommand()== "Prev"){
currentArrayCounter--;
}
else if (event.getActionCommand()== "Last"){
currentArrayCounter= arrayCount-1;
}
else if (event.getActionCommand()== "First"){
currentArrayCounter = 0;
}
else if (event.getActionCommand()== "Add"){
arrayDVDs[currentArrayCounter=1].addToQuantity();

}

else if (event.getActionCommand()== "Delete"){
arrayDVDs[currentArrayCounter].removeOneFromQuantity();
System.out.println("Deleting");
}







setTextFields();

} // end method actionPerformed
} // end private inner class ButtonHandler



private void setTextFields ()
{
// This is to ensure that you are not at the end of the array
if (currentArrayCounter == arrayCount)
{
currentArrayCounter = 0;
}

// This is set to prevent from going past the first if so I am setting it to the last
if (currentArrayCounter < 0)
{
currentArrayCounter = arrayCount-1;
}

// System.out.println(currentArrayCounter); // Debug statement

NumberFormat n = NumberFormat.getCurrencyInstance(Locale.US); //Provides Locale appropriate currency format

txtActor.setText(arrayDVDs[currentArrayCounter].getactor());
txtItemNum.setText(arrayDVDs[currentArrayCounter].getitemnumber());
txtTitle.setText(arrayDVDs[currentArrayCounter].gettitle());
txtQuantity.setText(Double.toString(arrayDVDs[currentArrayCounter].getquantity()));
txtUnitPrice.setText(Double.toString(arrayDVDs[currentArrayCounter].getunitprice()));
String stringRestockFee = n.format(arrayDVDs[currentArrayCounter].CalculateRestockFee());
txtRestockFee.setText(stringRestockFee);
txtItemValue.setText(n.format(arrayDVDs[currentArrayCounter].calculateDVDValue()));


}


} // end class ButtonFrame


E:\java\ButtonFrame.java:51: cannot find symbol
symbol : class UsedDVD
location: class ButtonFrame
UsedDVD[] arrayDVDs;
^
E:\java\ButtonFrame.java:61: cannot find symbol
symbol : class UsedDVD
location: class ButtonFrame
public ButtonFrame(UsedDVD[] myDVDs, int totalArrayCount, String stringInventoryTotal)
^
2 errors

Tool completed with exit code 1
Apr 21 '10 #1
1 2132
jkmyoung
2,057 Expert 2GB
Have you included the UsedDVD class in your build path? Or have you not written the class yet?
Apr 21 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: smonczka | last post by:
I am trying to locate an inventory template. I have looked at the one that comes with Access but what I need is a little more complicated. We ship boxes of software and the inventory consists not...
13
by: royaltiger | last post by:
I am trying to copy the inventory database in Building Access Applications by John L Viescas but when i try to run the database i get an error in the orders form when i click on the allocate...
3
by: Henrik | last post by:
Hi all, I'm a .net developer working with developing automation equipment for the sawmill industry. The main focus of our product line is mechanical and measurement equipment but our clients...
109
by: zaidalin79 | last post by:
I have a java class that goes for another week or so, and I am going to fail if I can't figure out this simple program. I can't get anything to compile to at least get a few points... Here are the...
0
by: south622 | last post by:
I'm taking a beginning Java course and I'm stuck in week eight of a nine week course. If anyone could help me I would greatly appreciate it. This assignment was due yesterday and each day I go past...
9
by: xxplod | last post by:
I am suppose to modify the Inventory Program so the application can handle multiple items. Use an array to store the items. The output should display the information one product at a time, including...
3
by: cblank | last post by:
I need some help if someone could help me. I know everyone is asking for help in java. But for some reason I'm the same as everyone else when it comes to programming in java. I have an inventory...
2
by: pinkf24 | last post by:
I cannot figure out how to add the following: Modify the Inventory Program to include an Add button, a Delete button, and a Modify button on the GUI. These buttons should allow the user to perform...
1
by: jcato77 | last post by:
I need help with a class project I'm working on, Below is my assignment and the code I have currently created. Assignment: Modify the Inventory Program by creating a subclass of the product class...
3
by: 100grand | last post by:
Modify the Inventory Program to use a GUI. The GUI 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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.