How can I change the size of a CustomItem
inside a form in J2ME? I created a CustomItem
(derived class of javax.microedition.lcdui.CustomItem
) and placed it inside a form (of derived class of javax.microedition.lcdui.Form
). After some event triggers, I want to ch开发者_如何学Cange the CustomItem
's height and width. How should I change my code?
In MIDP, CustomItem is rendered by the enclosing container, the Form. MIDP doesn't provide a way to notify it's parent that it's size has changed; so this behavior has to be handcrafted in your code.
Suppose your event is fired upon the user pressing OK (FIRE), then you will need to call either repaint() OR repaint(x,y,w,h). This repaint call causes either entire CustomItem to be painted or just the rectangular portion. This inturn calls your paint() method (of CustomItem) where you can draw a larger sized component.
I got the solution. We should create a new object for the new CustomItem with new properties.Then delete the existing CustomItem from the form and add the new CustomItem inside the form.
精彩评论