473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Adding a GUI

nexcompac
Ok, I am working on an inventory program and this is where I am at thus far. I seem to be getting two errors that I can not figure out. I will post the errors at the end of the code.


Expand|Select|Wrap|Line Numbers
  1. import java.util.*;
  2. import java.awt.*;
  3. import javax.swing.*;
  4. import java.awt.event.*;
  5.  
  6.  
  7.  
  8. public class Inventory extends JFrame// Main class
  9. {
  10.  
  11.  
  12.     private JLabel prodNameLabel;
  13.     private JLabel numberLabel;
  14.     private JLabel unitLabel;
  15.     private JLabel priceLabel;
  16.     private JLabel featureLabel;
  17.     private JLabel valueLabel;
  18.     private JLabel rstkLabel;
  19.     private JLabel totalLabel;
  20.     private JTextField prodNameField;
  21.     private JTextField numberField;
  22.     private JTextField unitField;
  23.     private JTextField priceField;
  24.     private JTextField featureField;
  25.     private JTextField valueField;
  26.     private JTextField rstkField;
  27.     private JTextField totalField;
  28.     private JButton firstBtn;
  29.     private JButton prevBtn;
  30.     private JButton nextBtn;
  31.     private JButton lastBtn;
  32.     private JPanel buttonJPanel;
  33.     private JPanel fieldJPanel;
  34.     private JPanel fontJPanel;
  35.     private List<ProductAdd> nwProduct;
  36.     private int currProd = 0;
  37.     private double total; // variable for total inventory
  38.  
  39.  
  40.  
  41.     public Inventory()
  42.     {
  43.         initComponents();
  44.     }
  45.  
  46.     private void initComponents()
  47.     {
  48.         prodNameLabel = new JLabel("Product Name:");
  49.         numberLabel = new JLabel("Item Number:");
  50.         unitLabel = new JLabel("In Stock:");
  51.         priceLabel = new JLabel("Each Item Cost:");
  52.         featureLabel = new JLabel("Type of Item:");
  53.         valueLabel = new JLabel("Value of Item Inventory:");
  54.         rstkLabel = new JLabel("Cost to Re-Stock Item:");
  55.         totalLabel = new JLabel("Total Value of Inventory:");
  56.  
  57.         firstBtn = new JButton("First");
  58.         prevBtn = new JButton("Previous");
  59.         nextBtn = new JButton("Next");
  60.         lastBtn = new JButton("Last");
  61.  
  62.         prodNameField = new JTextField();
  63.         prodNameField.setEditable(false);
  64.         numberField = new JTextField();
  65.         numberField.setEditable(false);
  66.         unitField = new JTextField();
  67.         unitField.setEditable(false);
  68.         priceField = new JTextField();
  69.         priceField.setEditable(false);
  70.         featureField = new JTextField();
  71.         featureField.setEditable(false);
  72.         valueField = new JTextField();
  73.         valueField.setEditable(false);
  74.         rstkField = new JTextField();
  75.         rstkField.setEditable(false);
  76.         totalField = new JTextField();
  77.         totalField.setEditable(false);
  78.  
  79.         prodNameLabel.setSize(200, 20);
  80.         numberLabel.setSize(200, 20);
  81.         unitLabel.setSize(200, 20);
  82.         priceLabel.setSize(200, 20);
  83.         featureLabel.setSize(200, 20);
  84.         valueLabel.setSize(200, 20);
  85.         rstkLabel.setSize(200, 20);
  86.         totalLabel.setSize(200, 20);
  87.  
  88.         prodNameField.setSize(100, 20);
  89.         numberField.setSize(100, 20);
  90.         unitField.setSize(100, 20);
  91.         priceField.setSize(100, 20);
  92.         featureField.setSize(100, 20);
  93.         valueField.setSize(100, 20);
  94.         rstkField.setSize(100, 20);
  95.         totalField.setSize(100, 20);
  96.  
  97.         buttonJPanel = new JPanel(); // set up panel
  98.         buttonJPanel.setLayout( new GridLayout(1, 4)); //set layout
  99.         // add buttons to buttonJPanel
  100.         buttonJPanel.add(firstBtn);
  101.         buttonJPanel.add(prevBtn);
  102.         buttonJPanel.add(nextBtn);
  103.         buttonJPanel.add(lastBtn);
  104.  
  105.  
  106.  
  107.     }
  108.     public static void main( String args[])
  109.     {
  110.       product[] myProduct = new product[5];
  111.       //Company[] myCompany = new Company[5];
  112.  
  113.         product p1 = new Company("Mad Dash", 20003, 5, 30, "EIDOS");
  114.         product p2 = new Company("Fuzion Frenzy", 74512, 2, 10, "MicroSoft");
  115.         product p3 = new Company("Time Splitters 2", 20009, 3, 45, "EIDOS");
  116.         product p4 = new Company("Night Caster", 74522, 8, 5, "MicroSoft");
  117.         product p5 = new Company("Lego Star Wars II", 32976, 1, 50, "LucasArts");
  118.  
  119.         myProduct[0] = p1;
  120.         myProduct[1] = p2;
  121.         myProduct[2] = p3;
  122.         myProduct[3] = p4;
  123.         myProduct[4] = p5;
  124.  
  125.         double totalValue = 0.0;
  126.  
  127.         for (int c=0; c < 5; c++)
  128.         {
  129.             totalValue = totalValue + myProduct[c].itemCalculate();
  130.         }
  131.  
  132.         Arrays.sort(myProduct); // function used to sort arrays
  133.  
  134.         for(product p: myProduct)
  135.         {
  136.             System.out.println(p);
  137.             System.out.println();
  138.         }
  139.        System.out.println("Total Inventory value is: $"+totalValue);
  140.  
  141.    } //end main
  142.  
  143. } //end Inventory
  144.  

