Thanks for the tips. I still haven't been able to get the 2-decimal point to work. But I've moved on to bigger and better and things for the moment.... I just have to make my items show up in a frame one at a time, which I've managed to figure out. But I want the entire application to close when I finish going through each window. I'm trying to use EXIT_ON_CLOSE, but it's not working properly. Can anyone tell me what I'm missing? This assignment is due tonight so any quick help would be GREATLY appreciated!!
Code:
public class InventoryGui extends JFrame //begin class InventoryGui { public static void main( String args[]) { Product[] item = new Product [4]; Product item1 = new Plastic (1003182, "Polytrope TPP", 7, 1.81, "Black" ); Product item2 = new Plastic (1003296, "Polyvin PVC", 3, 1.72, "Light Neutral" ); Product item3 = new Plastic (1013972, "Polyvin PVC-DC", 5, 1.15, "Beige" ); Product item4 = new Plastic (1019392, "Invision", 9, 1.57, "Medium Dark Pewter" ); item[0] = item1; item[1] = item2; item[2] = item3; item[3] = item4; double all = 0.00; for (int total= 0; total < 4;total++) { all = all + item[total].value(); } for (Product myProduct: item) { System.out.println(myProduct); System.out.println(); } System.out.println("The Value of all items combined is: $"+all); JOptionPane.showMessageDialog( null, "The first item is: "+item1, "ASI Product Inventory", JOptionPane.PLAIN_MESSAGE ); //display first item JOptionPane.showMessageDialog( null, "The second item is: "+item2, "ASI Product Inventory", JOptionPane.PLAIN_MESSAGE ); //display second item JOptionPane.showMessageDialog( null, "The third item is: "+item3, "ASI Product Inventory", JOptionPane.PLAIN_MESSAGE ); //display third item JOptionPane.showMessageDialog( null, "The fourth item is: "+item4, "ASI Product Inventory", JOptionPane.PLAIN_MESSAGE ); //display fourth item JOptionPane.showMessageDialog( null, "The value of the entire inventory is: "+all, "ASI Product Inventory", JOptionPane.PLAIN_MESSAGE ); //display inventory value total InventoryGui inventoryGui = new InventoryGui(); //create InventoryGui inventoryGui.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); //set frame to close on exit } //end main method } //end class InventoryGui
Comment