inventory program part 4 - GUI

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 3642 Views - Last Post: 09 December 2009 - 02:16 PM Rate Topic: -----

#1 atherton23   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 18-November 09

inventory program part 4 - GUI

Post icon  Posted 06 December 2009 - 06:46 PM

I have two issues I am asking for help on. One being I have errors in the main class, they are marked. I ahve racked my brain and cant seem to clear them I am sure it is a rookie mistake. Please take a look, again they are marked. Two, at the end of my program I have a setter that is placing my CD info into my GUI, do I need a group like I have for every CD or just one for all?
package inventoryprogram;
	import java.awt.*;
	import javax.swing.*;

/**
 *
 * @author Atherton
 */
public class Main {

	/**
	 * @param args the command line arguments
	 */

	public static void main(String[] args) {
		// TODO code application logic here


		String cdName;
		double cdItemnumber;
		double cdStock = 0;
		double cdPrice = 0;
		String cdGenre;
		double ReStockingFee = 0;

		CD[] CD = new CD[100];

			CD bush = new CD("Bush", 1, 10, 10.99, "Rock", 0.56);
			System.out.println();
			CD acdc = new CD("ACDC", 2, 12, 12.99, "Rock", 0.65);
			System.out.println();
			CD creed = new CD("Creed", 3, 4, 9.99, "Rock", 0.50);
			System.out.println();
			CD korn = new CD("Korn", 4, 7, 14.99, "Rock", 0.75);
			System.out.println();

		acdc.showInventory();
			System.out.println();

		bush.showInventory();
			System.out.println();

		creed.showInventory();
			System.out.println();

		korn.showInventory();
			System.out.println();

		for (int i = 0; i<args.length; i++)
			System.out.println(args[i] + ",");

		double array[] = {109.90, 155.88, 39.96, 104.93};
		double total = 0;

		for (int counter = 0; counter < array.length; counter++)
			total += array[counter];

		System.out.println();
		System.out.printf("Total inventory value is: $%.2f\n", total);
		System.out.println("There will be a .5% Restocking Fee with all orders returned.");
		System.out.println();

		InventoryGUI gui = new InventoryGUI();

		gui.setItemNumber(acdc.getItemNumber());
 *** gui.setItemName(acdc.getItemName()); **** ERROR*** these errors repeat them selves for each CD
	   the error say - (itemName, musicGenre, RestockingFee, value, and totalValue cant be found - yet they are in the program
		gui.setPrice(acdc.getPrice());
 ***  gui.setMusicGenre(acdc.getMusicGenre());
		gui.setUnitsinstock(acdc.getStockNumbers());
 ***  gui.setRestockingFee(acdc.getRestockingFee()); ****ERROR****
  *** gui.setValue(acdc.getValue()); *****ERROR****
  *** gui.setTotalValue(acdc.getTotalValue()); ******ERROR******

		gui.setItemNumber(bush.getItemNumber());
		gui.setItemName(bush.getItemName());
		gui.setPrice(bush.getPrice());
		gui.setMusicGenre(bush.getMusicGenre());
		gui.setUnitsinstock(bush.getStockNumbers());
		gui.setRestockingFee(bush.getRestockingFee());
		gui.setValue(bush.getValue());
		gui.setTotalValue(bush.getTotalValue());

		gui.setItemNumber(creed.getItemNumber());
		gui.setItemName(creed.getItemName());
		gui.setPrice(creed.getPrice());
		gui.setMusicGenre(creed.getMusicGenre());
		gui.setUnitsinstock(creed.getStockNumbers());
		gui.setRestockingFee(creed.getRestockingFee());
		gui.setValue(creed.getValue());
		gui.setTotalValue(creed.getTotalValue());

		gui.setItemNumber(korn.getItemNumber());
		gui.setItemName(korn.getItemName());
		gui.setPrice(korn.getPrice());
		gui.setMusicGenre(korn.getMusicGenre());
		gui.setUnitsinstock(korn.getStockNumbers());
		gui.setRestockingFee(korn.getRestockingFee());
		gui.setValue(korn.getValue());
		gui.setTotalValue(korn.getTotalValue());


		} // end public main

	}

	class CD
	{
	private String cdName;
	private double itemNumber;
	private double unitsInStock;
	private double unitPrice;
	private String cdGenre;
	private double ReStockingFee;

	public CD(String itemName, double cdNumber, double unitsInStock, double unitPrice, String Genre, double StockingFee)
	{
	 this.cdName = itemName;
	 this.itemNumber = cdNumber;
	 this.unitsInStock = unitsInStock;
	 this.unitPrice = unitPrice;
	 this.cdGenre = Genre;
	 this.ReStockingFee = StockingFee;
	}

	 public String getItemName()
	 {
		  return this.cdName;
	 }

	 public double getItemNumber()
	 {
		  return this.itemNumber;
	 }

	 public double getStockNumbers()
	 {
		  return this.unitsInStock;
	 }

	 public double getPrice()
	 {
		  return this.unitPrice;
	 }

	 public String getGenre()
	 {
		 return this.cdGenre;
	 }

	 public double computeStockingFee()
	 {
		 return this.ReStockingFee * unitPrice;
	 }

	 public double computeInventoryValue()
	 {
		  return this.unitsInStock * unitPrice;
	 }


	public void showInventory()
	{
		System.out.println("CD item number: " +itemNumber);
		System.out.println("CD Name: " +cdName);
		System.out.println("Number of Units: "+unitsInStock);
		System.out.println("Price: "+unitPrice);
		System.out.println("Genre: " +cdGenre);
		System.out.println("Restocking Fee per CD: " +ReStockingFee);
		System.out.printf("Inventory Value of "+cdName+" is = $%.2f\n", computeInventoryValue());

	}

 }

class genre extends CD
	{
		
		genre(String itemName, double cdNumber, double unitsInStock, double unitPrice, String cdGenre, double ReStockingFee )
		{
			super(itemName, cdNumber, unitsInStock, unitPrice, cdGenre, ReStockingFee);
			cdGenre = genre;
		}
		
		private String cdGenre;
		String genre;

		public void setGenre ( String genre)
		{
			this.cdGenre = genre;
		}

		public String getgenre()
		{
			return cdGenre;
		}

