arguments don't match datatype of constructor

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Freckles
    New Member
    • May 2007
    • 9

    #16
    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

    • sandyw
      New Member
      • Mar 2007
      • 122

      #17
      Originally posted by Freckles
      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
      I think you better read up on swings...
      couple of things you have some of your codes in the wrong order, and you are not using them correctly.
      you also need to add(item),
      setVisible(true )
      Public static void main (String[] argements){
      InventoryGui inventoryGui = new InventoryGui();
      }

      Sandy

      Comment

      • Freckles
        New Member
        • May 2007
        • 9

        #18
        Here's what I added but I can still see it's wrong. Do I need to call each item[ ] ... and how do I do that if so?

        Code:
         
        public class InventoryGui extends JFrame //begin class InventoryGui
        {
        private JLabel items; // JLabel with just text 
        public InventoryGui()
        {
        setLayout( new FlowLayout() );
        items = new JLabel("text");
        add(items);
        }
        public static void main( String args[])
        {
        InventoryGui inventoryGui = new InventoryGui(); //create InventoryGui
        inventoryGui.setVisible( true ); // display frame
        inventoryGui.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); //set frame to close on exit
        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
        } //end main method
        } //end class InventoryGui

        Comment

        Working...