Sunday, December 16, 2012

BlackBerry Custom Menu

We can create a customized menu in blackberry , however i seen very less times the use of customization in menu . however we can use it an can use all the effects provided by the API . You can use the following code to achieve the Menu customization :)




import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.FontFamily;
import net.rim.device.api.ui.FontManager;
import net.rim.device.api.ui.XYEdges;
import net.rim.device.api.ui.decor.Background;
import net.rim.device.api.ui.decor.BackgroundFactory;
import net.rim.device.api.ui.decor.Border;
import net.rim.device.api.ui.decor.BorderFactory;

public class MenuUtility {
Background _menuBackground, particular;
Border border;
Font font;
FontFamily fontFamily;
public MenuUtility(){}


public Background menuBackground(int x){

_menuBackground =

BackgroundFactory.createSolidBackground(x);
return _menuBackground;
}
public Background menuCaretBackground(int x){
particular =

BackgroundFactory.createSolidBackground(x);
return particular;
}

public Border menuBorder(){

border=BorderFactory.createBitmapBorder(
new XYEdges(8,8,8,8), Bitmap.getBitmapResource("menubg.png"));
return border;
}



public Font menuFont(int x) {

if (FontManager.getInstance().load("Insight_screen_Regular.ttf", "Insight_screen_Regular", FontManager.APPLICATION_FONT) == FontManager.SUCCESS) 
       {
           try 
           {
            fontFamily= FontFamily.forName("Insight_screen_Regular");
            font = fontFamily.getFont(Font.PLAIN, x);
               
           }
           catch (ClassNotFoundException e) 
           {
               System.out.println(e.getMessage());
           }
       }

return font;

}
}

No comments:

Post a Comment