CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: multiple errors

  1. #1
    Join Date
    May 2009
    Posts
    3

    multiple errors

    Code:
    import java.awt.Container;
    import java.awt.GridLayout;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
    import javax.swing.JButton;
    
    public class InventoryGUI {
    
        private GridLayout gridLayout = new GridLayout(Inventory.MAXIMUM_ITEMS,2);
        private JFrame frame = null;
        private JLabel label = null;
        private JTextField textField = null;
    
        private Inventory inventory = null;
    
        public static final int MAXIMUM_ITEMS = 4;
        Product[] product = null;
    
        private String price = "";
    
        public InventoryGUI(Inventory inventory) {
            this.inventory = inventory;
        }
    
        public void createDisplayGUI() {
    
            // Create a JFrame container for all GUI widgets
                                frame = new JFrame("Inventory");
                                frame = new JFrame("Number");
                                frame = new JFrame("Name");
                                frame = new JFrame("Quantity");
                                frame = new JFrame("Price");
                                frame = new JFrame("Item Value");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
            // Set up default look and feel for particular Operating System
            JFrame.setDefaultLookAndFeelDecorated(true);
    
            // Set up the content pane and components in GridLayout
            Container container = frame.getContentPane();
            container.setLayout(gridLayout);
    
            // get the all the products in the inventory
             product = inventory.getProduct();
    
            // loop through all the products in the inventory and display them.
               for (int i=0; i < Inventory.MAXIMUM_ITEMS; i++) {
    
    
                // Define label widget
                  label = new JLabel(product[i].getName());
    
    
             Icon logo = new ImageIcon("C:/COMPANYLOGO.jpg");
             label = new JLabel(logo);
             label.setToolTipText("Company Logo");
    
    
                // Define textField widget
                price = Double.toString (product[i].getPrice());
                textField = new JTextField(price);
    
                // add widgets to JFrame
                container.add(label);
                container.add(textField);
    
                 //add buttons to JFrame
                  JButton add = new JButton("Add");
                  JButton delete = new JButton("Delete");
                  JButton modify = new JButton("Modify");
                  JButton first = new JButton("First");
                  JButton next = new JButton("Next");
                  JButton previous = new JButton("Previous");
                  JButton last = new JButton("Last");
            }
    
            // display the frame and all widgets within
            frame.pack();
            frame.setVisible(true);
        }
    }
    This is a different code than the one I posted before. This uses a GUI interface and goes something like this. But first I will give you the list of errors that I got after added { at the end of the parsing.
    E:\IT 215 Java Programming\public class InventoryGUI.java:10: class InventoryGUI is public, should be declared in a file named InventoryGUI.java
    public class InventoryGUI {
    ^
    .\Inventory.java:22: not a statement
    for (int number=0; counter;prodArray.list counter++ )
    ^
    .\Inventory.java:22: ')' expected
    for (int number=0; counter;prodArray.list counter++ )
    ^
    .\Inventory.java:22: ';' expected
    for (int number=0; counter;prodArray.list counter++ )
    ^
    .\Inventory.java:37: class, interface, or enum expected
    import java.util.Locale;
    ^
    .\Inventory.java:38: class, interface, or enum expected
    import java.text.NumberFormat;
    ^
    E:\IT 215 Java Programming\public class InventoryGUI.java:20: cannot find symbol
    symbol : class Product
    location: class InventoryGUI
    Product[] product = null;
    ^
    E:\IT 215 Java Programming\public class InventoryGUI.java:12: cannot find symbol
    symbol : variable MAXIMUM_ITEMS
    location: class Inventory
    private GridLayout gridLayout = new GridLayout(Inventory.MAXIMUM_ITEMS,2);
    ^
    E:\IT 215 Java Programming\public class InventoryGUI.java:47: cannot find symbol
    symbol : method getProduct()
    location: class Inventory
    product = inventory.getProduct();
    ^
    E:\IT 215 Java Programming\public class InventoryGUI.java:50: cannot find symbol
    symbol : variable MAXIMUM_ITEMS
    location: class Inventory
    for (int i=0; i < Inventory.MAXIMUM_ITEMS; i++) {
    ^
    .\Inventory.java:22: cannot find symbol
    symbol : variable counter
    location: class Inventory
    for (int number=0; counter;prodArray.list counter++ )
    ^
    .\Inventory.java:22: cannot find symbol
    symbol : variable counter
    location: class Inventory
    for (int number=0; counter;prodArray.list counter++ )
    ^
    .\Inventory.java:26: cannot find symbol
    symbol : variable counter
    location: class Inventory
    System.out.println("Item Number: " + prodArray[counter].getitemNum());
    ^
    .\Inventory.java:27: cannot find symbol
    symbol : variable counter
    location: class Inventory
    System.out.println("Product Name: " + prodArray[counter].getName());
    ^
    .\Inventory.java:28: cannot find symbol
    symbol : variable counter
    location: class Inventory
    System.out.println("Quantity: " + prodArray[counter].getunits());
    ^
    .\Inventory.java:29: cannot find symbol
    symbol : variable counter
    location: class Inventory
    System.out.println("Unit Price: " + prodArray[counter].getprice());
    ^
    .\Inventory.java:30: cannot find symbol
    symbol : variable counter
    location: class Inventory
    System.out.println("Total Value: " + prodArray[counter].getvalue());
    ^
    .\Inventory.java:118: cannot find symbol
    symbol : variable Locale
    location: class DVD
    + "DVD Price : " + NumberFormat.getCurrencyInstance(Locale.US).format(getprice()) + " "
    ^
    .\Inventory.java:118: cannot find symbol
    symbol : variable NumberFormat
    location: class DVD
    + "DVD Price : " + NumberFormat.getCurrencyInstance(Locale.US).format(getprice()) + " "
    ^
    .\Inventory.java:120: cannot find symbol
    symbol : variable Locale
    location: class DVD
    + "Value of inventory : " + NumberFormat.getCurrencyInstance(Locale.US).format(getvalue());
    ^
    .\Inventory.java:120: cannot find symbol
    symbol : variable NumberFormat
    location: class DVD
    + "Value of inventory : " + NumberFormat.getCurrencyInstance(Locale.US).format(getvalue());
    ^
    21 errors

    Tool completed with exit code 1
    The modification of the Inventory Program to use a GUI. The GUI should display the information one product at a time, including the itme number, the name of the product, the number of units in stock, th eprice of each unit, and the value of the invnetor of that product. In addition, the GUI should display the value of the entire inventory, the additional attribute, and the restocking fee. Thanks for the help in advance!

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: multiple errors

    Quote Originally Posted by tlouvierre View Post
    E:\IT 215 Java Programming\public class InventoryGUI.java:10: class InventoryGUI is public, should be declared in a file named InventoryGUI.java
    public class InventoryGUI {
    What is it about this error message you don't understand?

    The rest of the errors appear to be for another class, because the code isn't in what you posted, but the 'for' loop problems are at least partly due to having rubbish in the loop condition - the second expression should be the termination condition, evaluating to a boolean true/false. In your loop conditon it's just 'counter', whatever that is. The loop increment condition is also wrong, as 'prodArray.list' has been dropped in there for no apparent reason. If the loop starts with 'number' set to zero, shouldn't it check the value of 'number' in the termination condition, and increment 'number' in the increment expression ? (alternatively use 'counter', but not both ). I suggest you re-read your tutorial on 'for' loops and try stepping through one of these loops by hand, writing down the loop variables as you go.
    .\Inventory.java:22: not a statement
    for (int number=0; counter;prodArray.list counter++ )
    Debugging is anticipated with distaste, performed with reluctance, and bragged about forever...
    Anon
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured