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
Code :
/**
* 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
Code :
/** 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
Code :
/**
* 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;
}
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?