Welcome to Dream.In.Code
Become a Java Expert!

Join 149,609 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,844 people online right now. Registration is fast and FREE... Join Now!




Java Inventory GUI

 
Reply to this topicStart new topic

Java Inventory GUI

mudpuppy
19 Aug, 2007 - 08:47 PM
Post #1

New D.I.C Head
*

Joined: 13 Aug, 2007
Posts: 17


My Contributions
I have been posting under the other topic I started named Inventory Program. I hope I do not get in trouble, but I am starting a new post because this is a new part of the program and I wasn't receiving any help in the other one. Please forgive me if this is the wrong thing to do. Ok, now on to my code. This is the errors I am getting when I try to compile.

/tmp/13923/JPanel.java:3: cannot find symbol
symbol : class DrawingArea
location: class JPanel
private DrawingArea left = new DrawingArea();
^
/tmp/13923/JPanel.java:4: cannot find symbol
symbol : class DrawingArea
location: class JPanel
private DrawingArea rite = new DrawingArea();
^
/tmp/13923/JPanel.java:32: cannot find symbol
symbol : class Color
location: class JPanel
private static Color randomColor() {
^
/tmp/13923/JFrame.java:12: cannot find symbol
symbol : constructor JFrame(java.lang.String)
location: class JFrame
JFrame frame = new JFrame("Inventory Of Fish");
^
/tmp/13923/JFrame.java:14: cannot find symbol
symbol : method addWindowListener()
location: class JFrame
frame.addWindowListener(new WindowAdapter() {
^
/tmp/13923/JFrame.java:23: cannot find symbol
symbol : method getContentPane()
location: class JFrame
frame.getContentPane().add(jlbempty, BorderLayout.CENTER);
^
/tmp/13923/JFrame.java:25: cannot find symbol
symbol : method pack()
location: class JFrame
frame.pack();
^
/tmp/13923/JFrame.java:26: cannot find symbol
symbol : method setVisible(boolean)
location: class JFrame
frame.setVisible(true);
^
/tmp/13923/JPanel.java:3: cannot find symbol
symbol : class DrawingArea
location: class JPanel
private DrawingArea left = new DrawingArea();
^
/tmp/13923/JPanel.java:4: cannot find symbol
symbol : class DrawingArea
location: class JPanel
private DrawingArea rite = new DrawingArea();
^
/tmp/13923/JPanel.java:8: cannot find symbol
symbol : variable Color
location: class JPanel
left.setBackground(Color.white);
^
/tmp/13923/JPanel.java:9: cannot find symbol
symbol : variable Color
location: class JPanel
rite.setBackground(Color.black);
^
/tmp/13923/JPanel.java:11: cannot find symbol
symbol : class JButton
location: class JPanel
JButton changeColorBtn = new JButton("Randomize Colors");
^
/tmp/13923/JPanel.java:11: cannot find symbol
symbol : class JButton
location: class JPanel
JButton changeColorBtn = new JButton("Randomize Colors");
^
/tmp/13923/JPanel.java:12: cannot find symbol
symbol : class ActionListener
location: class JPanel
changeColorBtn.addActionListener(new ActionListener() {
^
/tmp/13923/JPanel.java:20: cannot find symbol
symbol : class BorderLayout
location: class JPanel
content.setLayout(new BorderLayout(5, 5));
^
/tmp/13923/JPanel.java:21: cannot find symbol
symbol : variable BorderLayout
location: class JPanel
content.add(changeColorBtn, BorderLayout.NORTH);
^
/tmp/13923/JPanel.java:22: cannot find symbol
symbol : variable BorderLayout
location: class JPanel
content.add(left, BorderLayout.WEST);
^
/tmp/13923/JPanel.java:23: cannot find symbol
symbol : variable BorderLayout
location: class JPanel
content.add(rite, BorderLayout.EAST);
^
/tmp/13923/JPanel.java:26: cannot find symbol
symbol : method setContentPane(JPanel)
location: class JPanel
setContentPane(content);
^
/tmp/13923/JPanel.java:27: cannot find symbol
symbol : variable EXIT_ON_CLOSE
location: class JFrame
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
^
/tmp/13923/JPanel.java:28: cannot find symbol
symbol : method setTitle(java.lang.String)
location: class JPanel
setTitle("Demo Drawing");
^
/tmp/13923/JPanel.java:29: cannot find symbol
symbol : method setLocationRelativeTo()
location: class JPanel
setLocationRelativeTo(null);
^
/tmp/13923/JPanel.java:30: cannot find symbol
symbol : method pack()
location: class JPanel
pack();
^
/tmp/13923/JPanel.java:33: cannot find symbol
symbol : class Color
location: class JPanel
return new Color((int) (Math.random() * 256), // Red
^
/tmp/13923/JPanel.java:42: cannot find symbol
symbol : method setVisible(boolean)
location: class JFrame
window.setVisible(true);
^
/tmp/13923/Inventory.java:48: cannot find symbol
symbol : method printIn(java.lang.String)
location: class java.io.PrintStream
System.out.printIn("Restock Fee: " + (product.getQuantity() * product.getPrice()) * 0.05);
^
/tmp/13923/Inventory.java:50: cannot find symbol
symbol : method printIn()
location: class java.io.PrintStream
System.out.printIn();
^
28 errors

Wow, that is a ton! This is what the assignment said to do: Modify the Inventory Program to use a GUI. The GUI should display the information one product at a time, including the item number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory of that product. In addition, the GUI should display the value of the entire inventory, the additional attribute, and the restocking fee. This assignment was due Friday! I've been working on it for days now!
Here is my code:
CODE
//Stephanie Baker

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;


public class JFrame
{
    public static void main( String args[] )
    {
        JFrame frame = new JFrame("Inventory Of Fish");

        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

        //This is an empty content area in the frame
        JLabel jlbempty = new JLabel("");
        jlbempty.setPreferredSize(new Dimension(400, 400));
        frame.getContentPane().add(jlbempty, BorderLayout.CENTER);

        frame.pack();
        frame.setVisible(true);
    }
}

CODE
public class JPanel extends JFrame {

    private DrawingArea left = new DrawingArea();
    private DrawingArea rite = new DrawingArea();

    
    public JPanel() {
        left.setBackground(Color.white);
        rite.setBackground(Color.black);

        JButton changeColorBtn = new JButton("Randomize Colors");
        changeColorBtn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    left.setMyColor(randomColor());
                    rite.setMyColor(randomColor());
                }
            });

JPanel content = new JPanel();
        content.setLayout(new BorderLayout(5, 5));
        content.add(changeColorBtn, BorderLayout.NORTH);
        content.add(left, BorderLayout.WEST);
        content.add(rite, BorderLayout.EAST);

        
        setContentPane(content);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setTitle("Demo Drawing");
        setLocationRelativeTo(null);  
        pack();
    }
private static Color randomColor() {
        return new Color((int) (Math.random() * 256),  // Red
                         (int) (Math.random() * 256),  // Green
                         (int) (Math.random() * 256)); // Blue
    }


  
    public static void main(String[] args) {
        JFrame window = new JPanel();
        window.setVisible(true);
    }
}

CODE
public class Inventory extends JPanel
{
  
        
        public static final int MAXIMUM_ITEMS = 10;
        private static Product product[] = new Fish[MAXIMUM_ITEMS];

        public static void main(String args[]) {
                buildInventory();
                getInventory();        
        }

    

        
        public static void buildInventory() {

                

                product[0] = new Fish(0, "Fancy Tailed Guppy",25, 4.99);
                product[1] = new Fish(1, "Huma Huma Picasso Trigger",2, 35.99);
                product[2] = new Fish(2, "Black Durgeon Trigger",1, 99.99);
                product[3] = new Fish(3, "Niger Trigger",2, 45.99);
                product[4] = new Fish(4, "Jack Dempsey Cichlid",4, 19.99);
                product[5] = new Fish(5, "Midas Cichlid",1, 69.99);
                product[6] = new Fish(6, "Neon Tetra",25, 2.99);
                product[7] = new Fish(7, "Convict Cichlid",2, 15.99);
                product[8] = new Fish(8, "Oscar", 4, 37.99);
                product[9] = new Fish(9, "Albino Cory Cat",1, 29.99);
        }


        
        public static void getInventory() {
                for(int i = 0; i < product.length; i++) {
                    System.out.println("Number:     " + product[i].getNumber());
                    System.out.println("Name:       " + product[i].getName());
                    System.out.println("Quantity:   " + product[i].getQuantity());
                    System.out.println("Price:      " + product[i].getPrice());
                    System.out.println("Item Value: " + product[i].getQuantity() * product[i].getPrice());
            

                        

                    System.out.printIn("Restock Fee: " + (product[i].getQuantity() * product[i].getPrice()) * 0.05);
                    System.out.printf("\n%s's Inventory Total including Restocking Fee is: $%4.2f%n");
                    System.out.printIn();

              }  
       }
}



If anyone would mind to help me with this, it will be greatly appreciated! Martyr2 has been excellent in helping me thus far. I have 2 more parts following this one, to completeing my program! I feel like this is the code from hell! It never ends!!! LOL

Thanks you all so very much!
User is offlineProfile CardPM
+Quote Post

scarecrowfeild
RE: Java Inventory GUI
20 Aug, 2007 - 06:03 AM
Post #2

New D.I.C Head
*

Joined: 14 Jul, 2007
Posts: 33


My Contributions
hi!
is it really ok to use JPanel as your class name?
JPanel already existed in javax.swing
User is offlineProfile CardPM
+Quote Post

mudpuppy
RE: Java Inventory GUI
20 Aug, 2007 - 05:28 PM
Post #3

New D.I.C Head
*

Joined: 13 Aug, 2007
Posts: 17


My Contributions
QUOTE(scarecrowfeild @ 20 Aug, 2007 - 07:03 AM) *

hi!
is it really ok to use JPanel as your class name?
JPanel already existed in javax.swing

Actually, no it wasn't. My teacher informed me that I needed to change the name of them. I changed them to GUIPanel and GUIFrame. Does this sound alright to anyone? I am getting a ton more errors after I made the changes the teacher told me to. I will post a few here and see if anyone will help me with them.

/tmp/18328/GUIPanel.java:3: cannot find symbol
symbol : class DrawingArea
location: class GUIPanel
private DrawingArea left = new DrawingArea();
^
/tmp/18328/GUIPanel.java:4: cannot find symbol
symbol : class DrawingArea
location: class GUIPanel
private DrawingArea rite = new DrawingArea();
^
/tmp/18328/GUIPanel.java:32: cannot find symbol
symbol : class Color
location: class GUIPanel
private static Color randomColor() {
^
/tmp/18328/GUIPanel.java:3: cannot find symbol
symbol : class DrawingArea
location: class GUIPanel
private DrawingArea left = new DrawingArea();
^
/tmp/18328/GUIPanel.java:4: cannot find symbol
symbol : class DrawingArea
location: class GUIPanel
private DrawingArea rite = new DrawingArea();
^
tmp/18328/Inventory.java:12: incompatible types
found : Fish[]
required: Product[]
Product product[] = new Fish[MAXIMUM_ITEMS];
^
/tmp/18328/Inventory.java:22: non-static variable product cannot be referenced from a static context
product[0] = new Fish(0, "Fancy Tailed Guppy",25, 4.99);
^
/tmp/18328/Inventory.java:22: cannot find symbol
symbol : constructor Fish(int,java.lang.String,int,double)
location: class Fish
product[0] = new Fish(0, "Fancy Tailed Guppy",25, 4.99);
^
/tmp/18328/Inventory.java:23: non-static variable product cannot be referenced from a static context
product[1] = new Fish(1, "Huma Huma Picasso Trigger",2, 35.99);
^
/tmp/18328/Inventory.java:23: cannot find symbol
symbol : constructor Fish(int,java.lang.String,int,double)
location: class Fish
product[1] = new Fish(1, "Huma Huma Picasso Trigger",2, 35.99);
^
Total there are 42 errors, but I won't post them all here unless it is needed.

Here is all of my code:
CODE

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Arrays;

public class Inventory extends GUIFrame
{
  
        
        public static final int MAXIMUM_ITEMS = 10;
        Product product[] = new Fish[MAXIMUM_ITEMS];

        public Inventory() {
                buildInventory();
                sortInventoryByName();
                displayInventory();
        }

        public static void buildInventory() {

                product[0] = new Fish(0, "Fancy Tailed Guppy",25, 4.99);
                product[1] = new Fish(1, "Huma Huma Picasso Trigger",2, 35.99);
                product[2] = new Fish(2, "Black Durgeon Trigger",1, 99.99);
                product[3] = new Fish(3, "Niger Trigger",2, 45.99);
                product[4] = new Fish(4, "Jack Dempsey Cichlid",4, 19.99);
                product[5] = new Fish(5, "Midas Cichlid",1, 69.99);
                product[6] = new Fish(6, "Neon Tetra",25, 2.99);
                product[7] = new Fish(7, "Convict Cichlid",2, 15.99);
                product[8] = new Fish(8, "Oscar", 4, 37.99);
                product[9] = new Fish(9, "Albino Cory Cat",1, 29.99);
                }
                
   public void displayInventory() {
        
        double totalPrice = 0.0;
        
        for(int i = 0; i < product.length; i++) {
            System.out.println("Number:      " + product[i].getNumber());
            System.out.println("Name:        " + product[i].getName());
            System.out.println("Quantity:    " + product[i].getQuantity());
            System.out.println("Price:       " + product[i].getPrice());
            System.out.println("Item Value:  " +
                    product[i].getQuantity() * product[i].getPrice());
            System.out.println();
            
            totalPrice += product[i].getPrice();
        }
        
        System.out.println("Grand Total: " + totalPrice);
    }
    
    public void sortInventoryByName() {
      Arrays.sort(product);
    }
}


CODE
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;


public class GUIFrame
{
    public static void main( String args[] )
    {
        JFrame frame = new JFrame("Inventory Of Fish");

        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

        //This is an empty content area in the frame
        JLabel jlbempty = new JLabel("");
        jlbempty.setPreferredSize(new Dimension(400, 400));
        frame.getContentPane().add(jlbempty, BorderLayout.CENTER);

        frame.pack();
        frame.setVisible(true);
    }
}


CODE
public class GUIPanel extends GUIFrame {

    private DrawingArea left = new DrawingArea();
    private DrawingArea rite = new DrawingArea();

    
    public GUIPanel() {
        left.setBackground(Color.white);
        rite.setBackground(Color.black);

        JButton changeColorBtn = new JButton("Randomize Colors");
        changeColorBtn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    left.setMyColor(randomColor());
                    rite.setMyColor(randomColor());
                }
            });

GUIPanel content = new GUIPanel();
        content.setLayout(new BorderLayout(5, 5));
        content.add(changeColorBtn, BorderLayout.NORTH);
        content.add(left, BorderLayout.WEST);
        content.add(rite, BorderLayout.EAST);

        
        setContentPane(content);
        setDefaultCloseOperation(GUIFrame.EXIT_ON_CLOSE);
        setTitle("Demo Drawing");
        setLocationRelativeTo(null);  
        pack();
    }
private static Color randomColor() {
        return new Color((int) (Math.random() * 256),  // Red
                         (int) (Math.random() * 256),  // Green
                         (int) (Math.random() * 256)); // Blue
    }


  
    public static void main(String[] args) {
        GUIFrame window = new GUIPanel();
        window.setVisible(true);
    }
}


Thanks for any help I recieve! I feel as though I am running around in circles!! blink.gif
User is offlineProfile CardPM
+Quote Post

mudpuppy
RE: Java Inventory GUI
20 Aug, 2007 - 06:41 PM
Post #4

New D.I.C Head
*

Joined: 13 Aug, 2007
Posts: 17


My Contributions
Ok, I've been working on my codes and have the errors down to just one. I assume that when I fix it, the compiler will spit out about a ton more errors! lol If anyone is avalible, please help me with this. I just wnt to get this part of the assignment over with and turn it in so I can recieve some ort of grade and then move on to the next part that is due on Sunday. Thank you to anyone willing to tackle my code!

CODE
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;


public class GUIFrame
{
    public static void main( String args[] )
    {
        GUIFrame frame = new GUIFrame("Inventory Of Fish");

        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

        //This is an empty content area in the frame
        JLabel jlbempty = new JLabel("");
        jlbempty.setPreferredSize(new Dimension(400, 400));
        frame.getContentPane().add(jlbempty, BorderLayout.CENTER);

        frame.pack();
        frame.setVisible(true);
    }
}


CODE
public class GUIPanel extends GUIFrame {

    public DrawingArea left = new DrawingArea();
    public DrawingArea rite = new DrawingArea();

    
    public GUIPanel() {
        left.setBackground(Color.white);
        rite.setBackground(Color.black);

        JButton changeColorBtn = new JButton("Randomize Colors");
        changeColorBtn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    left.setMyColor(randomColor());
                    rite.setMyColor(randomColor());
                }
            });