Here are the two errors that I recieve

Expand|Select|Wrap|Line Numbers
  1. C:\Users\Brian\Desktop\Java Inventory program\Inventory.java:35: cannot find symbol
  2. symbol  : class list
  3. location: class Inventory
  4.     private list<ProductAdd> nwProduct;
  5.             ^
  6. C:\Users\Brian\Desktop\Java Inventory program\Inventory.java:35: cannot find symbol
  7. symbol  : class ProductAdd
  8. location: class Inventory
  9.     private list<ProductAdd> nwProduct;
  10.                  ^
  11. 2 errors
  12.  
  13. Tool completed with exit code 1
  14.  
  15.  
Can not figure out why this will not compile... What am I missing.
Aug 13 '07 #1
8 2039
madhoriya22
252 100+
C:\Users\Brian\Desktop\Java Inventory program\Inventory.java:35: cannot find symbol
symbol : class list
location: class Inventory
private list<ProductAdd> nwProduct;
^
C:\Users\Brian\Desktop\Java Inventory program\Inventory.java:35: cannot find symbol
symbol : class ProductAdd
location: class Inventory
private list<ProductAdd> nwProduct;
^
2 errors

Tool completed with exit code 1


Can not figure out why this will not compile... What am I missing.
Hi,
luk at ur first error...compiler is not able to find symbol *list*...I think it should be *List*.
Same problem can be in second error also...check for ProductAdd..Is it the right name. check for spelling also..

thanks and regards,
madhoriya22
Aug 13 '07 #2
I tried both ways with the capitols. Still got the same errors.
Aug 13 '07 #3
madhoriya22
252 100+
I tried both ways with the capitols. Still got the same errors.
Hi,
Where are you using this List<ProductAdd> nwProduct in ur program?

thanks and regards,
madhoriya22.
Aug 13 '07 #4
praveen2gupta
201 100+
Hi
private List<ProductAdd> nwProduct declaration is wrong
use following
private List nwProduct;
Aug 13 '07 #5
ok, changed that line of code to read what you sugested and here are the error codes.

Expand|Select|Wrap|Line Numbers
  1. C:\Users\Brian\Desktop\Java Inventory program\Inventory.java:35: reference to List is ambiguous, both class java.awt.List in java.awt and class java.util.List in java.util match
  2.     private List nwProduct;
  3.             ^
  4. 1 error
  5.  
  6. Tool completed with exit code 1
  7.  

What is ment by where is my refrence?
Aug 13 '07 #6
madhoriya22
252 100+
ok, changed that line of code to read what you sugested and here are the error codes.

Expand|Select|Wrap|Line Numbers
  1. C:\Users\Brian\Desktop\Java Inventory program\Inventory.java:35: reference to List is ambiguous, both class java.awt.List in java.awt and class java.util.List in java.util match
  2.     private List nwProduct;
  3.      ^
  4. 1 error
  5.  
  6. Tool completed with exit code 1
  7.  

