QUOTE(letthecolorsrumble @ 18 Mar, 2008 - 09:15 PM)

I'm guessing that the error should be here :
s = inventory.Search(s);
If you have implemented the Search(); method in the Inventory class, could you please post the code?
QUOTE
I have been able to build a search text area and it loads after compiling. I believe I can build a for statement that will run through each of the array Names elements and if equals break or calls that informtion out. What I should have probably asked is; I have a program that inside the "InventoryPart1.java" has an array. In that array I have 4 elements with information, hard coded. To build this search, I need to count this information plus the "added" inventory data when I create the "add button". Will I need to build an open array somehow and pull the existing array data into it before I can build an "add" and a "search"? Also, am I heading in the correct direction regarding the build of the search? If correct, can I get assistance on how I go about pulling out of the initial array into a new open array?
CODE
import java.util.Arrays;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.DecimalFormat;
class GUI extends JFrame {
// declare instance variables
// THIS IS THE VALUE THAT WILL RUN IN THE INVENTORY[ INDEX ]
//WHEN THE NEXT BUTTON IS CLICKED
private int currentProdno = 0;
// INVENTORY WILL GET THE VALUE PASSED IN THE CONSTRUCTOR PARAMETER
private NameRestock[ ] inventory;
private JTextField jtfprdItem; //1
private JTextField jtfprdName; //2
private JTextField jtfprdUnit; //3
private JTextField jtfprdPrice;//4
private JTextField jtfgetResult;//5 getresult()
private JTextField jtfReStock; //6 getrestock()
private JTextField jtfstrCName;//7
private JTextField jtfinvTotal;//8
private double totValue;
private int i = 0;
private JButton btnFirst;
private JButton btnNext;
private JButton btnPrevious;
private JButton btnLast;
//**************************
private JButton btnSave;
private JButton btnAdd;
private JButton btnDelete;
private JButton btnModify;
private JButton btnSearch;
//**************************
private double tmp;
//private Formatter output;
GUI( NameRestock[ ] inv ) {
super("Inventory Part 4 Program");
inventory = inv; // ASSIGN inv FROM TO inventor
JPanel jp;
JLabel jl;
JPanel outerPanel = new JPanel();
outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.Y_AXIS));
JPanel titlePanel = new JPanel();
titlePanel.setLayout(new FlowLayout(FlowLayout.CENTER));
jl = new JLabel("Inventory Part 4");
titlePanel.add(jl);
ImageIcon ig = new ImageIcon("CpyLogo.jpg");
//outerPanel.add(titlePanel);
outerPanel.add(new JLabel(ig));
//******************************************
JPanel numberPanel = new JPanel();
numberPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
jl = new JLabel(" Number: " );//Count of each item
numberPanel.add(jl);
jtfprdItem = new JTextField (3);
jtfprdItem.setEditable(false);
numberPanel.add(jtfprdItem);
outerPanel.add(numberPanel);
JPanel number1Panel = new JPanel();
number1Panel.setLayout(new FlowLayout(FlowLayout.LEFT));
jl = new JLabel(" Name: " );//Name of item
number1Panel.add(jl);
jtfprdName = new JTextField (12);
jtfprdName.setEditable(false);
number1Panel.add(jtfprdName);
outerPanel.add(number1Panel);
JPanel number2Panel = new JPanel();
number2Panel.setLayout(new FlowLayout(FlowLayout.LEFT));
jl = new JLabel(" Units: " );// Number of each item
number2Panel.add(jl);
jtfprdUnit = new JTextField(3);
jtfprdUnit.setEditable(false);
number2Panel.add(jtfprdUnit);
outerPanel.add(number2Panel);
JPanel number3Panel = new JPanel();
number3Panel.setLayout(new FlowLayout(FlowLayout.LEFT));
jl = new JLabel(" Price: $ " );
number3Panel.add(jl);
jtfprdPrice = new JTextField(4);
jtfprdPrice.setEditable(false);
number3Panel.add(jtfprdPrice);
outerPanel.add(number3Panel);
JPanel number4Panel = new JPanel();
number4Panel.setLayout(new FlowLayout(FlowLayout.LEFT));
jl = new JLabel(" Total: $ " );//Total Price of Items
number4Panel.add(jl);
jtfgetResult = new JTextField(5);
jtfgetResult.setEditable(false);
number4Panel.add(jtfgetResult);
outerPanel.add(number4Panel);
JPanel number5Panel = new JPanel();
number5Panel.setLayout(new FlowLayout(FlowLayout.LEFT));
jl = new JLabel("Restocking Fee: $ " );//Restocking FEE
number5Panel.add(jl);
jtfReStock = new JTextField(6);
jtfReStock.setEditable(false);
number5Panel.add(jtfReStock);
outerPanel.add(number5Panel);
JPanel number6Panel = new JPanel();
number5Panel.setLayout(new FlowLayout(FlowLayout.LEFT));
jl = new JLabel("Company Name: " );//Company Name
number6Panel.add(jl);
jtfstrCName = new JTextField(7);
jtfstrCName.setEditable(false);
number6Panel.add(jtfstrCName);
outerPanel.add(number6Panel);
JPanel number7Panel = new JPanel();
number7Panel.setLayout(new FlowLayout(FlowLayout.LEFT));
jl = new JLabel("Total Invenory Value: $" );//Total Inventory Value
number7Panel.add(jl);
jtfinvTotal = new JTextField(7);
jtfinvTotal.setEditable(false);
number7Panel.add(jtfinvTotal);
outerPanel.add(number7Panel);
//******************************************
//Button Area:
JPanel jpButtonF = new JPanel();
JButton jbFirst = new JButton("First");
jbFirst.addActionListener(new FirstButtonHandler());
jpButtonF.add(jbFirst);
outerPanel.add(jpButtonF);
JPanel jpButtonN = new JPanel();
JButton jbNext = new JButton("Next");
jbNext.addActionListener(new NextButtonHandler());
jpButtonN.add(jbNext);
outerPanel.add(jpButtonN);
JPanel jpButtonP = new JPanel();
JButton jbPrevious = new JButton("Previous");
jbPrevious.addActionListener(new PreviousButtonHandler());
jpButtonP.add(jbPrevious);
outerPanel.add(jpButtonP);
JPanel jpButtonL = new JPanel();
JButton jbLast = new JButton("Last");
jbLast.addActionListener(new LastButtonHandler());
jpButtonL.add(jbLast);
outerPanel.add(jpButtonL);
JPanel jpButtonS = new JPanel();
JButton jbSave = new JButton("Save");
jbSave.addActionListener(new LastButtonHandler());
jpButtonS.add(jbSave);
outerPanel.add(jpButtonS);
JPanel jpButtonD = new JPanel();
JButton jbDelete = new JButton("Delete");
jbDelete.addActionListener(new LastButtonHandler());
jpButtonD.add(jbDelete);
outerPanel.add(jpButtonD);
JPanel jpButtonA = new JPanel();
JButton jbAdd = new JButton("Add");
jbAdd.addActionListener(new LastButtonHandler());
jpButtonA.add(jbAdd);
outerPanel.add(jpButtonA);
JPanel jpButtonM = new JPanel();
JButton jbModify = new JButton("Modify");
jbModify.addActionListener(new LastButtonHandler());
jpButtonM.add(jbModify);
outerPanel.add(jpButtonM);
JPanel jpButtonSch = new JPanel();
JButton jbSearch = new JButton("Search");
jbSearch.addActionListener(new SearchButtonHandler());
jpButtonSch.add(jbSearch);
outerPanel.add(jpButtonSch);
//*******************************************
//Call update Fields
updateNButton( inventory, currentProdno );
updateFields( inventory, currentProdno );
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(300, 75, 550, 650);
setContentPane(outerPanel);
setResizable(false);
setVisible(true);
}//end GUI
public void updateNButton( NameRestock[ ] inventory, int index )
{
totValue += inventory[ index ].getRestock();
}
public void updatePButton( NameRestock[ ] inventory, int index )
{
// totValue -= inventory[currentProdno - 1].getRestock();
if (currentProdno <= -1)
{
currentProdno = (inventory.length-1);
totValue = inventory[currentProdno].getRestock();
//--currentProdno;
//totValue = inventory[currentProdno].getRestock();
}
else
{
//--currentProdno;
totValue = inventory[currentProdno].getRestock();
}
}
public void updateLButton( NameRestock[ ] inventory, int index)
{
//currentProdno = (inventory.length-1);
for(i = 0;i <= (inventory.length-1);i++)
{
totValue += inventory[ i ].getRestock();
}
}
//updateFields NEED 2 PARAMENTER THE OBJECT AND THE INDEX
//TO SPECIFY THE ARRAY ELEMENT
public void updateFields( NameRestock[ ] inventory, int index )
{
jtfprdItem.setText( "" + inventory[ index ].getnumItem() );//Number
jtfprdName.setText( "" + inventory[ index ].getstrName() );//Name
jtfprdUnit.setText( "" + inventory[ index ].getnumUnit() );//Units
jtfprdPrice.setText( "" + inventory[ index ].getnumPrice() );//Price
jtfgetResult.setText( "" + String.format("%.2f",inventory[ index ].getResult()));//Total
jtfReStock.setText( "" + String.format("%.2f",inventory[ index ].getRestock()) );//Restocking Fee
jtfstrCName.setText( "" + inventory[ index ].getstrCName() );//Company
//jtfinvTotal.setText( "" + inventory[ index ].gettotValue() );//Total Value
jtfinvTotal.setText( "" + String.format("%.2f",totValue ));//Total Value
} // end updateFields()
//**********************************************************
//Next Button
class NextButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
if (currentProdno > inventory.length-2)
{
currentProdno = -1;
totValue = 0;
++currentProdno;
updateNButton( inventory, currentProdno );
}
else
{
++currentProdno;
updateNButton( inventory, currentProdno );
}
updateFields( inventory, currentProdno);
}
}//end Next Button
//**********************************************************
//First Button
class FirstButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
totValue = 0;
currentProdno = 0;
updateNButton( inventory, currentProdno );
updateFields( inventory, currentProdno );
}
} //end First Button
//**********************************************************
//Previous Button
class PreviousButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
if (currentProdno == 0)
{
totValue = 0;
updateLButton( inventory, currentProdno );
currentProdno = inventory.length - 1;
//totValue = inventory[currentProdno].getRestock();
}
else
{
--currentProdno;
totValue -= inventory[currentProdno + 1].getRestock();
}
// updatePButton( inventory, currentProdno );
updateFields( inventory, currentProdno );
}
} //end Previous Button
//**********************************************************
//Last Button
class LastButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
totValue = 0;
currentProdno = (inventory.length-1);
updateLButton( inventory, currentProdno );
updateFields( inventory, currentProdno );
}
} //end Last Button
//***********************************************************
//Search Button
class SearchButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
String productName = JOptionPane.showInputDialog("Enter product name");
}
} //end Last Button
//***********************************************************
} // end GUI class