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