James Harpe
James Harpe

Reputation: 4345

LWUIT Resource Editor: Creating a Button

I think I need to create a button style in the LWUIT Resource Editor since I'm not able to change the background color and other properties of buttons in my J2ME app. I have no idea how to accomplish this, and all the tutorials and examples are very confusing and unhelpful.

So if I want to have a button with a custom style, how do I go about creating this in the resource editor, and then how do I access this in my app?

Thanks!

Upvotes: 0

Views: 359

Answers (1)

dic19
dic19

Reputation: 17971

Suggested readings: Using Styles, Themes, and Painters with LWUIT and LWUIT Tutorial - Styles and Themes to understand the style concept.

First step you need to create a new theme. Open LWUIT resource editor and then create a new theme:

enter image description here

Then you have to add a button style for Unselected, Selected, Pressed and Disabled styles as you wish (no need to do it for all of these just which ones needed, most commonly Unselected and Pressed):

enter image description here

enter image description here

Save your theme in a .res file (let say MyTheme.res) clicking in Save option (please note a single .res file may contain several themes). Copy MyTheme.res file into your project, let say in res folder and please don't forget to add this folder in project properties so when you generate your jar file it will be included. Finally load your theme like this:

Resources r = Resources.open("/res/MyTheme.res");
UIManager.getInstance().setThemeProps(r.getTheme("MyTheme"));

Upvotes: 1

Related Questions