What is ment by where is my refrence?
Hi,
where u have initialized ur List? Compiler is not able to differentiate that Is it a AWT List or util List.

Thanks and regards,
madhoriya22.
Aug 13 '07 #7
Ok, so I removed the line to work backwards to move forward. Now, it complies but the GUI does not show up. When I run the program it goes to the comand prompt.

Expand|Select|Wrap|Line Numbers
  1. import java.util.*;
  2. import java.awt.*;
  3. import javax.swing.*;
  4. import java.awt.event.*;
  5. import javax.swing.JFrame; // provides basic window features
  6. import javax.swing.JLabel; // displays text and images
  7. import javax.swing.SwingConstants; // common constants used with Swing
  8. import javax.swing.Icon; // interface used to manipulate images
  9. import javax.swing.ImageIcon; // loads images
  10.  
  11.  
  12.  
  13. public class Inventory extends JFrame// Main class
  14. {
  15.  
  16.  
  17.     private JLabel prodNameLabel;
  18.     private JLabel numberLabel;
  19.     private JLabel unitLabel;
  20.     private JLabel priceLabel;
  21.     private JLabel featureLabel;
  22.     private JLabel valueLabel;
  23.     private JLabel rstkLabel;
  24.     private JLabel totalLabel;
  25.     private JTextField prodNameField;
  26.     private JTextField numberField;
  27.     private JTextField unitField;
  28.     private JTextField priceField;
  29.     private JTextField featureField;
  30.     private JTextField valueField;
  31.     private JTextField rstkField;
  32.     private JTextField totalField;
  33.     private JButton firstBtn;
  34.     private JButton prevBtn;
  35.     private JButton nextBtn;
  36.     private JButton lastBtn;
  37.     private JPanel buttonJPanel;
  38.     private JPanel fieldJPanel;
  39.     private JPanel fontJPanel;
  40.     private int currProd = 0;
  41.     private double total; // variable for total inventory
  42.  
  43.  
  44.  
  45.     public Inventory()
  46.     {
  47.         initComponents();
  48.     }
  49.  
  50.     private void initComponents()
  51.     {
  52.         prodNameLabel = new JLabel("Product Name:");
  53.         numberLabel = new JLabel("Item Number:");
  54.         unitLabel = new JLabel("In Stock:");
  55.         priceLabel = new JLabel("Each Item Cost:");
  56.         featureLabel = new JLabel("Type of Item:");
  57.         valueLabel = new JLabel("Value of Item Inventory:");
  58.         rstkLabel = new JLabel("Cost to Re-Stock Item:");
  59.         totalLabel = new JLabel("Total Value of Inventory:");
  60.  
  61.         firstBtn = new JButton("First");
  62.         prevBtn = new JButton("Previous");
  63.         nextBtn = new JButton("Next");
  64.         lastBtn = new JButton("Last");
  65.  
  66.         prodNameField = new JTextField();
  67.         prodNameField.setEditable(false);
  68.         numberField = new JTextField();
  69.         numberField.setEditable(false);
  70.         unitField = new JTextField();
  71.         unitField.setEditable(false);
  72.         priceField = new JTextField();
  73.         priceField.setEditable(false);
  74.         featureField = new JTextField();
  75.         featureField.setEditable(false);
  76.         valueField = new JTextField();
  77.         valueField.setEditable(false);
  78.         rstkField = new JTextField();
  79.         rstkField.setEditable(false);
  80.         totalField = new JTextField();
  81.         totalField.setEditable(false);
  82.  
  83.         prodNameLabel.setSize(200, 20);
  84.         numberLabel.setSize(200, 20);
  85.         unitLabel.setSize(200, 20);
  86.         priceLabel.setSize(200, 20);
  87.         featureLabel.setSize(200, 20);
  88.         valueLabel.setSize(200, 20);
  89.         rstkLabel.setSize(200, 20);
  90.         totalLabel.setSize(200, 20);
  91.  
  92.         prodNameField.setSize(100, 20);
  93.         numberField.setSize(100, 20);
  94.         unitField.setSize(100, 20);
  95.         priceField.setSize(100, 20);
  96.         featureField.setSize(100, 20);
  97.         valueField.setSize(100, 20);
  98.         rstkField.setSize(100, 20);
  99.         totalField.setSize(100, 20);
  100.  
  101.         buttonJPanel = new JPanel(); // set up panel
  102.         buttonJPanel.setLayout( new GridLayout(1, 4)); //set layout
  103.         // add buttons to buttonJPanel
  104.         buttonJPanel.add(firstBtn);
  105.         buttonJPanel.add(prevBtn);
  106.         buttonJPanel.add(nextBtn);
  107.         buttonJPanel.add(lastBtn);
  108.  
  109.  
  110.  
  111.     }
  112.     public static void main( String args[])
  113.     {
  114.       product[] myProduct = new product[5];
  115.       //Company[] myCompany = new Company[5];
  116.  
  117.         product p1 = new Company("Mad Dash", 20003, 5, 30, "EIDOS");
  118.         product p2 = new Company("Fuzion Frenzy", 74512, 2, 10, "MicroSoft");
  119.         product p3 = new Company("Time Splitters 2", 20009, 3, 45, "EIDOS");
  120.         product p4 = new Company("Night Caster", 74522, 8, 5, "MicroSoft");
  121.         product p5 = new Company("Lego Star Wars II", 32976, 1, 50, "LucasArts");
  122.  
  123.         myProduct[0] = p1;
  124.         myProduct[1] = p2;
  125.         myProduct[2] = p3;
  126.         myProduct[3] = p4;
  127.         myProduct[4] = p5;
  128.  
  129.         double totalValue = 0.0;
  130.  
  131.         for (int c=0; c < 5; c++)
  132.         {
  133.             totalValue = totalValue + myProduct[c].itemCalculate();
  134.         }
  135.  
  136.         Arrays.sort(myProduct); // function used to sort arrays
  137.  
  138.         for(product p: myProduct)
  139.         {
  140.             System.out.println(p);
  141.             System.out.println();
  142.         }
  143.        System.out.println("Total Inventory value is: $"+totalValue);
  144.  
  145.    } //end main
  146.  
  147. } //end Inventory
  148.  
  149.  

