Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Method is not applicable for the arguments

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Method is not applicable for the arguments

    I need this window to read the contents of a file and display them when it opens. This is the code I have for it. My problem is that on the getItems() eclipse is telling me that the method is not applicable for the arguments. Eclipse tells me to add arguments to match what is in my interface which would be "String category, float amount, String color, String type" but if I do that it yells as me about those being invalid. The only thing it likes, is if I fill the arguments in with "getTitle(), getOpacity(), getTitle(), getTitle()" which makes no sense and when an just results in a blank window anyway. I am assuming that the error has to be in how I wrote the interface or implementation?

    Code for the jframe

    	/**
    	 * Create the window frame.
    	 */
    	public ShowAllInventory() throws ItemNotFoundException {
    		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		setBounds(100, 100, 450, 300);
    		contentPane = new JPanel();
    		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    		contentPane.setLayout(new BorderLayout(0, 0));
    		setContentPane(contentPane);
     
    		/**
    		 * Load the inventory
    		 */
     
    		IItemsService service = new ItemsServiceImpl();
    		try {
    			Items items = service.getItems();
    		} catch (ItemNotFoundException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    			System.out.println ("Items Not Found");
    		}
     
    	}

    code for the interface

        /** Retrieves items from the database
        	 * 
        	 * @param category
        	 * @param amount
        	 * @param color
        	 * @param type
        	 * @return
        	 * @throws ItemNotFoundException 
        	 */
        	public Items getItems (String category, float amount, String color, String type) throws ItemNotFoundException;
     
        }

    Code for the implementation

    	/**
    	 * Getting Items from the database
    	 * @return 
    	 * @throws ItemNotFoundException
    	 */
    	@Override
    	public Items getItems(String category, float amount, String color,
    			String type) throws ItemNotFoundException {
     
    		Items items = (Items) null;
    		try {
    			ObjectInputStream input = new
    					ObjectInputStream (new FileInputStream("itemdatabase"));
    			items = (Items)input.readObject();
    			input.close();
    		} catch (IOException ioe) {
    			System.out.println ("IOException");
    		} catch (ClassNotFoundException e) {
    			e.printStackTrace();
    		}		
    		return items;		
    	}


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,412
    Thanks
    49
    Thanked 2,214 Times in 2,187 Posts

    Default Re: Method is not applicable for the arguments

    Why are you arguing with the compiler? It is telling you that the getItems() method takes some arguments that you must code if you want to use it.
    Why don't you either change how you are calling the method to include the arguments
    or change the definition of the method so it has no arguments.
    Or something in between?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 1
    Last Post: April 19th, 2012, 02:46 AM
  2. execute bat file with arguments
    By kafka82 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: August 6th, 2011, 01:20 PM
  3. Tiny problem with arguments.
    By Melawe in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 15th, 2011, 02:26 PM
  4. Problem with inheritence? arguments not applicable
    By rbk in forum Object Oriented Programming
    Replies: 2
    Last Post: March 29th, 2011, 09:37 AM
  5. command line arguments
    By rizla in forum Member Introductions
    Replies: 3
    Last Post: December 12th, 2010, 10:14 PM

Tags for this Thread