I want to know how to create a label that contains two icons, one on each side and set it as the title bar for the form element (LWUIT widgets).
Asked
Active
Viewed 1,228 times
4
-
can you plz explain your question in little more detail – Muhammad Saqib Mar 16 '12 at 12:55
3 Answers
3
You can just add a component to the north portion of the screen which is the recommended way that will work properly and won't break for newer versions of LWUIT/Codename One.
When you don't set a title it will just work and you can give it the Title UIID. LWUIT 1.5 and newer have a TitleArea container but I suggest you stay away from it since CodenameOne customizes it quite allot for iOS/Android 4.x etc.

Shai Almog
- 51,749
- 5
- 35
- 65
-
If I add a component to the north portion of the screen, when scrolling, the component will move out of the screen, and I don't want this to happen. – David-mu Mar 22 '12 at 09:54
-
1form.setScrollable(false); containerInCenterPosition.setScrollableY(true); – Shai Almog Mar 22 '12 at 13:14
3
Form has a function to get a titleArea then you can put some components what you want.
Form f = new Form();
Container c = f.getTitleArea();
Label iconLabel1 = new Label("leftIcon");//using Image
Label iconLabel2 = new Label("rightIcon");//using Image
c.addComponent(BorderLayout.WEST, iconLabel1);
c.addComponent(BorderLayout.EAST, iconLabel2);

reddberckley
- 58
- 6

Yohan Kim
- 46
- 1
0
Use the setTitleComponent(Label title)
method.
EDIT :
Derive the Label
class and implement the paint
method where you can use the Graphics
method to draw Image
s and texts. Also set the label's text position to Label.CENTER
.

pheromix
- 18,213
- 29
- 88
- 158
-
I know how to set a label for the title of a form using 'setTitleComponent(Label title)' . My problem is that i don't know how to customize a label so that it contains two icons, one on each side and a text in the center. – David-mu Mar 19 '12 at 04:28