문제

I'm trying to inherit a class that I made in the GUI Resource Editor of Lwuit to extend some functionality. I want to do something like:

public class MyCustomGUIForm extend CustomGUIForm{...}

Where CustomGUIForm its a Form that I create in the Resource Editor. Any idea??

도움이 되었습니까?

해결책

I am going to explain you what I do for extend some functionallity in the Formsthat I create with the Resource Editor. When you build a NetBeansProject with the Resource Editor, you get a StateMachine class wich allows you to modify/add some aspects of your apps navigation. In the StateMachine class you can find a lot of methods related to the elements that you create in the Resource Editor.

For example:

You create a Form in the Resource Editor, called CustomGUIForm. After you save the .res, you should find some methods in the StateMachine class called beforeCustomGUIForm postCustomGUIForm and exitGUIForm, with this methods you can use the Form and add some functionality. You can observe that in StateMachine there are other methods for Commands that you build in the Resource Editor, ActionListeners, etc etc. Take a look to the overriden methods for the StateMachine, they could be usefull for you.

Let me know if you have more questions

다른 팁

While jmunoz gave the better answer for this just for completeness you can indeed inherit and override any component created by the resource editor.

In your Statemachine override:

protected Component createComponentInstance(String componentType, Class cls) {
     if(cls == Form.class) {
           return new MyFormInstance();
     }
     return null;
}

There is one drawback in this approach, all forms will now be MyFormInstance. This is or usable for some use cases and not so much for others.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top