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