GUIPanel content = new GUIPanel();
        content.setLayout(new BorderLayout(5, 5));
        content.add(changeColorBtn, BorderLayout.NORTH);
        content.add(left, BorderLayout.WEST);
        content.add(rite, BorderLayout.EAST);

        
        setContentPane(content);
        setDefaultCloseOperation(GUIFrame.EXIT_ON_CLOSE);
        setTitle("Inventory of Fish");
        setLocationRelativeTo(null);  
        pack();
    }
public static Color randomColor() {
        return new Color((int) (Math.random() * 256),  // Red
                         (int) (Math.random() * 256),  // Green
                         (int) (Math.random() * 256)); // Blue
    }


  
    public static void main(String[] args) {
        GUIFrame window = new GUIPanel();
        window setVisible(true);
    }
}


Oops, forgot to put my error on here! Sorry!
/tmp/14279/GUIPanel.java:42: ';' expected
window setVisible(true);
^
1 error


This post has been edited by mudpuppy: 20 Aug, 2007 - 07:32 PM
User is offlineProfile CardPM
+Quote Post

PennyBoki
RE: Java Inventory GUI
22 Aug, 2007 - 04:13 PM
Post #5

system("revolution");
Group Icon

Joined: 11 Dec, 2006
Posts: 2,010



Thanked: 7 times
Dream Kudos: 500
Expert In: Java,C++,C

My Contributions
shouldn't it be
CODE
window.setVisible(true);
like you did in the code before that one.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 12:15AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month