		public double getValue()
		{
			return super.computeInventoryValue() * 1.05;
		}

		public double getReStockingFee()
		{
			return super.computeInventoryValue() * .05;
		}

	@Override
		public String toString()
		{
			String formatString = "Genre:  %s";
			formatString += "Restocking Fee:  $%.2f";
			formatString = String.format(formatString, cdGenre, super.computeInventoryValue() * 0.05);
			return( formatString + super.toString() );
		}

		public void showInvwentory()
		{
			super.showInventory();
			System.out.println( toString());
			System.out.println( "Genre: "+cdGenre);
			System.out.printf("\nInventory value of "+cdGenre+" is = $%.2f\n", getReStockingFee() );
		}

	  }

class InventoryGUI extends JFrame
	{

		private final JLabel itemNumberLabel = new JLabel("  Item Number:");
		private JTextField itemNumberText;

		private final JLabel itemNameLabel = new JLabel("  CD Name:");
		private JTextField itemNameText;

		private final JLabel priceLabel = new JLabel("  CD Price:");
		private JTextField priceText;

		private final JLabel musicGenreLabel = new JLabel("  Genre:");
		private JTextField musicGenreText;

		private final JLabel unitsinstockLabel = new JLabel("  Stock:");
		private JTextField unitsinstockText;

		private final JLabel valueLabel = new JLabel("  Value:");
		private JTextField valueText;

		private final JLabel restockingFeeLabel = new JLabel("  Restocking Fee:");
		private JTextField restockingFeeText;

		private final JLabel totalValueLabel = new JLabel("  Inventory Total Value:");
		private JTextField totalValueText;

		private JPanel centerPanel;


	InventoryGUI()
		{

		super("CD Inventory List");
		final Dimension dim = new Dimension(150, 40);
		final FlowLayout flo = new FlowLayout(FlowLayout.LEFT);
		JPanel jp;


		centerPanel = new JPanel();
		centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS));

