Below is the code I am having a issue with. I created a instance of a class AddItemView, inside StartUpMenuController. I then passed it into the class, the main method is below showing that as well. However when I do this:
else if(e.getSource()==menu.addBtn) { new addItem(); }
I get an error, little red line on the bottom of the text. I am testing the frame at the moment to make sure it is what I want before I move on to the Controller side of it. I just want to display it and go from there. Any idea what I am doing wrong?
package mainMenu.Home.DataBase; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import addItemBtn.Home.DataBase.AddItemView; public class StartUpMenuController { StartUpMenu menu; AddItemView addItem; StartUpMenuController(StartUpMenu menu,AddItemView addItem) { this.menu = menu; this.addItem = addItem; menu.closeBtn.addActionListener(new AddListeners()); menu.reportsBtn.addActionListener(new AddListeners()); menu.findItemBtn.addActionListener(new AddListeners()); menu.addBtn.addActionListener(new AddListeners()); } class AddListeners implements ActionListener { public void actionPerformed(ActionEvent e) { try { if(e.getSource()==menu.closeBtn) { menu.frame.dispose(); } else if(e.getSource()==menu.addBtn) { new addItem(); } else if(e.getSource()==menu.reportsBtn) { } else if(e.getSource()==menu.reportsBtn) { } }catch(Exception ex) { System.out.println("There was an error "+e); } } } public static void main(String args[]) { StartUpMenu menu = new StartUpMenu(); AddItemView addItem = new AddItemView(); new StartUpMenuController(menu,addItem); } }
--- Update ---
Not sure if this is the issue but the class I am making a new instance of is in a different package. I imported the package though:
import addItemBtn.Home.DataBase.AddItemView;