here is the files/problems
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package farmersmarket3;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
/**
*
* @author Omar "RamO" Muthana
*/
class FarmersMarket3 implements ActionListener
{
static JFrame jfrMain;
// Declare 9 buttons
static JButton jbnFirst, jbnNext, jbnPrevious, jbnLast, jbnAdd, jbnDelete, jbnModify,jbnSearch, jbnSave;
// Declare a panel to draw on
static JPanel jplNavigation;
// Declare Advanced panel for additional buttons
static JPanel jplAdvanced;
// Declare a text area
static JTextArea jtxtArea;
// Declare a Label
static JLabel jlblLogo, jlbLabel;
public FarmersMarket3 (){
// Create and set up the window.
jfrMain = new JFrame("Salesman Data Report");
jfrMain.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Add the text area
jtxtArea = new JTextArea();
jtxtArea.append(NewProduce.getCurrentProduceString());
jfrMain.getContentPane().add(jtxtArea);
// Create Panel for buttons
jplNavigation = new JPanel();
jlbLabel = new JLabel();
jlbLabel.setText("SALES LEAD PROGRAM");
// Create Advanced panel for additional buttons
jplAdvanced = new JPanel();
// Create First button
jbnFirst = new JButton("First");
jbnFirst.addActionListener(this);
jbnFirst.setActionCommand("first");
// Create Previous button
jbnPrevious = new JButton("Previous");
jbnPrevious.addActionListener(this);
jbnPrevious.setActionCommand("previous");
// Create Next button
jbnNext = new JButton("Next");
jbnNext.addActionListener(this);
jbnNext.setActionCommand("next");
// Create Last button
jbnLast = new JButton("Last");
jbnLast.addActionListener(this);
jbnLast.setActionCommand("last");
// Create Add button
jbnAdd = new JButton("Add");
jbnAdd.addActionListener(this);
jbnAdd.setActionCommand("add");
// Create Delete button
jbnDelete = new JButton("Delete");
jbnDelete.addActionListener(this);
jbnDelete.setActionCommand("delete");
// Create Modify button
jbnModify = new JButton("Modify");
jbnModify.addActionListener(this);
jbnModify.setActionCommand("modify");
// Create Search button
jbnSearch = new JButton("Search");
jbnSearch.addActionListener(this);
jbnSearch.setActionCommand("search");
// Create Save button
jbnSave = new JButton("Save");
jbnSave.addActionListener(this);
jbnSave.setActionCommand("save");
// Add Title label to the panel
jplNavigation.add(jlbLabel);
// Add buttons to Advanced Panel
jplAdvanced.add(jbnFirst);
jplAdvanced.add(jbnPrevious);
jplAdvanced.add(jbnNext);
jplAdvanced.add(jbnLast);
jplAdvanced.add(jbnAdd);
jplAdvanced.add(jbnDelete);
jplAdvanced.add(jbnModify);
jplAdvanced.add(jbnSearch);
jplAdvanced.add(jbnSave);
// Create Logo
jlblLogo = new JLabel(createImageIcon("Farmers.gif"));
// Add panel to frame
jfrMain.getContentPane().add(jplNavigation, BorderLayout.PAGE_START);
jfrMain.getContentPane().add(jtxtArea, BorderLayout.WEST);
jfrMain.getContentPane().add(jlblLogo, BorderLayout.EAST);
// Add Advanced panel to frame
jfrMain.getContentPane().add(jplAdvanced, BorderLayout.PAGE_END);
//Display the window.
jfrMain.pack();
jfrMain.setVisible(true);
}
private static void showCurrentSales(){
jtxtArea.setText(NewProduce.getCurrentProduceString());
}
private static ImageIcon createImageIcon(String fileName) {
java.net.URL imgURL = FarmersMarket3.class.getResource(fileName);
return new ImageIcon(imgURL);
}
public static void enableButtons(boolean enable) {
jbnFirst.setEnabled(enable);
jbnNext.setEnabled(enable);
jbnPrevious.setEnabled(enable);
jbnLast.setEnabled(enable);
jbnDelete.setEnabled(enable);
jbnModify.setEnabled(enable);
jbnSearch.setEnabled(enable);
jbnSave.setEnabled(enable);
return;
}
@SuppressWarnings("static-access")
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
if ("first".equalsIgnoreCase(e.getActionCommand())) {
NewProduce.showFirst();
showCurrentSales();
} else if (("PREVIOUS").equalsIgnoreCase(e.getActionCommand())) {
NewProduce.showPrevious();
showCurrentSales();
} else if ("next".equalsIgnoreCase(e.getActionCommand())) {
NewProduce.showNext();
showCurrentSales();
} else if ("last".equalsIgnoreCase(e.getActionCommand())) {
NewProduce.showLast();
showCurrentSales();
} else if ("add".equalsIgnoreCase(e.getActionCommand())) {
AddNewProduce dialog = new AddNewProduce(this.jfrMain, true);
dialog.setSize(250, 120);
dialog.setVisible(true);
if (dialog.bOKPressed) {
AddNewProduce.newSalesData(dialog.getSalesman());
showCurrentSales();
enableButtons(true);
}
} else if ("delete".equalsIgnoreCase(e.getActionCommand())) {
DeleteProduce dialog = new DeleteProduce(FarmersMarket3.jfrMain, true);
dialog.setSize(250, 120);
dialog.setVisible(true);
if (dialog.bOKPressed) {
NewProduce.getStringArray();
showCurrentSales();
if (NewProduce.getCurrentProduce() == 0) {
enableButtons(false);
}
}
} else if ("modify".equalsIgnoreCase(e.getActionCommand())) {
ModifyFarmer dialog = new ModifyFarmer(FarmersMarket3.jfrMain, true);
dialog.setSize(250, 120);
dialog.setVisible(true);
if (dialog.bOKPressed) {
ModifyFarmer.newSalesData (dialog.getSalesmanData());
showCurrentSales();
}
// copy for all new classes
} else if ("search".equalsIgnoreCase(e.getActionCommand())) {
SearchFarm dialog = new SearchFarm(FarmersMarket3.jfrMain, true);
dialog.setSize(250, 78);
dialog.setVisible(true);
if (dialog.bOKPressed) {
SearchFarm.(dialog.getSalesManName());
showCurrentSales();
}
} else if ("save".equalsIgnoreCase(e.getActionCommand())) {
SaveFarm dialog = new SaveFarm(FarmersMarket3.jfrMain, true);
dialog.setSize(250, 60);
dialog.setVisible(true);
if (dialog.bOKPressed) {
NewProduce.saveSalesData();
showCurrentSales();
}
} else {
// something is wrong
}
}
public static void searchFailed() {
JOptionPane.showMessageDialog(jfrMain, "Salesman not found");
return;
}
public static void saveFailed() {
JOptionPane.showMessageDialog(jfrMain, "Did not save salesman data");
return;
}
public static void saveSuccessful() {
JOptionPane.showMessageDialog(jfrMain, "Save salesman data");
return;
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package farmersmarket3;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JTextField;
/**
*
* @author Omar "Ramo" Muthana
*/
public class AddNewProduce extends JDialog
{
private static final long serialVersionUID = 1L;
static void NewProduce(String[] salesman) {
throw new UnsupportedOperationException("Not yet implemented");
}
static void newSalesData(String[] salesman) {
throw new UnsupportedOperationException("Not yet implemented");
}
private JLabel jlblName = new JLabel("Farmers/ Farm Name");
private JTextField jtxtName = new JTextField();
private JLabel jlblProduceName = new JLabel("Produce Name");
private JTextField jtxtProduceName = new JTextField();
private JLabel jlblPrice = new JLabel("Price of Produce");
private JTextField jtxtPrice = new JTextField();
private String[] newSalesData = new String[3];
JButton jbnOK = new JButton("Add");
JButton jbnCancel = new JButton("Cancel");
public Boolean bOKPressed = false;
public AddNewProduce(Frame owner, boolean modal) {
super(owner, modal);
init();
}
private void init() {
this.setTitle("Add a Farmer");
this.setLayout(new GridLayout(4, 2));
this.add(getJlblName());
this.add(jtxtName);
this.add(jlblProduceName);
this.add(jtxtProduceName);
this.add(jlblPrice);
this.add(jtxtPrice);
jbnOK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
bOKPressed = true;
dispose();
}
});
jbnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
dispose();
}
});
this.add(jbnOK);
this.add(jbnCancel);
}
public String[] getSalesman() {
getNewSalesData()[0] = jtxtName.getText();
getNewSalesData()[1] = jtxtProduceName.getText();
getNewSalesData()[2] = jtxtPrice.getText();
return getNewSalesData();
}
/**
* @return the jlblName
*/
public JLabel getJlblName() {
return jlblName;
}
/**
* @param jlblName the jlblName to set
*/
public void setJlblName(JLabel jlblName) {
this.jlblName = jlblName;
}
/**
* @return the newSalesData
*/
public String[] getNewSalesData() {
return newSalesData;
}
/**
* @param newSalesData the newSalesData to set
*/
public void setNewSalesData(String[] newSalesData) {
this.newSalesData = newSalesData;
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package farmersmarket3;
import farmersmarket3.NewProduce;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JTextField;
/**
*
* @author Omar "Ramo" MUthana
*/
public class DeleteProduce extends JDialog {
private static final long serialVersionUID = 1L;
private JLabel jlblName = new JLabel("Farmers Name");
private JTextField jtxtName = new JTextField();
private JLabel jlblNewProduce = new JLabel("Produce Sold");
private JTextField jtxtNewProduce = new JTextField();
private JLabel jlblPrice = new JLabel("Price of Produce");
private JTextField jtxtPrice = new JTextField();
String[] DeleteProduce = new String[3];
JButton jbnOK = new JButton("Delete");
JButton jbnCancel = new JButton("Cancel");
public Boolean bOKPressed = false;
public DeleteProduce(Frame owner, boolean modal) {
super(owner, modal);
init();
}
private void init() {
this.setTitle("Delete Farmers Data");
this.setLayout(new GridLayout(4, 2));
this.add(jlblName);
this.add(jtxtName);
this.add(jlblNewProduce);
this.add(jtxtNewProduce);
this.add(jlblPrice);
this.add(jtxtPrice);
populateTextFields();
jbnOK.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
bOKPressed = true;
dispose();
}
});
jbnCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
dispose();
}
});
this.add(jbnOK);
this.add(jbnCancel);
}
public String getDVD() {
return jtxtName.getText();
}
private void populateTextFields() {
String[] currentSales = NewProduce.getStringArray();
jtxtName.setText(currentSales[0]);
jtxtNewProduce.setText(currentSales[1]);
jtxtPrice.setText(currentSales[3]);
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package farmersmarket3;
import farmersmarket3.NewProduce;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JTextField;
/**
*
* @author Omar "RamO" Muthana
*/
public class ModifyFarmer extends JDialog {
private static final long serialVersionUID = 1L;
static void newSalesData(String[] salesmanData) {
throw new UnsupportedOperationException("Not yet implemented");
}
JLabel jlblName = new JLabel("Salesman Name");
JTextField jtxtName = new JTextField();
JLabel jlblWidgetsSold = new JLabel("Widgets Sold");
JTextField jtxtWidgetsSold = new JTextField();
JLabel jlblPrice = new JLabel("Price");
JTextField jtxtPrice = new JTextField();
JLabel jlblDept = new JLabel("Dept");
JTextField jtxtDept = new JTextField();
String[] newSalesData = new String[4];
JButton jbnOK = new JButton("Modify");
JButton jbnCancel = new JButton("Cancel");
public Boolean bOKPressed = false;
public ModifyFarmer(Frame owner, boolean modal) {
super(owner, modal);
init();
}
private void init() {
this.setTitle("Modify Salesman Data");
this.setLayout(new GridLayout(5, 2));
this.add(jlblName);
this.add(jtxtName);
this.add(jlblWidgetsSold);
this.add(jtxtWidgetsSold);
this.add(jlblPrice);
this.add(jtxtPrice);
this.add(jlblDept);
this.add(jtxtDept);
populateTextFields();
jbnOK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
bOKPressed = true;
dispose();
}
});
jbnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
dispose();
}
});
this.add(jbnOK);
this.add(jbnCancel);
}
public String[] getSalesmanData() {
newSalesData[0] = jtxtName.getText();
newSalesData[1] = jtxtDept.getText();
newSalesData[2] = jtxtWidgetsSold.getText();
newSalesData[3] = jtxtPrice.getText();
return newSalesData;
}
private void populateTextFields() {
String[] currentSales = NewProduce.getStringArray();
jtxtName.setText(currentSales[0]);
jtxtDept.setText(currentSales[1]);
jtxtWidgetsSold.setText(currentSales[2]);
jtxtPrice.setText(currentSales[3]);
}
}
package farmersmarket3;
import java.text.NumberFormat;
import java.util.Formatter;
import java.util.Locale;
import javax.swing.JDialog;
/**
*
* @author Omar "RamO" Muthana
*/
public class NewProduce
{
// Create an array of Produce
private static ProdDataFormat[] farmData = new ProdDataFormat[0]; //array object
// Keep track of current Produce
private static int currentProduce = 0;
private static final long serialVersionUID = 1L;
// main method begins execution of the Java application;
public static void main( String args[])
{
//loading the array object
addFarmData("Apples","RamO's Orchard Farm", 12345678,120, 4.79);
addFarmData("Oranges","RamO's Orchard Farm", 87654321, 150, 2.25);
addFarmData("Peaches","RamO's Orchard Farm",12312312, 120, 5.95);
addFarmData("HoneyDue Melon's","Melon's de RamO",20947136, 140,3.75);
addFarmData("Watermelon","Melon's de RamO",86125390, 220,12.95);
dataSort(); //call a method to sort the data
FarmersMarket3 appGUI = new FarmersMarket3(); //calls constructor
} // end main
public static float inventoryValue()
{
float total = 0;
for(int x = 0; x < getFarmData().length; x++){
total += getFarmData()[x].getTotalSales();
}// end for loop
return total;
}
public static void dataSort()
{
ProdDataFormat tmp;
for (int currentNewProduce = 0; currentNewProduce < getFarmData().length; currentNewProduce++) {
for (int i = currentNewProduce + 1; i< getFarmData().length; i++) {
String s1 = getFarmData()[currentNewProduce].getProdName();
String s2 = getFarmData()[i].getProdName();
if( s1.compareTo(s2) > 0) {
tmp = getFarmData()[currentNewProduce];
getFarmData()[currentNewProduce] = getFarmData()[i];
getFarmData()[i] = tmp;
}
}
}
}
// Return a string for the current Produce
public static String getCurrentProduceString() {
if (getFarmData().length == 0) {
return "No Produce data";
} else {
StringBuilder sb = new StringBuilder();
// Send all output to the Appendable object sb
Formatter formatter = new Formatter(sb, Locale.US);
// Build Inventory String
formatter.format(getFarmData()[getCurrentProduce()].toString());
formatter.format("\n");
formatter.format("Total Inventory Value: %s\n", NumberFormat.getCurrencyInstance().format(inventoryValue()));
return sb.toString();
}
}
// Method to increment current produce
public static void showNext(){
if (getCurrentProduce() == getFarmData().length - 1){
showFirst();
} else {
setCurrentProduce(getCurrentProduce() + 1);
}
}
// Method to go to first item
public static void showFirst(){
setCurrentProduce(0);
}
// Method to go to last item
public static void showLast(){
setCurrentProduce(getFarmData().length - 1);
}
/**
*
*/
public static void showPrevious(){
setCurrentProduce(getFarmData().length + - 1);
}
//
public static String[] getStringArray() {
String[] currentStringArray = new String[4];
currentStringArray[2] = Integer.toString(getFarmData()[getCurrentProduce()].getProdSKU());
currentStringArray[0] = getFarmData()[getCurrentProduce()].getProdName();
currentStringArray[1] = getFarmData()[getCurrentProduce()].getFarmName();
currentStringArray[3] = Integer.toString(getFarmData()[getCurrentProduce()].getProdUnits());
currentStringArray[4] = Double.toString(getFarmData()[getCurrentProduce()].getProdPrice());
return currentStringArray;
}
public static void addFarmData(String name, String farm, int SKU, int units, double price) {
String[] newProduce = new String[4]; //create a String array
//load the array with the items that was passed into the method
newProduce[0] = name;
newProduce[1] = farm;
newProduce[2] = Integer.toString(SKU);
newProduce[2] = Integer.toString(units); //convert the integer pass in to a string
newProduce[3] = Double.toString(price);
addProduce(newProduce); //method call
//return;
}
//assigns the SKU number to the current array object
public static int getNextFarmData() {
int newCode=0;
for (int x = 0; x < getFarmData().length; x++)
{
if (getFarmData()[x].getProdSKU() > newCode)
{
newCode = getFarmData()[x].getProdSKU();
}
}
return newCode +1;
}
// New Method called addProduce
public static void addProduce(String[] data) {
// Add a new Produce
ProdDataFormat sDataFormat = new ProdDataFormat(getNextFarmData(), data[0], Integer.valueOf(data[2]), Double.valueOf(data[3]), data[1]);
Class elementType = getFarmData().getClass().getComponentType();
ProdDataFormat[] newArray = (ProdDataFormat[]) java.lang.reflect.Array.newInstance(elementType,getFarmData().length + 1);
System.arraycopy(getFarmData(), 0, newArray, 0, getFarmData().length);
newArray[newArray.length - 1] = sDataFormat;
setFarmData(newArray);
showLast();
dataSort();
}
/**
* @return the farmData
*/
public static ProdDataFormat[] getFarmData() {
return farmData;
}
/**
* @param aFarmData the farmData to set
*/
public static void setFarmData(ProdDataFormat[] aFarmData) {
farmData = aFarmData;
}
/**
* @return the currentProduce
*/
public static int getCurrentProduce() {
return currentProduce;
}
/**
* @param aCurrentProduce the currentProduce to set
*/
public static void setCurrentProduce(int aCurrentProduce) {
currentProduce = aCurrentProduce;
}
}
package farmersmarket3;
import java.text.NumberFormat;
import java.util.Formatter;
import java.util.Locale;
/**
*
* @author Omar "RamO" Muthana
*/
class ProdDataFormat extends Proddata
{
private static final long serialVersionUID = 1L;
private String farmName;
public ProdDataFormat(int SKU, String pName, int pUnits, double pPrice, String fName)
{
super(SKU, pName, pUnits, pPrice);
farmName = fName;
}
public ProdDataFormat(int SKU, String pName, int pUnits, double pPrice)
{
super (SKU, pName, pUnits, pPrice);
}
public ProdDataFormat(String pName) {
super(pName);
}
public String getFarmName(){
return farmName;
}
public void setFarmName(String fName){
farmName = fName;
}
@Override
public double getTotalSales(){
return super.getTotalSales();
}
public double getSalesTax() {
return super.getTotalSales() * .07;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
// Send all output to the Appendable object sb
Formatter formatter = new Formatter(sb, Locale.US);
// Explicit argument indices may be used to re-order output.
formatter.format("SKU: %d\n", getProdSKU());
formatter.format("Item Name: %s\n", getProdName());
formatter.format("Farm Name: %s\n", getFarmName());
formatter.format("Number of Units Sold: %d\n", getProdUnits());
formatter.format("Produce Price: %s\n", NumberFormat.getCurrencyInstance().format(getProdPrice()));
formatter.format("Total Sales: %s\n", NumberFormat.getCurrencyInstance().format(getTotalSales()));
formatter.format("Sales Tax: %s\n", NumberFormat.getCurrencyInstance().format(getSalesTax()));
formatter.format("Grand Total: %s\n", NumberFormat.getCurrencyInstance().format(getTotalSales() + getSalesTax()));
return sb.toString();
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package farmersmarket3;
/**
*
* @author Omar "RamO" Muthana
*/
class Proddata
{
private int prodSKU;
private String prodName;
private int prodUnits;
private double prodPrice;
public Proddata(int SKU, String pName, int pUnits, double pPrice)
{
prodSKU = SKU;
prodName = pName;
prodUnits = pUnits;
prodPrice = pPrice;
}
public Proddata(String pName)
{
prodName = pName;
prodSKU = 0;
prodUnits = 0;
prodPrice = 0;
}
public Proddata()
{
prodName = "";
prodSKU = 0;
prodUnits = 0;
prodPrice = 0;
}
//get SKU
public int getProdSKU()
{
return prodSKU;
}
//set SKU
public void setProdSKU(int prodSKU) {
this.prodSKU = prodSKU;
}
//get produce name
public String getProdName() {
return prodName;
}
//set produce name
public void setProdName(String prodName) {
this.prodName = prodName;
}
//get number of units sold
public int getProdUnits() {
return prodUnits;
}
// set units sold
public void setProdUnits(int prodUnits) {
this.prodUnits = prodUnits;
}
//get produce price
public double getProdPrice() {
return prodPrice;
}
//set produce price
public void setProdPrice(double prodPrice) {
this.prodPrice = prodPrice;
}
// get total sales
public double getTotalSales(){
return prodUnits * prodPrice;
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package farmersmarket3;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
/**
*
* @author Omar "RamO" Muthana
*/
public class SaveFarm extends JDialog {
private static final long serialVersionUID = 1L;
JButton jbnOK = new JButton("Save");
JButton jbnCancel = new JButton("Cancel");
public Boolean bOKPressed = false;
public SaveFarm(Frame owner, boolean modal) {
super(owner, modal);
init();
}
private void init() {
this.setTitle("Save Salesman Data");
this.setLayout(new GridLayout(1, 2));
jbnOK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
bOKPressed = true;
dispose();
}
});
jbnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
dispose();
}
});
this.add(jbnOK);
this.add(jbnCancel);
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package farmersmarket3;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
/**
*
* @author Omar "RamO" Muthana
*/
public class SaveFarm2 extends JDialog {
private static final long serialVersionUID = 1L;
JButton jbnOK = new JButton("Save");
JButton jbnCancel = new JButton("Cancel");
public Boolean bOKPressed = false;
public SaveFarm2(Frame owner, boolean modal) {
super(owner, modal);
init();
}
private void init() {
this.setTitle("Save Salesman Data");
this.setLayout(new GridLayout(1, 2));
jbnOK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
bOKPressed = true;
dispose();
}
});
jbnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
dispose();
}
});
this.add(jbnOK);
this.add(jbnCancel);
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package farmersmarket3;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JTextField;
/**
*
* @author Omar "RamO" Muthana
*/
public class SearchFarm extends JDialog {
private static final long serialVersionUID = 1L;
JLabel jlblName = new JLabel("Name");
JTextField jtxtName = new JTextField();
// String[] newDVD = new String[4];
JButton jbnOK = new JButton("Search");
JButton jbnCancel = new JButton("Cancel");
public Boolean bOKPressed = false;
public SearchFarm(Frame owner, boolean modal) {
super(owner, modal);
init();
}
private void init() {
this.setTitle("Search for a Salesman");
this.setLayout(new GridLayout(2, 2));
this.add(jlblName);
this.add(jtxtName);
jbnOK.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
bOKPressed = true;
dispose();
}
});
jbnCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
dispose();
}
});
this.add(jbnOK);
this.add(jbnCancel);
}
public String getSalesManName() {
return jtxtName.getText();
}
}
HERE are the Directions of the assignment
Modify the Farmers Market Program to include an Add button, a Delete button, and a Modify button on the GUI. These buttons should allow the user to perform the corresponding actions on the product name, the SKU number, and the price of each case. An item added to your purchases should have SKU number one more than the previous SKU number.
Add a Save button to the GUI that saves the purchases to a C:\data\purchases.dat file.
Use exception handling to create the directory and file if necessary.
Add a Search button to the GUI that allows the user to search for a fruit or vegetable product. If the product is not found, the GUI should display an appropriate message. If the product is found, the GUI should display that product’s name, SKU number, and the price per case in the GUI.
Here Is the Error Message I get on running and click buttons…
ADD Button run: DOES COME UP
Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not yet implemented
at farmersmarket3.AddNewProduce.newSalesData(AddNewProduce.java:30)
at farmersmarket3.FarmersMarket3.actionPerformed(FarmersMarket3.java:179)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.window.dispatchEventImpl(window.java:2713)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:680)
at java.awt.EventQueue$4.run(EventQueue.java:678)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Delete button NOTHING BUT ERROR MESSAGE
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 4
at farmersmarket3.NewProduce.getStringArray(NewProduce.java:100)
at farmersmarket3.DeleteProduce.populateTextFields(DeleteProduce.java:78)
at farmersmarket3.DeleteProduce.init(DeleteProduce.java:51)
at farmersmarket3.DeleteProduce.<init>(DeleteProduce.java:38)
at farmersmarket3.FarmersMarket3.actionPerformed(FarmersMarket3.java:185)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.window.dispatchEventImpl(window.java:2713)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:680)
at java.awt.EventQueue$4.run(EventQueue.java:678)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Modify Button DOES NOTHING BUT ERROR
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 4
at farmersmarket3.NewProduce.getStringArray(NewProduce.java:100)
at farmersmarket3.ModifyFarmer.populateTextFields(ModifyFarmer.java:86)
at farmersmarket3.ModifyFarmer.init(ModifyFarmer.java:58)
at farmersmarket3.ModifyFarmer.<init>(ModifyFarmer.java:43)
at farmersmarket3.FarmersMarket3.actionPerformed(FarmersMarket3.java:197)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.window.dispatchEventImpl(window.java:2713)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:680)
at java.awt.EventQueue$4.run(EventQueue.java:678)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
SEARCH Button COMES UP ALLOWS INPUT THEN NOTHING
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: farmersmarket3.SearchFarm.<error>
at farmersmarket3.FarmersMarket3.actionPerformed(FarmersMarket3.java:211)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.window.dispatchEventImpl(window.java:2713)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:680)
at java.awt.EventQueue$4.run(EventQueue.java:678)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
SAVE BUTTON COMES UP THEN
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: farmersmarket3.NewProduce.saveSalesData
at farmersmarket3.FarmersMarket3.actionPerformed(FarmersMarket3.java:220)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.window.dispatchEventImpl(window.java:2713)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:680)
at java.awt.EventQueue$4.run(EventQueue.java:678)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Please Help me figure out how to correctly link the actions to the buttons...
This post has been edited by modi123_1: 25 May 2012 - 11:20 AM
Reason for edit:: highlight the lines THEN click the code tags

New Topic/Question
Reply




MultiQuote







|