I have a problem with my program. I'm working on the gui, and I can't get it to change the view with this line in the class MenuController:
currentComponent = timeRegContr开发者_如何学JAVAoller.getView().userRegisterTime(user);
But I have similar lines, that works just fine. currentComponent an Component that is the current view that the program is showing.
timeRegController.getView() returns a TimeRegistrationPanel called view.
In the class TimeRegistrationPanel I have the following method:
public Component userRegisterTime(User user) {
JPanel window = new JPanel(new BorderLayout());
return window;
}
My program says that the problem lies in the line:
currentComponent = timeRegController.getView().userRegisterTime(user);
because userRegisterTime() is undefined for the type Component.
You need to cast the return value to your TimeRegistrationPanel
class.
Make sure getView() returns TimeRegistrationPanel.
精彩评论