473,396 Members | 2,017 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,396 software developers and data experts.

Inventory Program part 6

I am trying to modify my program to add and delete inventory items. I tried just adding but I am getting mutliple errors help.

This is what my program currently looks like what am I missing?

// Display The DVDs.
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 addJButton;// button with icons
private JButton deleteJButton; // button with icons
private JLabel logoLabel;
private JTextField space1;
private JTextField space2;
private JTextField lblArtist; // text field with set size
private JTextField txtArtist; // 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 iconDelete = new ImageIcon( getClass().getResource( "delete.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" ) );
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
lblArtist = new JTextField( "Actor", 25 );
lblArtist.setEditable( false ); // disable editing
add( lblArtist );
txtArtist = new JTextField("", 25 );
add( txtArtist ); // 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
addJButton = new JButton( "Add", iconAdd ); // button with Add
deleteJButton = new JButton( "Delete", iconDelete ); // button with Delete
nextJButton = new JButton( "Next", iconNext ); // button with Next
prevJButton =new JButton( "Prev" , iconPrev ); // button with Next
lastJButton = new JButton( "Last", iconLast ); // button with Next
firstJButton =new JButton( "First" , iconFirst ); // button with Next
add( addJButton ); // add plainJButton to JFrame
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





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

// System.out.println(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;
}

setTextFields();

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



private void setTextFields ()
{
// Make sure you havent gone past the end of the array
if (currentArrayCounter == arrayCount)
{
currentArrayCounter = 0;
}

// Make sure you havent gone past the first if so, set 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

txtArtist.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
May 28 '07 #1
1 1152
JosAH
11,448 Expert 8TB
Where is that 'main question'? You're posting the same long code listing again.

kind regards,

Jos
May 28 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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...
3
MonolithTMA
by: MonolithTMA | last post by:
Greetings all, I am new here, and aside from my introductory post, this will be my first. I am working on an Inventory program for a class I am taking. I've searched the forums here and have...
10
by: mistb2002 | last post by:
I am trying to modify my program to add and delete inventory items. I tried just adding but I am getting mutliple errors help. This is what my program currently looks like // Display The...
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...
5
by: cblank | last post by:
I'm having some trouble with my inventory program. Its due tom and my teacher is not wanting to help. He keeps giving me a soluction that is not related to my code. I have everything working except...
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...
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...
2
by: blitz1989 | last post by:
Hello all, I'm new to this forum and Java and having a alot of problems understanding this language. I am working on an invetory program part 4. The assignment requirements are listed but the...
16
by: lilsugaman | last post by:
I have to assignment which includes the following: Modify the Inventory Program so the application can handle multiple items. Use an array to store the items. The output should display the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.