Expand|Select|Wrap|Line Numbers
  1. import java.util.*;
  2.  
  3. public class Company extends product implements Comparable
  4. {
  5.     private String developer;
  6.     //double total;
  7.  
  8.     /** Creates a new instance of Company */
  9.     public Company()
  10.     {
  11.         super();
  12.         String developer ="";
  13.         //total =0.0;
  14.     }
  15.     public Company(String productName, int itemNumber, double unitProduct, double priceProduct, String developer)
  16.     {
  17.         super(productName, itemNumber, unitProduct, priceProduct);
  18.         this.developer = developer;
  19.     }
  20.  
  21.         public void setDeveloper( String developer)
  22.          {
  23.             this.developer = developer;
  24.          }
  25.         public String getDeveloper()
  26.          {
  27.             return developer;
  28.          }
  29.  
  30.         public double itemCalculate()
  31.         {
  32.             return (super.itemCalculate()*.05)+super.itemCalculate();
  33.         }
  34.  
  35.         public int compareTo (Object o) // use the compareTo method
  36.         {
  37.             product p = (product)o;
  38.             return productName.compareTo(p.getProductName());
  39.         }
  40.  
  41.         public String toString()
  42.         {
  43.          return super.toString()+ "\nCompany: "+ developer +"\nPrice with restock fee: $"+itemCalculate();
  44.         }
  45. }
  46.  
  47.  
  48.  
  49.  
  50.  

