Codename one separate class along with statemachine class

雨燕双飞 提交于 2020-01-04 06:50:50

问题


I am working a project in gui builder..As my project is growing bigger and bigger, i find it hard to search a particular forms and methods all in a statemachine class. so i wanted to create a separate class for each form. but since the gui builder create the methods automatically in statemachine which extends statemachineBase class. how can i use separate class for separate gui forms so that they automatically create methods in the designated class. for instance when i click before show event of form named "NextPage", the gui builder automatically create beforeNextPage method in NextPage class instead of statemachine. I did the followings but lost in the process..

NextPage.class

public class NextPage extends StateMachine {
    private ArrayList<Map<String, Object>> mData;
    private ArrayList<Map<String, Object>> moreData;

public NextPage(String resFile) {
        super(resFile);
    }

@Override
    public void beforeNextPage(Form f) {
     //.........
}
}

回答1:


Forms generated by GUI Builder cannot be separated from StateMachineBase into different Classes.

What I do personally is create a form in GUI to get the right Look and Feel and then create a replica of that form in code, then delete the one on GUI Builder once I'm satisfied with the code version. It makes my projects well organized and easy to debug.

BeforeShow() would be handle while the form class is loading and to do anything in PostShow(), just do this:

    this.addShowListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            removeShowListener(this);
            //Your postShow() codes here.
            revalidate();
        }
    });

Forms created in code are light-weight and more customizable than GUI forms.



来源:https://stackoverflow.com/questions/34153710/codename-one-separate-class-along-with-statemachine-class

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!