I am having trouble correcting the errors in my application to get it to compile. My deadline for this app is Oct. 1. I would appreciate if a fresh set of eyes could look at my code and see where I'm going wrong. Thanks

import java.util.Arrays;
import javax.swing.*; 
import java.awt.*;
import java.awt.event.*;
 
 
 
public class Inventory {

 {
 	
 final int arrayLength = 4;
 int productNum[] = new int[ arrayLength];
 String productName[] = new String[] { "X-Men" , "LOST", "Fragile Rock", "KiKi's Delivery Service" };
 int productUnits[] = { 25, 20, 40, 50 };
 double productPrice[] = { 10.00, 25.00, 4.00, 9.99 };
 double productValue[] = new double[ arrayLength ];
 
 
 sortProductName( productName );
 
            for ( int counter = 0 ; counter < productNum.length; counter++ );
            }    
  	   

            public static void outputTotalValue( double productValue[] )
 
            {      
                        double totalProductValue = 0;
  
                        for ( int counter = 0; counter < productValue.length; counter++ )
 
                        totalProductValue += productValue[ counter ]; 
                      }
 
            public static void sortProductName( String productName[] )
            {
             Arrays.sort( productName );
            }
         
 
   public class Rating extends Inventory
   {
    private boolean ratingG, ratingPg, ratingR;
    
    public Rating(String color) {
     ratingG = false;
     ratingPg = true;
     ratingR = false;
    }
  //already has method to calculate the value of the inventory of a product
  
  
            }
public int numClicks = 0;
     JLabel label = new JLabel("Item number");
     JLabel label1 = new JLabel("Name of product");
   	 JLabel label2 = new JLabel("Number of units in stock");
   	 JLabel label3 = new JLabel("Price of unit");
   	 JLabel label4 = new JLabel("Value of product inventory");
   	 JLabel label5 = new JLabel("Product rating");
   	 JLabel label6 = new JLabel("Restocking fee");
   	 JLabel label7 = new JLabel("Entire inventory value");
    
    final static String LOOKANDFEEL = null;
 
    public Component createComponents() {
        JButton button = new JButton("Click me to see products");
        button.setMnemonic(KeyEvent.VK_I);
        button.addActionListener(this);
        label.setLabelFor(button);
        
        JButton button = new JButton1("First");
        button.setMnemonic(KeyEvent.VK_I);
        button.addActionListener(this);
        label.setLabelFor(button1);
        
        JButton button = new JButton2("Next");
        button.setMnemonic(KeyEvent.VK_I);
        button.addActionListener(this);
        label.setLabelFor(button2);
        
        JButton button = new JButton3("Previous");
        button.setMnemonic(KeyEvent.VK_I);
        button.addActionListener(this);
        label.setLabelFor(button3);
 
 		JButton button = new JButton4("Last");
        button.setMnemonic(KeyEvent.VK_I);
        button.addActionListener(this);
        label.setLabelFor(button4);
        
        JPanel pane = new JPanel(new GridLayout(0, 1));
        pane.add(button);
        pane.add(button1);
        pane.add(button2);
        pane.add(button3);
        pane.add(button4);
        pane.add(label);
        pane.add(label1);
        pane.add(label2);
        pane.add(label3);
        pane.add(label4);
        pane.add(label5);
        pane.add(label6);
        pane.add(label7);
        pane.setBorder(BorderFactory.createEmptyBorder(
                                        30, //top
                                        30, //left
                                        20, //bottom
                                        30) //right
                                        );
 
        return pane;
    }
 
    public void actionPerformed(ActionEvent e){
    	
    	label.setText(productName[0]);
    	label1.setText(productName[1]);
    	label2.setText(productName[2]);
    } 
    
    	
   
 {
 final int arrayLength = 4;
 int productNum[] = new int[ arrayLength];
 String productName[] = new String[] { "X-Men" , "LOST", "Fragile Rock", "KiKi's Delivery Service" };
 int productUnits[] = { 25, 20, 40, 50 };
 double productPrice[] = { 10.00, 25.00, 4.00, 9.99 };
 double productValue[] = new double[ arrayLength ];
    
      
    
       }
    }
 
  public static void initLookAndFeel() {
       
        String lookAndFeel = null;
 
        if (LOOKANDFEEL != null) {
            if (LOOKANDFEEL.equals("Metal")) {
                lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
            } else if (LOOKANDFEEL.equals("System")) {
                lookAndFeel = UIManager.getSystemLookAndFeelClassName();
            } else if (LOOKANDFEEL.equals("Motif")) {
                lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
            } else if (LOOKANDFEEL.equals("GTK+")) { //new in 1.4.2
                lookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
            } else {
                System.err.println("Unexpected value of LOOKANDFEEL specified: "
                                   + LOOKANDFEEL);
                lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
            }
 
            try {
                UIManager.setLookAndFeel(lookAndFeel);
            } catch (ClassNotFoundException e) {
                System.err.println("Couldn't find class for specified look and feel:"
                                   + lookAndFeel);
                System.err.println("Did you include the L&F library in the class path?");
                System.err.println("Using the default look and feel.");
            } catch (UnsupportedLookAndFeelException e) {
                System.err.println("Can't use the specified look and feel ("
                                   + lookAndFeel
                                   + ") on this platform.");
                System.err.println("Using the default look and feel.");
            } catch (Exception e) {
                System.err.println("Couldn't get specified look and feel ("
                                   + lookAndFeel
                                   + "), for some reason.");
                System.err.println("Using the default look and feel.");
                e.printStackTrace();
            }
        }

    
    private static void createAndShowGUI() {
       
        initLookAndFeel();
 
        JFrame.setDefaultLookAndFeelDecorated(true);
 
        JFrame frame = new JFrame("DVD Inventory");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
        Inventory app = new Inventory();
        Component contents = app.createComponents();
        frame.getContentPane().add(contents, BorderLayout.CENTER);
 
        frame.pack();
        frame.setVisible(true);
       
    }  
 
     	public static void main(String[] args) {
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
  
	public class ImageTest extends GUIFrame {
		public ImageTest() {
			super("Image Test");
			setSize(65,88);
			setBackground(Color.red);
		}
	
		public static void main(String args[]) {
			new ImageTest().setVisible(true);
		}
	
		public void paint(Graphics g) {
			Imageimg = Toolkit.getDefaultToolkit().getImage("dvd.jpg");
			g.drawImage(img, 0, 0, 64, 88, this);
		}
	}     
 }

Care to tell us the errors you're receiving?


Took a glance at it, oh where do I even begin.

What's this?
sortProductName( productName );

Unless its returning a value and assigning it to something, you have to put it inside a method or constructor.

This, too, can not be outside a method. It also never performs any action because of the semicolon after the declaration.

for ( int counter = 0 ; counter < productNum.length; counter++ );

And just after that line, you put the closing bracket for hte class, making the following methods belong to nothing.

Actually, you have a ton of problems with your curly brackets. Many are out of place, some appear just to be the wrong direction of bracket, and some are just plain missing. Go through your whole program, indent everything evenly, and look at those brackets carefully.


Also, before you can add "this" as an ActionListener for the buttons, the class must implement the ActionListener interface.

You're also trying to declare "button" multiple times. Plus you're calling classes that do not exist.

JButton1, JButton2, JButton3

It should be:
JButton button1 = new JButton("First");
JButton button2 = new JButton("Next");
JButton button3 = new JButton("Previous");


By the way, why are you making all your methods static anyway?

Also, put the ImageTest class in a separate file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.