开发者

Java return Component

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