Thursday 8 November 2012

LWUIT Theme in J2me Application(Nokia)

If  you want to apply Themes to Your Nokia Application ,You can use the below Code:

1)Create a Project with the Name LWUITTheme
2)Create a Midlet class
3)Copy the LWUITtheme.res file to your "res" folder(Download  LWUITtheme.res  form Click Here )
Note: To Successfully Execute this Application you require LWUIT Jar file(You can get this jar file from Click Here )

PackageStructure:

ThemeMidlet :
import com.sun.lwuit.Display;import com.sun.lwuit.Form;
import com.sun.lwuit.List;
import com.sun.lwuit.plaf.UIManager;
import com.sun.lwuit.util.Resources;
import javax.microedition.midlet.MIDlet;
public class ThemeMidlet extends MIDlet {
    private Form form;
    private List list;
    private Object[] items;
    public ThemeMidlet() {
        Display.init(this);
        items = new Object[]{"Item1", "Item2", "Item3", "Item3", "Item4", "Item5"};
        list = new List(items);
        form = new Form("LWUIT Theme");
        //for the list to cover the entire screen width we need to set it    
        //list.setPreferredW(form.getWidth());
    }
   public void startApp() {
        try {
            Resources res = Resources.open("/res/LWUITtheme.res");
            UIManager.getInstance().setThemeProps(res.getTheme("LWUITDefault"));
            form.addComponent(list);
            form.show();
        } catch (Exception e) {
        }
    }
    public void pauseApp() {
    }
    public void destroyApp(boolean unconditional) {
    }
   }
OutPut:





No comments:

Post a Comment