ITEMS layouts

How can set corectly the desired layout for an custom item that extends CustomItem class.

I tried it both to set layout calling setLayout() method from the form that contains my item OR in my item class, to return the desired layout in the overrided method getLayout(). No one really works. In fact, I want to have an custom item that expand verticaly or that have a break line after.

Any help, I appreciate!

[428 byte] By [krysza] at [2007-11-26 19:04:44]
# 1
show us a part of your code (with code tags please)
suparenoa at 2007-7-9 20:53:48 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

All I want is 2 buttons without beeing separated at all.

Look:

class ButtonItem extends CustomItem {

int displayWidth;

public ButtonItem(String title, int width) {

this(title);

displayWidth = width;

}

protected int getMinContentHeight(){

return 10;

}

protected int getMinContentWidth(){

displayWidth;

}

protected int getPrefContentHeight(int width){

return 10;

}

protected int getPrefContentWidth(int height){

return displayWidth;

}

public void paint() {

// draw some stuff

}

public int getLayout() {

return Item.LAYOUT_2 | Item.LAYOUT_VEXPAND;

}

}

krysza at 2007-7-9 20:53:48 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3

check out

http://developers.sun.com/techtopics/mobility/midp/articles/customitems/index.html

to see how implement CustomItem...

it seems that the layout should be defined in your CustomItem constructor...

and to answer to your question...

you should read the Form javadoc because it is in the Form layout that you define the

place of your CustomItems...

hope this help

suparenoa at 2007-7-9 20:53:48 > top of Java-index,Java Mobility Forums,Java ME Technologies...