代号一个单独的类以及状态机类 [英] Codename one separate class along with statemachine class

查看:77
本文介绍了代号一个单独的类以及状态机类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在gui builder中工作一个项目。随着我的项目越来越大,我发现很难在statemachine类中搜索所有特定的形式和方法。所以我想为每种形式创建一个单独的类。但是由于gui构建器会在statemachine中自动创建方法,从而扩展了statemachineBase类。我如何为单独的GUI表单使用单独的类,以便它们在指定的类中自动创建方法。例如,当我单击名为 NextPage的表单的show event之前时,gui构建器将在NextPage类而不是statemachine中自动创建beforeNextPage方法。我执行了以下操作,但在此过程中迷路了。.

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

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) {
     //.........
}
}


推荐答案

GUI Builder生成的表单不能与StateMachineBase分为不同的类。

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

我个人要做的是在GUI中创建表单以获取正确的外观,然后在代码中创建该表单的副本,然后删除我对代码版本感到满意后,就可以在GUI Builder上使用它了。

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()将在表单类加载时进行处理,并在PostShow()中执行任何操作,只需执行此操作即可。 :

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

用代码创建的表单比GUI表单轻巧且可自定义。

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

这篇关于代号一个单独的类以及状态机类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