Expand|Select|Wrap|Line Numbers
  1. import java.util.*; // program uses any class available
  2.  
  3. class product implements Comparable
  4. {
  5.    public String productName; // class variable that stores the item name
  6.    private int itemNumber; // class variable that stores the item number
  7.    private double unitProduct; // class variable that stores the quantity in stock
  8.    private double priceProduct; // class variable that stores the item price
  9.  
  10.     /** Creates a new instance of product */
  11.     public product() // Constructor for Product class
  12.      {
  13.         productName = "";
  14.         itemNumber = 0;
  15.         unitProduct = 0.0;
  16.         priceProduct = 0.0;
  17.      }
  18.     public product( String productName, int itemNumber, double unitProduct, double priceProduct) // Constructor for myProduct class
  19.     {
  20.         this.productName = productName;
  21.         this.itemNumber = itemNumber;
  22.         this.unitProduct = unitProduct;
  23.         this.priceProduct = priceProduct;
  24.     }
  25.  
  26.       public void setProductName(String name)  // Method to set the item name
  27.        {
  28.          this.productName = productName;
  29.        }
  30.       public String getProductName()  // Method to get the item name
  31.        {
  32.          return productName;
  33.        }
  34.       public void setItemNumber(int number)  // Method to set the item number
  35.        {
  36.          this.itemNumber = itemNumber;
  37.        }
  38.       public int getItemNumber()  // Method to get the item name
  39.        {
  40.          return itemNumber;
  41.        }
  42.        public void setUnitProduct(double unit)  // Method to set the item number
  43.        {
  44.          this.unitProduct = unitProduct;
  45.        }
  46.       public double getUnitProduct()  // Method to get the item name
  47.        {
  48.          return unitProduct;
  49.        }
  50.        public void setPriceProduct(double price)  // Method to set the item number
  51.        {
  52.          this.priceProduct = priceProduct;
  53.        }
  54.       public double getPriceProduct()  // Method to get the item name
  55.        {
  56.          return priceProduct;
  57.        }
  58.  
  59. // Calculation method
  60.   public double itemCalculate()
  61.    {
  62.         return unitProduct * priceProduct; // multiply for total for each item
  63.  
  64.    } // end calculation
  65.   public int compareTo (Object o) // use the compareTo method
  66.     {
  67.       product p = (product)o;
  68.          return productName.compareTo(p.getProductName());
  69.     }
  70.  
  71.   public String toString() // displays products
  72.   {
  73.       return "Title: "+productName+
  74.               "\nBarcode: "+itemNumber+
  75.               "\nNumber of Xbox games: "+(int)unitProduct+
  76.               "\nPrice: $"+priceProduct+
  77.               "\nTotal: $"+itemCalculate();
  78.    } // end toString
  79.  
  80.  
  81. }//end class Supplies
  82.  
  83.  
Aug 14 '07 #8
madhoriya22
252 100+
Ok, so I removed the line to work backwards to move forward. Now, it complies but the GUI does not show up. When I run the program it goes to the comand prompt.

Hi,
Declare ur list like this .. to remove the ambiguity
Expand|Select|Wrap|Line Numbers
  1.  
  2. private java.awt.List nwProduct;
  3. private void initComponents()
  4.     {
  5. nwProduct = new java.awt.List();
  6.  
GUI is not creating bcoz u r not creating any object of ur inventory class in main method.
thanks and regards,
madhoriya22
Aug 14 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Jamie Fryatt | last post by:
Hi everyone, here's what id like to do. I have a table with 2 fields, name and value I need to be able to add multiple records quickly, for example I need to add name value abc 1...
10
by: sp0 | last post by:
Is there a reason why to make mix numbers improper when adding? It seems when subtracting and adding, adding a subtracting the whole numbers and fraction parts should be sufficient? what'ch think
1
by: hzgt9b | last post by:
When adding my VB .NET solution (with two sub-projects) the folder structure in VSS gets an extra level of folders... For example, here's the structure of the solution on my C:\...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
3
by: Robin Thomas | last post by:
I am fairly new to ASP.NET so I think I am missing something fundamental. Anyway, quite often I am pulling data from a database, but then I need to use that data to produce more data. A simple...
0
by: Sileesh | last post by:
Hi I have html table and a Button in an Aspx page. I am adding one row with some textboxes to Html table each time i click on the Button thru Javascript. Now problem is when when i try to...
1
by: seanmayhew | last post by:
I have a form page that that while editing saves the data to an xml doc before submitting to db. On each page unload it saves the xmldoc as the user can add multiple items to the company like...
6
by: vb | last post by:
Hi, I am new to .Net. I am using a Combo Box in my windows forms. I am adding the items by creating the instances and adding the same to the list. My questions/doubts are: 1. If I have 25 to...
9
by: Kadett | last post by:
Hi all, I have following problem: I'm creating a ListView (Details) control at run-time and filling it with some records (let's say 10 000). This operation seems to be quite fast, but when I call...
0
by: AndyL69 | last post by:
Hello I've got a very strange Problem. When im adding a new ACE entry to a UNC Direcotry the inherented ACL's will be lost. When I'm adding a new ACE to a directory / file in this UNC path the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.