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);
}
}
}