		jp = new JPanel(flo);
		itemNumberLabel.setPreferredSize(dim);
		jp.add(itemNumberLabel);
		itemNumberText = new JTextField(3);
		itemNumberText.setEditable(false);
		jp.add(itemNumberText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		itemNameLabel.setPreferredSize(dim);
		jp.add(itemNameLabel);
		itemNameText = new JTextField(17);
		itemNameText.setEditable(false);
		jp.add(itemNameText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		priceLabel.setPreferredSize(dim);
		jp.add(priceLabel);
		priceText = new JTextField(17);
		priceText.setEditable(false);
		jp.add(priceText);
		centerPanel.add(jp);

		jp = new JPanel (flo);
		musicGenreLabel.setPreferredSize(dim);
		jp.add(musicGenreLabel);
		musicGenreText = new JTextField(17);
		musicGenreText.setEditable(false);
		jp.add(musicGenreText);
		centerPanel.add(jp);
		
		jp = new JPanel(flo);
		unitsinstockLabel.setPreferredSize(dim);
		jp.add(unitsinstockLabel);
		unitsinstockText = new JTextField(5);
		unitsinstockText.setEditable(false);
		jp.add(unitsinstockText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		restockingFeeLabel.setPreferredSize(dim);
		jp.add(restockingFeeLabel);
		restockingFeeText = new JTextField(17);
		restockingFeeText.setEditable(false);
		jp.add(restockingFeeText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		valueLabel.setPreferredSize(dim);
		jp.add(valueLabel);
		valueText = new JTextField(17);
		valueText.setEditable(false);
		jp.add(valueText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		totalValueLabel.setPreferredSize(dim);
		jp.add(totalValueLabel);
		totalValueText = new JTextField(17);
		totalValueText.setEditable(false);
		jp.add(totalValueText);
		centerPanel.add(jp);

		setContentPane(centerPanel);

		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setSize(360, 300);
		setResizable(false);
		setLocationRelativeTo(null);
		setVisible(true);

		}


	public void setItemNumber(double d)
		{
			this.itemNumberText.setText(Double.toString(d));
		}
	
	public void setItemName(double d)
		{
			this.itemNameText.setText(Double.toString(d));
		}
	public void setPrice(double d)
		{
			this.priceText.setText(Double.toString(d));
		}
	public void setMusicGenre(double d)
		{
			this.musicGenreText.setText(Double.toString(d));
		}
	public void setUnitsinstock(double d)
		{
			this.unitsinstockText.setText(Double.toString(d));
		}
	public void setRestockingFee(double d)
		{
			this.restockingFeeText.setText(Double.toString(d));
		}
	public void setValue(double d)
		{
			this.valueText.setText(Double.toString(d));
		}
	public void setTotalValue(double d)
		{
			this.totalValueText.setText(Double.toString(d));
		}
	

	}




Is This A Good Question/Topic? 0
  • +

Replies To: inventory program part 4 - GUI

#2 Dogstopper   User is offline

  • The Ninjaducky
  • member icon

Reputation: 2965
  • View blog
  • Posts: 11,222
  • Joined: 15-July 08

Re: inventory program part 4 - GUI

Posted 06 December 2009 - 06:57 PM

Maybe you meant this:
public void setItemName(String d)
		{
			this.itemNameText.setText(d);
		}



instead of this:
public void setItemName(double d)
		{
			this.itemNameText.setText(Double.toString(d));
		}



also:
		 gui.setMusicGenre(acdc.getMusicGenre()); // Add this get method
		gui.setUnitsinstock(acdc.getStockNumbers());
		gui.setRestockingFee(acdc.getRestockingFee()); // Add this get method
		gui.setValue(acdc.getValue());// Add this get method
		gui.setTotalValue(acdc.getTotalValue());// Add this get method


Was This Post Helpful? 0
  • +
  • -

#3 atherton23   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 18-November 09

Re: inventory program part 4 - GUI

Posted 06 December 2009 - 07:07 PM

First, Thanks for your help. I understadn that I had it labeled double and it needed to be String but I could sort it out. I am still not understanding your second suggestion? What do you mean by add this get method?

Your help is appreciated.
Was This Post Helpful? 0
  • +
  • -

#4 Dogstopper   User is offline

  • The Ninjaducky
  • member icon

Reputation: 2965
  • View blog
  • Posts: 11,222
  • Joined: 15-July 08

Re: inventory program part 4 - GUI

Posted 06 December 2009 - 07:13 PM

Those methods have not been written!!! If they aren't there, how can you access them? EDIT: they have been written, but they are in the wrong class. The way that you have it, they are in the genre class, which subclasses CD. However, you create only instances of the superclass, CD, whilst not mentioning the genre class at all.

This post has been edited by Dogstopper: 06 December 2009 - 07:19 PM

Was This Post Helpful? 0
  • +
  • -

#5 atherton23   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 18-November 09

Re: inventory program part 4 - GUI

Posted 06 December 2009 - 07:21 PM

I apologize for being stupid but I thought I had those methods. musicGenre, RestockingFee, and so on.
Was This Post Helpful? 0
  • +
  • -

#6 Dogstopper   User is offline

  • The Ninjaducky
  • member icon

Reputation: 2965
  • View blog
  • Posts: 11,222
  • Joined: 15-July 08

Re: inventory program part 4 - GUI

Posted 06 December 2009 - 07:26 PM

public String getgenre()
		{
			return cdGenre;
		}

		public double getValue()
		{
			return super.computeInventoryValue() * 1.05;
		}

		public double getReStockingFee()
		{
			return super.computeInventoryValue() * .05;
		}


Your methods have different capitalization than what you are trying to call as well. you call getGenre() and the the same thing with the other two methods here. Make sure the capitalization is right!

Also, in order to access thos methods, they must be of that method's class, in this case, genre.
CD[] CD = new genre[100];

			genre bush = new genre("Bush", 1, 10, 10.99, "Rock", 0.56);
			System.out.println();
			genre acdc = new genre("ACDC", 2, 12, 12.99, "Rock", 0.65);
			System.out.println();
			genre creed = new genre("Creed", 3, 4, 9.99, "Rock", 0.50);
			System.out.println();
			genre korn = new genre("Korn", 4, 7, 14.99, "Rock", 0.75);
			System.out.println();



EDIT: You're not stupid, you just need some explanation like everyone at some point.

This post has been edited by Dogstopper: 06 December 2009 - 07:28 PM

Was This Post Helpful? 0
  • +
  • -

#7 atherton23   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 18-November 09

Re: inventory program part 4 - GUI

Posted 06 December 2009 - 08:17 PM

Thanks, you have helped me a great deal. I now have other problems. If you dont mind taking a look. I believe these will be minor issues. My program compiles and runs but I don't see all of my CDs inventory only my last CD (korn). Why is this? Also my program keeps running as if it is waiting for an input or something. Any suggestins?
Was This Post Helpful? 0
  • +
  • -

#8 atherton23   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 18-November 09

Re: inventory program part 4 - GUI

Post icon  Posted 06 December 2009 - 08:40 PM

I am almost done, thanks to the help of many of you. Thanks you again. I have no erros but still two questions.
1. When I run my prgram my window only shows the last CD (korn) not all four CD's?
2. My program keeps running as if it is waiting for an input or response?
Any Suggestions?
package inventoryprogram;
	import java.awt.*;
	import javax.swing.*;

/**
 *
 * @author Atherton
 */
public class Main {

	/**
	 * @param args the command line arguments
	 */

	public static void main(String[] args) {
		// TODO code application logic here


		CD[] CD = new CD[100];

			CD bush = new CD("Bush", 1, 10, 10.99, "Rock", 0.56);
			System.out.println();
			CD acdc = new CD("ACDC", 2, 12, 12.99, "Rock", 0.65);
			System.out.println();
			CD creed = new CD("Creed", 3, 4, 9.99, "Rock", 0.50);
			System.out.println();
			CD korn = new CD("Korn", 4, 7, 14.99, "Rock", 0.75);
			System.out.println();

		acdc.showInventory();
			System.out.println();

		bush.showInventory();
			System.out.println();

		creed.showInventory();
			System.out.println();

		korn.showInventory();
			System.out.println();

		for (int i = 0; i<args.length; i++)
			System.out.println(args[i] + ",");

		double array[] = {109.90, 155.88, 39.96, 104.93};
		double total = 0;

		for (int counter = 0; counter < array.length; counter++)
			total += array[counter];

		System.out.println();
		System.out.printf("Total inventory value is: $%.2f\n", total);
		System.out.println("There will be a .5% Restocking Fee with all orders returned.");
		System.out.println();

		InventoryGUI gui = new InventoryGUI();

		gui.setItemNumber(acdc.getItemNumber());
		gui.setItemName(acdc.getItemName());
		gui.setPrice(acdc.getPrice());
		gui.setGenre(acdc.getGenre());
		gui.setUnitsinstock(acdc.getStockNumbers());
		gui.setComputeStockingFee(acdc.computeStockingFee());
		gui.setComputeInventoryValue(acdc.computeInventoryValue());

		gui.setItemNumber(bush.getItemNumber());
		gui.setItemName(bush.getItemName());
		gui.setPrice(bush.getPrice());
		gui.setGenre(bush.getGenre());
		gui.setUnitsinstock(bush.getStockNumbers());
		gui.setComputeStockingFee(bush.computeStockingFee());
		gui.setComputeInventoryValue(bush.computeInventoryValue());

		gui.setItemNumber(creed.getItemNumber());
		gui.setItemName(creed.getItemName());
		gui.setPrice(creed.getPrice());
		gui.setGenre(creed.getGenre());
		gui.setUnitsinstock(creed.getStockNumbers());
		gui.setComputeStockingFee(creed.computeStockingFee());
		gui.setComputeInventoryValue(creed.computeInventoryValue());

		gui.setItemNumber(korn.getItemNumber());
		gui.setItemName(korn.getItemName());
		gui.setPrice(korn.getPrice());
		gui.setGenre(korn.getGenre());
		gui.setUnitsinstock(korn.getStockNumbers());
		gui.setComputeStockingFee(korn.computeStockingFee());
		gui.setComputeInventoryValue(korn.computeInventoryValue());


		} // end public main

	}

	class CD
	{
	private String cdName;
	private double itemNumber;
	private double unitsInStock;
	private double unitPrice;
	private String cdGenre;
	private double ReStockingFee;

	public CD(String itemName, double cdNumber, double unitsInStock, double unitPrice, String Genre, double StockingFee)
	{
	 this.cdName = itemName;
	 this.itemNumber = cdNumber;
	 this.unitsInStock = unitsInStock;
	 this.unitPrice = unitPrice;
	 this.cdGenre = Genre;
	 this.ReStockingFee = StockingFee;
	}

	 public String getItemName()
	 {
		  return this.cdName;
	 }

	 public double getItemNumber()
	 {
		  return this.itemNumber;
	 }

	 public double getStockNumbers()
	 {
		  return this.unitsInStock;
	 }

	 public double getPrice()
	 {
		  return this.unitPrice;
	 }

	 public String getGenre()
	 {
		 return this.cdGenre;
	 }

	 public double computeStockingFee()
	 {
		 return this.ReStockingFee * unitPrice;
	 }

	 public double computeInventoryValue()
	 {
		  return this.unitsInStock * unitPrice;
	 }


	public void showInventory()
	{
		System.out.println("CD item number: " +itemNumber);
		System.out.println("CD Name: " +cdName);
		System.out.println("Number of Units: "+unitsInStock);
		System.out.println("Price: "+unitPrice);
		System.out.println("Genre: " +cdGenre);
		System.out.println("Restocking Fee per CD: " +ReStockingFee);
		System.out.printf("Inventory Value of "+cdName+" is = $%.2f\n", computeInventoryValue());

	}

 }

class genre extends CD
	{
		
		genre(String itemName, double cdNumber, double unitsInStock, double unitPrice, String cdGenre, double ReStockingFee )
		{
			super(itemName, cdNumber, unitsInStock, unitPrice, cdGenre, ReStockingFee);
			cdGenre = genre;
		}
		
		private String cdGenre;
		String genre;

		public void setGenre ( String genre)
		{
			this.cdGenre = genre;
		}

		public String getgenre()
		{
			return cdGenre;
		}

		public double getValue()
		{
			return super.computeInventoryValue() * 1.05;
		}

		public double getReStockingFee()
		{
			return super.computeInventoryValue() * .05;
		}

	@Override
		public String toString()
		{
			String formatString = "Genre:  %s";
			formatString += "Restocking Fee:  $%.2f";
			formatString = String.format(formatString, cdGenre, super.computeInventoryValue() * 0.05);
			return( formatString + super.toString() );
		}

		public void showInvwentory()
		{
			super.showInventory();
			System.out.println( toString());
			System.out.println( "Genre: "+cdGenre);
			System.out.printf("\nInventory value of "+cdGenre+" is = $%.2f\n", getReStockingFee() );
		}

	  }

class InventoryGUI extends JFrame
	{

		private final JLabel itemNumberLabel = new JLabel("  Item Number:");
		private JTextField itemNumberText;

		private final JLabel itemNameLabel = new JLabel("  CD Name:");
		private JTextField itemNameText;

		private final JLabel priceLabel = new JLabel("  CD Price:");
		private JTextField priceText;

		private final JLabel genreLabel = new JLabel("  Genre:");
		private JTextField genreText;

		private final JLabel unitsinstockLabel = new JLabel("  Stock:");
		private JTextField unitsinstockText;

		private final JLabel computeStockingFeeLabel = new JLabel("  Restocking Fee:");
		private JTextField computeStockingFeeText;

		private final JLabel computeInventoryValueLabel = new JLabel("  Inventory Total Value:");
		private JTextField computeInventoryValueText;

		private JPanel centerPanel;


	InventoryGUI()
		{

		super("CD Inventory List");
		final Dimension dim = new Dimension(150, 40);
		final FlowLayout flo = new FlowLayout(FlowLayout.LEFT);
		JPanel jp;


		centerPanel = new JPanel();
		centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS));

		jp = new JPanel(flo);
		itemNumberLabel.setPreferredSize(dim);
		jp.add(itemNumberLabel);
		itemNumberText = new JTextField(3);
		itemNumberText.setEditable(false);
		jp.add(itemNumberText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		itemNameLabel.setPreferredSize(dim);
		jp.add(itemNameLabel);
		itemNameText = new JTextField(17);
		itemNameText.setEditable(false);
		jp.add(itemNameText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		priceLabel.setPreferredSize(dim);
		jp.add(priceLabel);
		priceText = new JTextField(17);
		priceText.setEditable(false);
		jp.add(priceText);
		centerPanel.add(jp);

		jp = new JPanel (flo);
		genreLabel.setPreferredSize(dim);
		jp.add(genreLabel);
		genreText = new JTextField(17);
		genreText.setEditable(false);
		jp.add(genreText);
		centerPanel.add(jp);
		
		jp = new JPanel(flo);
		unitsinstockLabel.setPreferredSize(dim);
		jp.add(unitsinstockLabel);
		unitsinstockText = new JTextField(5);
		unitsinstockText.setEditable(false);
		jp.add(unitsinstockText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		computeStockingFeeLabel.setPreferredSize(dim);
		jp.add(computeStockingFeeLabel);
		computeStockingFeeText = new JTextField(17);
		computeStockingFeeText.setEditable(false);
		jp.add(computeStockingFeeText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		computeInventoryValueLabel.setPreferredSize(dim);
		jp.add(computeInventoryValueLabel);
		computeInventoryValueText = new JTextField(17);
		computeInventoryValueText.setEditable(false);
		jp.add(computeInventoryValueText);
		centerPanel.add(jp);

		setContentPane(centerPanel);

		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setSize(400, 400);
		setResizable(false);
		setLocationRelativeTo(null);
		setVisible(true);

		}


	public void setItemNumber(double d)
		{
			this.itemNumberText.setText(Double.toString(d));
		}
	
	public void setItemName(String d)
		{
			this.itemNameText.setText(d);
		}
	public void setPrice(double d)
		{
			this.priceText.setText(Double.toString(d));
		}
	public void setGenre(String d)
		{
			this.genreText.setText(d);
		}
	public void setUnitsinstock(double d)
		{
			this.unitsinstockText.setText(Double.toString(d));
		}
	public void setComputeStockingFee(double d)
		{
			this.computeStockingFeeText.setText(Double.toString(d));
		}

	public void setComputeInventoryValue(double d)
		{
			this.computeInventoryValueText.setText(Double.toString(d));
		}
	

	}



Was This Post Helpful? 0
  • +
  • -

#9 Dogstopper   User is offline

  • The Ninjaducky
  • member icon

Reputation: 2965
  • View blog
  • Posts: 11,222
  • Joined: 15-July 08

Re: inventory program part 4 - GUI

Posted 06 December 2009 - 09:08 PM

Can you please post your most current code so that I can take a look?
Was This Post Helpful? 0
  • +
  • -

#10 atherton23   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 18-November 09

Re: inventory program part 4 - GUI

Posted 06 December 2009 - 09:11 PM

Most current Code!
package inventoryprogram;
	import java.awt.*;
	import javax.swing.*;

/**
 *
 * @author Atherton
 */
public class Main {

	/**
	 * @param args the command line arguments
	 */

	public static void main(String[] args) {
		// TODO code application logic here


		CD[] CD = new CD[100];

			CD bush = new CD("Bush", 1, 10, 10.99, "Rock", 0.56);
			System.out.println();
			CD acdc = new CD("ACDC", 2, 12, 12.99, "Rock", 0.65);
			System.out.println();
			CD creed = new CD("Creed", 3, 4, 9.99, "Rock", 0.50);
			System.out.println();
			CD korn = new CD("Korn", 4, 7, 14.99, "Rock", 0.75);
			System.out.println();

		acdc.showInventory();
			System.out.println();

		bush.showInventory();
			System.out.println();

		creed.showInventory();
			System.out.println();

		korn.showInventory();
			System.out.println();

		for (int i = 0; i<args.length; i++)
			System.out.println(args[i] + ",");

		double array[] = {109.90, 155.88, 39.96, 104.93};
		double total = 0;

		for (int counter = 0; counter < array.length; counter++)
			total += array[counter];

		System.out.println();
		System.out.printf("Total inventory value is: $%.2f\n", total);
		System.out.println("There will be a .5% Restocking Fee with all orders returned.");
		System.out.println();

		InventoryGUI gui = new InventoryGUI();

		gui.setItemNumber(acdc.getItemNumber());
		gui.setItemName(acdc.getItemName());
		gui.setPrice(acdc.getPrice());
		gui.setGenre(acdc.getGenre());
		gui.setUnitsinstock(acdc.getStockNumbers());
		gui.setComputeStockingFee(acdc.computeStockingFee());
		gui.setComputeInventoryValue(acdc.computeInventoryValue());

		gui.setItemNumber(bush.getItemNumber());
		gui.setItemName(bush.getItemName());
		gui.setPrice(bush.getPrice());
		gui.setGenre(bush.getGenre());
		gui.setUnitsinstock(bush.getStockNumbers());
		gui.setComputeStockingFee(bush.computeStockingFee());
		gui.setComputeInventoryValue(bush.computeInventoryValue());

		gui.setItemNumber(creed.getItemNumber());
		gui.setItemName(creed.getItemName());
		gui.setPrice(creed.getPrice());
		gui.setGenre(creed.getGenre());
		gui.setUnitsinstock(creed.getStockNumbers());
		gui.setComputeStockingFee(creed.computeStockingFee());
		gui.setComputeInventoryValue(creed.computeInventoryValue());

		gui.setItemNumber(korn.getItemNumber());
		gui.setItemName(korn.getItemName());
		gui.setPrice(korn.getPrice());
		gui.setGenre(korn.getGenre());
		gui.setUnitsinstock(korn.getStockNumbers());
		gui.setComputeStockingFee(korn.computeStockingFee());
		gui.setComputeInventoryValue(korn.computeInventoryValue());


		} // end public main

	}

	class CD
	{
	private String cdName;
	private double itemNumber;
	private double unitsInStock;
	private double unitPrice;
	private String cdGenre;
	private double ReStockingFee;

	public CD(String itemName, double cdNumber, double unitsInStock, double unitPrice, String Genre, double StockingFee)
	{
	 this.cdName = itemName;
	 this.itemNumber = cdNumber;
	 this.unitsInStock = unitsInStock;
	 this.unitPrice = unitPrice;
	 this.cdGenre = Genre;
	 this.ReStockingFee = StockingFee;
	}

	 public String getItemName()
	 {
		  return this.cdName;
	 }

	 public double getItemNumber()
	 {
		  return this.itemNumber;
	 }

	 public double getStockNumbers()
	 {
		  return this.unitsInStock;
	 }

	 public double getPrice()
	 {
		  return this.unitPrice;
	 }

	 public String getGenre()
	 {
		 return this.cdGenre;
	 }

	 public double computeStockingFee()
	 {
		 return this.ReStockingFee * unitPrice;
	 }

	 public double computeInventoryValue()
	 {
		  return this.unitsInStock * unitPrice;
	 }


	public void showInventory()
	{
		System.out.println("CD item number: " +itemNumber);
		System.out.println("CD Name: " +cdName);
		System.out.println("Number of Units: "+unitsInStock);
		System.out.println("Price: "+unitPrice);
		System.out.println("Genre: " +cdGenre);
		System.out.println("Restocking Fee per CD: " +ReStockingFee);
		System.out.printf("Inventory Value of "+cdName+" is = $%.2f\n", computeInventoryValue());

	}

 }

class genre extends CD
	{
		
		genre(String itemName, double cdNumber, double unitsInStock, double unitPrice, String cdGenre, double ReStockingFee )
		{
			super(itemName, cdNumber, unitsInStock, unitPrice, cdGenre, ReStockingFee);
			cdGenre = genre;
		}
		
		private String cdGenre;
		String genre;

		public void setGenre ( String genre)
		{
			this.cdGenre = genre;
		}

		public String getgenre()
		{
			return cdGenre;
		}

		public double getValue()
		{
			return super.computeInventoryValue() * 1.05;
		}

		public double getReStockingFee()
		{
			return super.computeInventoryValue() * .05;
		}

	@Override
		public String toString()
		{
			String formatString = "Genre:  %s";
			formatString += "Restocking Fee:  $%.2f";
			formatString = String.format(formatString, cdGenre, super.computeInventoryValue() * 0.05);
			return( formatString + super.toString() );
		}

		public void showInvwentory()
		{
			super.showInventory();
			System.out.println( toString());
			System.out.println( "Genre: "+cdGenre);
			System.out.printf("\nInventory value of "+cdGenre+" is = $%.2f\n", getReStockingFee() );
		}

	  }

class InventoryGUI extends JFrame
	{

		private final JLabel itemNumberLabel = new JLabel("  Item Number:");
		private JTextField itemNumberText;

		private final JLabel itemNameLabel = new JLabel("  CD Name:");
		private JTextField itemNameText;

		private final JLabel priceLabel = new JLabel("  CD Price:");
		private JTextField priceText;

		private final JLabel genreLabel = new JLabel("  Genre:");
		private JTextField genreText;

		private final JLabel unitsinstockLabel = new JLabel("  Stock:");
		private JTextField unitsinstockText;

		private final JLabel computeStockingFeeLabel = new JLabel("  Restocking Fee:");
		private JTextField computeStockingFeeText;

		private final JLabel computeInventoryValueLabel = new JLabel("  Inventory Total Value:");
		private JTextField computeInventoryValueText;

		private JPanel centerPanel;


	InventoryGUI()
		{

		super("CD Inventory List");
		final Dimension dim = new Dimension(150, 40);
		final FlowLayout flo = new FlowLayout(FlowLayout.LEFT);
		JPanel jp;


		centerPanel = new JPanel();
		centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS));

		jp = new JPanel(flo);
		itemNumberLabel.setPreferredSize(dim);
		jp.add(itemNumberLabel);
		itemNumberText = new JTextField(3);
		itemNumberText.setEditable(false);
		jp.add(itemNumberText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		itemNameLabel.setPreferredSize(dim);
		jp.add(itemNameLabel);
		itemNameText = new JTextField(17);
		itemNameText.setEditable(false);
		jp.add(itemNameText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		priceLabel.setPreferredSize(dim);
		jp.add(priceLabel);
		priceText = new JTextField(17);
		priceText.setEditable(false);
		jp.add(priceText);
		centerPanel.add(jp);

		jp = new JPanel (flo);
		genreLabel.setPreferredSize(dim);
		jp.add(genreLabel);
		genreText = new JTextField(17);
		genreText.setEditable(false);
		jp.add(genreText);
		centerPanel.add(jp);
		
		jp = new JPanel(flo);
		unitsinstockLabel.setPreferredSize(dim);
		jp.add(unitsinstockLabel);
		unitsinstockText = new JTextField(5);
		unitsinstockText.setEditable(false);
		jp.add(unitsinstockText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		computeStockingFeeLabel.setPreferredSize(dim);
		jp.add(computeStockingFeeLabel);
		computeStockingFeeText = new JTextField(17);
		computeStockingFeeText.setEditable(false);
		jp.add(computeStockingFeeText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		computeInventoryValueLabel.setPreferredSize(dim);
		jp.add(computeInventoryValueLabel);
		computeInventoryValueText = new JTextField(17);
		computeInventoryValueText.setEditable(false);
		jp.add(computeInventoryValueText);
		centerPanel.add(jp);

		setContentPane(centerPanel);

		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setSize(400, 400);
		setResizable(false);
		setLocationRelativeTo(null);
		setVisible(true);

		}


	public void setItemNumber(double d)
		{
			this.itemNumberText.setText(Double.toString(d));
		}
	
	public void setItemName(String d)
		{
			this.itemNameText.setText(d);
		}
	public void setPrice(double d)
		{
			this.priceText.setText(Double.toString(d));
		}
	public void setGenre(String d)
		{
			this.genreText.setText(d);
		}
	public void setUnitsinstock(double d)
		{
			this.unitsinstockText.setText(Double.toString(d));
		}
	public void setComputeStockingFee(double d)
		{
			this.computeStockingFeeText.setText(Double.toString(d));
		}

	public void setComputeInventoryValue(double d)
		{
			this.computeInventoryValueText.setText(Double.toString(d));
		}



	}


Was This Post Helpful? 0
  • +
  • -

#11 Dogstopper   User is offline

  • The Ninjaducky
  • member icon

Reputation: 2965
  • View blog
  • Posts: 11,222
  • Joined: 15-July 08

Re: inventory program part 4 - GUI

Posted 06 December 2009 - 09:28 PM

Ok, I see where it went wrong.
gui.setItemNumber(acdc.getItemNumber());
		gui.setItemName(acdc.getItemName());
		gui.setPrice(acdc.getPrice());
		gui.setGenre(acdc.getGenre());
		gui.setUnitsinstock(acdc.getStockNumbers());
		gui.setComputeStockingFee(acdc.computeStockingFee());
		gui.setComputeInventoryValue(acdc.computeInventoryValue());

		gui.setItemNumber(bush.getItemNumber());
		gui.setItemName(bush.getItemName());
		gui.setPrice(bush.getPrice());
		gui.setGenre(bush.getGenre());
		gui.setUnitsinstock(bush.getStockNumbers());
		gui.setComputeStockingFee(bush.computeStockingFee());
		gui.setComputeInventoryValue(bush.computeInventoryValue());

		gui.setItemNumber(creed.getItemNumber());
		gui.setItemName(creed.getItemName());
		gui.setPrice(creed.getPrice());
		gui.setGenre(creed.getGenre());
		gui.setUnitsinstock(creed.getStockNumbers());
		gui.setComputeStockingFee(creed.computeStockingFee());
		gui.setComputeInventoryValue(creed.computeInventoryValue());

		gui.setItemNumber(korn.getItemNumber());
		gui.setItemName(korn.getItemName());
		gui.setPrice(korn.getPrice());
		gui.setGenre(korn.getGenre());
		gui.setUnitsinstock(korn.getStockNumbers());
		gui.setComputeStockingFee(korn.computeStockingFee());
		gui.setComputeInventoryValue(korn.computeInventoryValue());



Right? Well, all those instructions are performed, but because it is the same GUI, if you set a value and then set a second value, the field will display only the second value. Here's a suggestion, not that it is easy. Try to add a JButton, that when clicked outputs the next CD. You can do this by utilizing a CD array instead of directly referencing the CD names, reference the array indexes instead.

-- Good luck!
Was This Post Helpful? 0
  • +
  • -

#12 Dogstopper   User is offline

  • The Ninjaducky
  • member icon

Reputation: 2965
  • View blog
  • Posts: 11,222
  • Joined: 15-July 08

Re: inventory program part 4 - GUI

Posted 06 December 2009 - 09:31 PM

dual topic...please close.
Was This Post Helpful? 0
  • +
  • -

#13 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8378
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: inventory program part 4 - GUI

Posted 06 December 2009 - 09:52 PM

Duplicated topics merged
Was This Post Helpful? 0
  • +
  • -

#14 atherton23   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 18-November 09

Re: inventory program part 4 - GUI

Post icon  Posted 07 December 2009 - 08:58 AM

I am have an issue with mu GUI. I am writing an inventory program to track stock of CDs and their stocking information. I have no errors and everything is working properly but I only see the last CD in my GUI in a list of 4 CDs. I am assuming my problem is lieing in the main class( my first class) or possible inventoryGUI class (last class in program). Please take a look any suggestions is greatly appreciated.

Thanks

package inventoryprogram;
	import java.awt.*;
	import javax.swing.*;

/**
 *
 * @author Atherton
 */
public class Main {

	/**
	 * @param args the command line arguments
	 */

	public static void main(String[] args) {
		// TODO code application logic here


		CD[] CD = new CD[100];

			CD bush = new CD("Bush", 1, 10, 10.99, "Rock", 0.56);
			System.out.println();
			CD acdc = new CD("ACDC", 2, 12, 12.99, "Rock", 0.65);
			System.out.println();
			CD creed = new CD("Creed", 3, 4, 9.99, "Rock", 0.50);
			System.out.println();
			CD korn = new CD("Korn", 4, 7, 14.99, "Rock", 0.75);
			System.out.println();

		acdc.showInventory();
			System.out.println();

		bush.showInventory();
			System.out.println();

		creed.showInventory();
			System.out.println();

		korn.showInventory();
			System.out.println();

		for (int i = 0; i<args.length; i++)
			System.out.println(args[i] + ",");

		double array[] = {109.90, 155.88, 39.96, 104.93};
		double total = 0;

		for (int counter = 0; counter < array.length; counter++)
			total += array[counter];

		System.out.println();
		System.out.printf("Total inventory value is: $%.2f\n", total);
		System.out.println("There will be a .5% Restocking Fee with all orders returned.");
		System.out.println();

		InventoryGUI gui = new InventoryGUI();

		gui.setItemNumber(acdc.getItemNumber());
		gui.setItemName(acdc.getItemName());
		gui.setPrice(acdc.getPrice());
		gui.setGenre(acdc.getGenre());
		gui.setUnitsinstock(acdc.getStockNumbers());
		gui.setComputeStockingFee(acdc.computeStockingFee());
		gui.setComputeInventoryValue(acdc.computeInventoryValue());

		gui.setItemNumber(bush.getItemNumber());
		gui.setItemName(bush.getItemName());
		gui.setPrice(bush.getPrice());
		gui.setGenre(bush.getGenre());
		gui.setUnitsinstock(bush.getStockNumbers());
		gui.setComputeStockingFee(bush.computeStockingFee());
		gui.setComputeInventoryValue(bush.computeInventoryValue());

		gui.setItemNumber(creed.getItemNumber());
		gui.setItemName(creed.getItemName());
		gui.setPrice(creed.getPrice());
		gui.setGenre(creed.getGenre());
		gui.setUnitsinstock(creed.getStockNumbers());
		gui.setComputeStockingFee(creed.computeStockingFee());
		gui.setComputeInventoryValue(creed.computeInventoryValue());

		gui.setItemNumber(korn.getItemNumber());
		gui.setItemName(korn.getItemName());
		gui.setPrice(korn.getPrice());
		gui.setGenre(korn.getGenre());
		gui.setUnitsinstock(korn.getStockNumbers());
		gui.setComputeStockingFee(korn.computeStockingFee());
		gui.setComputeInventoryValue(korn.computeInventoryValue());


		} // end public main

	}

	class CD
	{
	private String cdName;
	private double itemNumber;
	private double unitsInStock;
	private double unitPrice;
	private String cdGenre;
	private double ReStockingFee;

	public CD(String itemName, double cdNumber, double unitsInStock, double unitPrice, String Genre, double StockingFee)
	{
	 this.cdName = itemName;
	 this.itemNumber = cdNumber;
	 this.unitsInStock = unitsInStock;
	 this.unitPrice = unitPrice;
	 this.cdGenre = Genre;
	 this.ReStockingFee = StockingFee;
	}

	 public String getItemName()
	 {
		  return this.cdName;
	 }

	 public double getItemNumber()
	 {
		  return this.itemNumber;
	 }

	 public double getStockNumbers()
	 {
		  return this.unitsInStock;
	 }

	 public double getPrice()
	 {
		  return this.unitPrice;
	 }

	 public String getGenre()
	 {
		 return this.cdGenre;
	 }

	 public double computeStockingFee()
	 {
		 return this.ReStockingFee * unitPrice;
	 }

	 public double computeInventoryValue()
	 {
		  return this.unitsInStock * unitPrice;
	 }


	public void showInventory()
	{
		System.out.println("CD item number: " +itemNumber);
		System.out.println("CD Name: " +cdName);
		System.out.println("Number of Units: "+unitsInStock);
		System.out.println("Price: "+unitPrice);
		System.out.println("Genre: " +cdGenre);
		System.out.println("Restocking Fee per CD: " +ReStockingFee);
		System.out.printf("Inventory Value of "+cdName+" is = $%.2f\n", computeInventoryValue());

	}

 }

class genre extends CD
	{
		
		genre(String itemName, double cdNumber, double unitsInStock, double unitPrice, String cdGenre, double ReStockingFee )
		{
			super(itemName, cdNumber, unitsInStock, unitPrice, cdGenre, ReStockingFee);
			cdGenre = genre;
		}
		
		private String cdGenre;
		String genre;

		public void setGenre ( String genre)
		{
			this.cdGenre = genre;
		}

		public String getgenre()
		{
			return cdGenre;
		}

		public double getValue()
		{
			return super.computeInventoryValue() * 1.05;
		}

		public double getReStockingFee()
		{
			return super.computeInventoryValue() * .05;
		}

	@Override
		public String toString()
		{
			String formatString = "Genre:  %s";
			formatString += "Restocking Fee:  $%.2f";
			formatString = String.format(formatString, cdGenre, super.computeInventoryValue() * 0.05);
			return( formatString + super.toString() );
		}

		public void showInvwentory()
		{
			super.showInventory();
			System.out.println( toString());
			System.out.println( "Genre: "+cdGenre);
			System.out.printf("\nInventory value of "+cdGenre+" is = $%.2f\n", getReStockingFee() );
		}

	  }

class InventoryGUI extends JFrame
	{

		private final JLabel itemNumberLabel = new JLabel("  Item Number:");
		private JTextField itemNumberText;

		private final JLabel itemNameLabel = new JLabel("  CD Name:");
		private JTextField itemNameText;

		private final JLabel priceLabel = new JLabel("  CD Price:");
		private JTextField priceText;

		private final JLabel genreLabel = new JLabel("  Genre:");
		private JTextField genreText;

		private final JLabel unitsinstockLabel = new JLabel("  Stock:");
		private JTextField unitsinstockText;

		private final JLabel computeStockingFeeLabel = new JLabel("  Restocking Fee:");
		private JTextField computeStockingFeeText;

		private final JLabel computeInventoryValueLabel = new JLabel("  Inventory Total Value:");
		private JTextField computeInventoryValueText;

		private JPanel centerPanel;


	InventoryGUI()
		{

		super("CD Inventory List");
		final Dimension dim = new Dimension(150, 40);
		final FlowLayout flo = new FlowLayout(FlowLayout.LEFT);
		JPanel jp;


		centerPanel = new JPanel();
		centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS));

		jp = new JPanel(flo);
		itemNumberLabel.setPreferredSize(dim);
		jp.add(itemNumberLabel);
		itemNumberText = new JTextField(3);
		itemNumberText.setEditable(false);
		jp.add(itemNumberText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		itemNameLabel.setPreferredSize(dim);
		jp.add(itemNameLabel);
		itemNameText = new JTextField(17);
		itemNameText.setEditable(false);
		jp.add(itemNameText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		priceLabel.setPreferredSize(dim);
		jp.add(priceLabel);
		priceText = new JTextField(17);
		priceText.setEditable(false);
		jp.add(priceText);
		centerPanel.add(jp);

		jp = new JPanel (flo);
		genreLabel.setPreferredSize(dim);
		jp.add(genreLabel);
		genreText = new JTextField(17);
		genreText.setEditable(false);
		jp.add(genreText);
		centerPanel.add(jp);
		
		jp = new JPanel(flo);
		unitsinstockLabel.setPreferredSize(dim);
		jp.add(unitsinstockLabel);
		unitsinstockText = new JTextField(5);
		unitsinstockText.setEditable(false);
		jp.add(unitsinstockText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		computeStockingFeeLabel.setPreferredSize(dim);
		jp.add(computeStockingFeeLabel);
		computeStockingFeeText = new JTextField(17);
		computeStockingFeeText.setEditable(false);
		jp.add(computeStockingFeeText);
		centerPanel.add(jp);

		jp = new JPanel(flo);
		computeInventoryValueLabel.setPreferredSize(dim);
		jp.add(computeInventoryValueLabel);
		computeInventoryValueText = new JTextField(17);
		computeInventoryValueText.setEditable(false);
		jp.add(computeInventoryValueText);
		centerPanel.add(jp);

		setContentPane(centerPanel);

		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setSize(400, 400);
		setResizable(false);
		setLocationRelativeTo(null);
		setVisible(true);

		}


	public void setItemNumber(double d)
		{
			this.itemNumberText.setText(Double.toString(d));
		}
	
	public void setItemName(String d)
		{
			this.itemNameText.setText(d);
		}
	public void setPrice(double d)
		{
			this.priceText.setText(Double.toString(d));
		}
	public void setGenre(String d)
		{
			this.genreText.setText(d);
		}
	public void setUnitsinstock(double d)
		{
			this.unitsinstockText.setText(Double.toString(d));
		}
	public void setComputeStockingFee(double d)
		{
			this.computeStockingFeeText.setText(Double.toString(d));
		}

	public void setComputeInventoryValue(double d)
		{
			this.computeInventoryValueText.setText(Double.toString(d));
		}



	}


Was This Post Helpful? 0
  • +
  • -

#15 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8378
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: inventory program part 4 - GUI

Posted 07 December 2009 - 08:04 PM

gui.setItemNumber(acdc.getItemNumber());
gui.setItemName(acdc.getItemName());
gui.setPrice(acdc.getPrice());
gui.setGenre(acdc.getGenre());
gui.setUnitsinstock(acdc.getStockNumbers());
gui.setComputeStockingFee(acdc.computeStockingFee());
gui.setComputeInventoryValue(acdc.computeInventoryValue());

gui.setItemNumber(bush.getItemNumber());
gui.setItemName(bush.getItemName());
gui.setPrice(bush.getPrice());
gui.setGenre(bush.getGenre());
gui.setUnitsinstock(bush.getStockNumbers());
gui.setComputeStockingFee(bush.computeStockingFee());
gui.setComputeInventoryValue(bush.computeInventoryValue());

gui.setItemNumber(creed.getItemNumber());
gui.setItemName(creed.getItemName());
gui.setPrice(creed.getPrice());
gui.setGenre(creed.getGenre());
gui.setUnitsinstock(creed.getStockNumbers());
gui.setComputeStockingFee(creed.computeStockingFee());
gui.setComputeInventoryValue(creed.computeInventoryValue());

gui.setItemNumber(korn.getItemNumber());
gui.setItemName(korn.getItemName());
gui.setPrice(korn.getPrice());
gui.setGenre(korn.getGenre());
gui.setUnitsinstock(korn.getStockNumbers());
gui.setComputeStockingFee(korn.computeStockingFee());
gui.setComputeInventoryValue(korn.computeInventoryValue());

all these:
setItemNumber(), setItemName(), setPrice() refer to the same unique JTextFields in the GUI
so only the last one will be shown
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2