Thursday, May 23, 2013

Menghilangkan Service UI0Detect atau Internet Service Detection

UI0Detect merupakan service atau program yang ada di Windows 7, untuk apanya saya juga kurang tahu, yang pasti program ini sangan mengganggu saya pada saat itu. Entah apa yang sudah saya lakukan sama laptop saya, tiba2 program ini muncul terus menerus setiap menitnya. Dan pada akhirnya program ini berhasil saya ambil gambarnya saat dia muncul. Berikut gambarnya:

Program ini muncul setiap menit, dan sangat mengganggu, kenapa, karena dia mengalihkan fokus kursos pada proses yang sedang saya lakukan. Misalnya, saat saya sedang maen game Football Manager 2011 yang menggunakan layar full, maka aplikasi ini akan me-minimize-nya.

Setelah beberapa hari yang cukup lama saya belum menemukan apa sebenarnya program ini, akhirnya saya mendapatkan juga. Ya, program ini merupakan Internet Service Detection atau UI0Detect.

Dari beberapa sumber yang saya baca program ini bukan merupakan virus atau malware, programm ini merupakan sudah ada dalam instalan Windows 7. Dan ketika ingin menhapusnya, maka tidak akan ada masalah dengan proses windows 7.

Berikut adalah cara untuk menhilangkan aplikasinya:
1. Buka 'Control Panel'
2. Double click "Administrative Services"
3. Double-click "services"
4. Cari 'Internet Service Detection' pada kolom 'Name'
5. Pilih 'Stop'
6. Pilih lagi 'Internet Service Detection'  lalu klik kanan -> Properties
7. Pada 'Startup type', pilih ‘Disable’
8. Click “OK”
Selesai.

Wednesday, May 15, 2013

Custom Password Field Blackberry

Berikut adalah code Custom Password Field Blackberry.
public class PasswordFieldCustom extends Manager {
 
    private final static int DEFAULT_LEFT_MARGIN = 1;
    private final static int DEFAULT_RIGHT_MARGIN = 1;
    private final static int DEFAULT_TOP_MARGIN = 3;
    private final static int DEFAULT_BOTTOM_MARGIN = 1;
       
    private final static int DEFAULT_LEFT_PADDING = 5;
    private final static int DEFAULT_RIGHT_PADDING = 5;
    private final static int DEFAULT_TOP_PADDING = 3;
    private final static int DEFAULT_BOTTOM_PADDING = 3;
       
    private int topMargin = DEFAULT_TOP_MARGIN;
    private int bottomMargin = DEFAULT_BOTTOM_MARGIN;
    private int leftMargin = DEFAULT_LEFT_MARGIN;
    private int rightMargin = DEFAULT_RIGHT_MARGIN;
       
    private int topPadding = DEFAULT_TOP_PADDING;
    private int bottomPadding = DEFAULT_BOTTOM_PADDING;
    private int leftPadding = DEFAULT_LEFT_PADDING;
    private int rightPadding = DEFAULT_RIGHT_PADDING;
       
    private int totalHorizontalEmptySpace = leftMargin + leftPadding + rightPadding + rightMargin;
    private int totalVerticalEmptySpace = topMargin + topPadding + bottomPadding + bottomMargin;
       
    private int minHeight = 21 + totalVerticalEmptySpace;
    private int width;
    private int height = minHeight;
    private int text_colour = 0xFF0000;
    private int border_color = 0x000066;
    private int background_color = 0xFFFF99;
    private String label = "";
    private Font headingFont = getFont().derive(Font.PLAIN, 20);
    private PasswordEditField editField;
      
    public PasswordFieldCustom(){
        super(0);
        this.label = "";
        this.width = Display.getWidth()/2;
        editField = new PasswordEditField();
        add(editField);
    }
      
    public PasswordFieldCustom(int panjang){
        super(0);
        this.label = "";
        this.width = panjang;
        editField = new PasswordEditField();
        add(editField);
    }
    
    public PasswordFieldCustom(long style){
     super(0);
     this.label = "";
     this.width = Display.getWidth()/2;
     editField = new PasswordEditField("", "", 200, style);
        add(editField);
    }
       
    protected void sublayout(int width, int height)
    {
        Field field = getField(0);
        layoutChild(field, this.width - totalHorizontalEmptySpace , this.height - totalVerticalEmptySpace);
        setPositionChild(field, leftMargin+leftPadding, topMargin+topPadding);
        setExtent(this.width, this.height);
    }   
       
    protected void paint(Graphics graphics){   
        graphics.setColor(border_color);
        graphics.drawRoundRect(leftMargin, topMargin, width - (leftMargin+rightMargin), height - (topMargin+bottomMargin), 7, 7);
        graphics.setColor(background_color);
        graphics.fillRoundRect(leftMargin+1, topMargin+1, (width - (leftMargin+rightMargin))-2, (height- (topMargin+bottomMargin))-2, 7, 7);
          
        graphics.setColor(Color.BLACK);
        if(headingFont!=null){
            setFont(headingFont);
            graphics.drawText(label, 2, 10);
        }else{
            graphics.drawText(label, 2, 7);
        }
          
        graphics.setColor(text_colour);
        PasswordEditField ef = (PasswordEditField)getField(0);
        String entireText = ef.getText();
          
        boolean longText = false;
        String textToDraw = "";
        Font font = headingFont;
        int availableWidth = width - totalHorizontalEmptySpace;
        if (font.getAdvance(entireText) <= availableWidth)
        {
            textToDraw = entireText;
        }
        else
        {
            int endIndex = entireText.length();
            for (int beginIndex = 1; beginIndex < endIndex; beginIndex++)
            {
                textToDraw = entireText.substring(beginIndex);
                if (font.getAdvance(textToDraw) <= availableWidth)
                {
                    longText = true;
                    break;
                }
            }
        }
          
        if (longText == true)
        {      
            ef.setText(textToDraw);        
            super.paint(graphics);
            ef.setText(entireText);
        }
        else
        {
            super.paint(graphics);
        }
           
    }
       
    public int getPreferredWidth(){
        return width;
    }
       
    public int getPreferredHeight(){
        return height;
    }
       
    protected boolean keyChar(char ch, int status, int time){      
       if (ch == Characters.ENTER)
       {
            return true;
       }   
       else
       {
            return super.keyChar(ch, status, time);
       }
    }
     
    protected void onUnfocus() {
       super.onUnfocus();
    }
     
    protected void onFocus(int direction) {
       super.onFocus(direction);
    }
    
    protected void drawFocus(Graphics graphics, boolean on) {
       super.drawFocus(graphics, on);
    }
  
    public String getText(){
       return ((PasswordEditField) getField(0)).getText();
    }
           
    public void setText(final String text){
       ((PasswordEditField) getField(0)).setText(text);
    }
}

Sunday, May 12, 2013

Validasi Email di Blackberry

Berikut adalah method untuk mengecek apakah email tersebut valid atau tidak, jika nilainya true maka valid dan sebaliknya.
public boolean isValidEmailAddress(String email) {
   if (email == null || email.length() == 0 || email.indexOf("@") == -1 || email.indexOf(" ") != -1) {
      return false;
   }
   int emailLenght = email.length();
   int atPosition = email.indexOf("@");

   String beforeAt = email.substring(0, atPosition);
   String afterAt = email.substring(atPosition + 1, emailLenght);

   if (beforeAt.length() == 0 || afterAt.length() == 0) {
      return false;
   }
   if (email.charAt(atPosition - 1) == '.') {
      return false;
   }
   if (email.charAt(atPosition + 1) == '.') {
      return false;
   }
   if (afterAt.indexOf(".") == -1) {
      return false;
   }
   char dotCh = 0;
   for (int i = 0; i < afterAt.length(); i++) {
      char ch = afterAt.charAt(i);
      if ((ch == 0x2e) && (ch == dotCh)) {
         return false;
      }
      dotCh = ch;
   }
   if (afterAt.indexOf("@") != -1) {
      return false;
   }

   for (int i = 0; i < afterAt.length(); i++) {
      char ch = afterAt.charAt(i);
      if (!((ch >= 0x30 && ch <= 0x39) || (ch >= 0x41 && ch <= 0x5a) || (ch >= 0x61 && ch <= 0x7a) || (ch == 0x2e) || (ch == 0x2d) || (ch == 0x5f))) {
         return false;
      }
      if ((ch == 0x2e) && (ch == dotCh)) {
         return false;
      }
      dotCh = ch;
   }

   dotCh = 0;
   for (int i = 0; i < beforeAt.length(); i++) {
      char ch = beforeAt.charAt(i);
      if (!((ch >= 0x30 && ch <= 0x39) || (ch >= 0x41 && ch <= 0x5a) || (ch >= 0x61 && ch <= 0x7a) || (ch == 0x2e) || (ch == 0x2d) || (ch == 0x5f))) {
         return false;
      }
      if ((ch == 0x2e) && (ch == dotCh)) {
         return false;
      }
      dotCh = ch;
   }
  
   if(email.startsWith(".")){
      return false;
   }
  
   int lastIndex = email.lastIndexOf('.');
   String lastToken = email.substring(lastIndex + 1);
   if (lastToken.length() >= 2) {
      if (lastToken.length() <= 3){
          //return true;
      }else{
          return false;
      }
   }else{
      return false;
   }
        
   return true;
}

Friday, May 10, 2013

Custom Email Field Blackberry

Custom Email Field ini tidak jauh berbeda dengan Custom Edit Field maupun Custom Number Field yang dah pernah saya tulis, untuk lebih jelasnya saya tuliskan code-nya.

public class EmailFieldCustom extends Manager {
 
    private final static int DEFAULT_LEFT_MARGIN = 1;
    private final static int DEFAULT_RIGHT_MARGIN = 1;
    private final static int DEFAULT_TOP_MARGIN = 3;
    private final static int DEFAULT_BOTTOM_MARGIN = 1;
       
    private final static int DEFAULT_LEFT_PADDING = 5;
    private final static int DEFAULT_RIGHT_PADDING = 5;
    private final static int DEFAULT_TOP_PADDING = 3;
    private final static int DEFAULT_BOTTOM_PADDING = 3;
       
    private int topMargin = DEFAULT_TOP_MARGIN;
    private int bottomMargin = DEFAULT_BOTTOM_MARGIN;
    private int leftMargin = DEFAULT_LEFT_MARGIN;
    private int rightMargin = DEFAULT_RIGHT_MARGIN;
       
    private int topPadding = DEFAULT_TOP_PADDING;
    private int bottomPadding = DEFAULT_BOTTOM_PADDING;
    private int leftPadding = DEFAULT_LEFT_PADDING;
    private int rightPadding = DEFAULT_RIGHT_PADDING;
       
    private int totalHorizontalEmptySpace = leftMargin + leftPadding + rightPadding + rightMargin;
    private int totalVerticalEmptySpace = topMargin + topPadding + bottomPadding + bottomMargin;
       
    private int minHeight = 21 + totalVerticalEmptySpace;
    private int width;
    private int height = minHeight;
    private int text_colour = 0xFF0000;
    private int border_color = 0x000066;
    private int background_color = 0xFFFF99;
    private String label = "";
    private Font headingFont = getFont().derive(Font.PLAIN, 20);
    private EmailAddressEditField editField;
      
    public EmailFieldCustom(){
        super(0);
        this.label = "";
        String initialValue = "";
        this.width = Display.getWidth()/2;
        editField = new EmailAddressEditField(label, initialValue);
        add(editField);
    }
      
    public EmailFieldCustom(int panjang){
        super(0);
        this.label = "";
        String initialValue = "";
        this.width = panjang;
        editField = new EmailAddressEditField(label, initialValue);
        add(editField);
    }

    public EmailFieldCustom(int panjang, long style){
        super(0);
        this.label = "";
        String initialValue = "";
        this.width = panjang;
        editField = new EmailAddressEditField(label, initialValue, 10000, style);
        add(editField);
    }
       
    protected void sublayout(int width, int height)
    {
        Field field = getField(0);
        layoutChild(field, this.width - totalHorizontalEmptySpace , this.height - totalVerticalEmptySpace);
        setPositionChild(field, leftMargin+leftPadding, topMargin+topPadding);
        setExtent(this.width, this.height);
    }   
       
    protected void paint(Graphics graphics){   
        graphics.setColor(border_color);
        graphics.drawRoundRect(leftMargin, topMargin, width - (leftMargin+rightMargin), height - (topMargin+bottomMargin), 7, 7);
        graphics.setColor(background_color);
        graphics.fillRoundRect(leftMargin+1, topMargin+1, (width - (leftMargin+rightMargin))-2, (height- (topMargin+bottomMargin))-2, 7, 7);
          
        graphics.setColor(Color.BLACK);
        if(headingFont!=null){
            setFont(headingFont);
            graphics.drawText(label, 2, 10);
        }else{
            graphics.drawText(label, 2, 7);
        }
          
        graphics.setColor(text_colour);
        EmailAddressEditField ef = (EmailAddressEditField)getField(0);
        String entireText = ef.getText();
          
        boolean longText = false;
        String textToDraw = "";
        Font font = headingFont;
        int availableWidth = width - totalHorizontalEmptySpace;
        if (font.getAdvance(entireText) <= availableWidth)
        {
            textToDraw = entireText;
        }
        else
        {
            int endIndex = entireText.length();
            for (int beginIndex = 1; beginIndex < endIndex; beginIndex++)
            {
                textToDraw = entireText.substring(beginIndex);
                if (font.getAdvance(textToDraw) <= availableWidth)
                {
                    longText = true;
                    break;
                }
            }
        }
          
        if (longText == true)
        {      
            ef.setText(textToDraw);        
            super.paint(graphics);
            ef.setText(entireText);
        }
        else
        {
            super.paint(graphics);
        }
           
    }
       
    public int getPreferredWidth(){
        return width;
    }
       
    public int getPreferredHeight(){
        return height;
    }
       
    protected boolean keyChar(char ch, int status, int time){      
       if (ch == Characters.ENTER)
       {
            return true;
       }   
       else
       {
            return super.keyChar(ch, status, time);
       }
    }
     
    protected void onUnfocus() {
       super.onUnfocus();
    }
     
    protected void onFocus(int direction) {
       super.onFocus(direction);
    }
    
    protected void drawFocus(Graphics graphics, boolean on) {
       super.drawFocus(graphics, on);
    }
  
    public String getText(){
       return ((EmailAddressEditField) getField(0)).getText();
    }
           
    public void setText(final String text){
       ((EmailAddressEditField) getField(0)).setText(text);
    }
}

Custom Number Field Blackberry

Number Field yang di maksud disini adalah field yang hanya menerima inputan berupa angka (0-9). Code-nya sebenarnya hampir sama dengan Custom EditField yang pernah saya tulis, tapi ada beberapa perbedaan.

Berikut code-nya:
import net.rim.device.api.system.Characters;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.component.BasicEditField;
  
public class NumberFieldCustom extends Manager {
      
    private final static int DEFAULT_LEFT_MARGIN = 1;
    private final static int DEFAULT_RIGHT_MARGIN = 1;
    private final static int DEFAULT_TOP_MARGIN = 3;
    private final static int DEFAULT_BOTTOM_MARGIN = 1;
       
    private final static int DEFAULT_LEFT_PADDING = 5;
    private final static int DEFAULT_RIGHT_PADDING = 5;
    private final static int DEFAULT_TOP_PADDING = 3;
    private final static int DEFAULT_BOTTOM_PADDING = 3;
       
    private int topMargin = DEFAULT_TOP_MARGIN;
    private int bottomMargin = DEFAULT_BOTTOM_MARGIN;
    private int leftMargin = DEFAULT_LEFT_MARGIN;
    private int rightMargin = DEFAULT_RIGHT_MARGIN;
       
    private int topPadding = DEFAULT_TOP_PADDING;
    private int bottomPadding = DEFAULT_BOTTOM_PADDING;
    private int leftPadding = DEFAULT_LEFT_PADDING;
    private int rightPadding = DEFAULT_RIGHT_PADDING;
       
    private int totalHorizontalEmptySpace = leftMargin + leftPadding + rightPadding + rightMargin;
    private int totalVerticalEmptySpace = topMargin + topPadding + bottomPadding + bottomMargin;
       
    private int minHeight = 21 + totalVerticalEmptySpace;
    private int width;
    private int height = minHeight;
    private int text_colour = 0xFF0000;
    private int border_color = 0x000066;
    private int background_color = 0xFFFF99;
    private String label = "";
    private Font headingFont = getFont().derive(Font.PLAIN, 20);
    private BasicEditField editField;
      
    public NumberFieldCustom (){
        super(0);
        this.label = "";
        this.width = Display.getWidth()/2;
        editField = new BasicEditField(BasicEditField.FILTER_NUMERIC);
        add(editField);
    }
      
    public NumberFieldCustom (int panjang){
        super(0);
        this.label = "";
        this.width = panjang;
        editField = new BasicEditField(BasicEditField.FILTER_NUMERIC);
        add(editField);
    }
       
    protected void sublayout(int width, int height)
    {
        Field field = getField(0);
        layoutChild(field, this.width - totalHorizontalEmptySpace , this.height - totalVerticalEmptySpace);
        setPositionChild(field, leftMargin+leftPadding, topMargin+topPadding);
        setExtent(this.width, this.height);
    }   
       
    protected void paint(Graphics graphics){   
        graphics.setColor(border_color);
        graphics.drawRoundRect(leftMargin, topMargin, width - (leftMargin+rightMargin), height - (topMargin+bottomMargin), 7, 7);
        graphics.setColor(background_color);
        graphics.fillRoundRect(leftMargin+1, topMargin+1, (width - (leftMargin+rightMargin))-2, (height- (topMargin+bottomMargin))-2, 7, 7);
          
        graphics.setColor(Color.BLACK);
        if(headingFont!=null){
            setFont(headingFont);
            graphics.drawText(label, 2, 10);
        }else{
            graphics.drawText(label, 2, 7);
        }
          
        graphics.setColor(text_colour);
        BasicEditField ef = (BasicEditField)getField(0);
        String entireText = ef.getText();
          
        boolean longText = false;
        String textToDraw = "";
        Font font = headingFont;
        int availableWidth = width - totalHorizontalEmptySpace;
        if (font.getAdvance(entireText) <= availableWidth)
        {
            textToDraw = entireText;
        }
        else
        {
            int endIndex = entireText.length();
            for (int beginIndex = 1; beginIndex < endIndex; beginIndex++)
            {
                textToDraw = entireText.substring(beginIndex);
                if (font.getAdvance(textToDraw) <= availableWidth)
                {
                    longText = true;
                    break;
                }
            }
        }
          
        if (longText == true)
        {      
            ef.setText(textToDraw);        
            super.paint(graphics);
            ef.setText(entireText);
        }
        else
        {
            super.paint(graphics);
        }
           
    }
       
    public int getPreferredWidth(){
        return width;
    }
       
    public int getPreferredHeight(){
        return height;
    }
       
    protected boolean keyChar(char ch, int status, int time){      
       if (ch == Characters.ENTER)
       {
            return true;
       }   
       else
       {
            return super.keyChar(ch, status, time);
       }
    }
     
    protected void onUnfocus() {
       super.onUnfocus();
    }
     
    protected void onFocus(int direction) {
       super.onFocus(direction);
    }
    
    protected void drawFocus(Graphics graphics, boolean on) {
       super.drawFocus(graphics, on);
    }
  
    public String getText(){
       return ((BasicEditField) getField(0)).getText();
    }
           
    public void setText(final String text){
       ((BasicEditField)getField(0)).setText(text);
    }
}

Wednesday, May 08, 2013

Custom EditField di Blackberry

EditField di Blackberry secara default di tampilkan dalam bentuk yang sangat kaku (mungkin ini pendapat pribadi saya), ia akan memakai semua width dari resolusi. Sehingga jika kita ingin menambah button di samping EditField maka button tersebut tidak akan tampil. Agar bisa tampil maka perlu untuk melakukan custom terhadap EditField tersebut.
Berikut code Custom EditField.


import net.rim.device.api.system.Characters;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.component.EditField;

public class TextFieldCustom extends Manager {
    
    private final static int DEFAULT_LEFT_MARGIN = 1;
    private final static int DEFAULT_RIGHT_MARGIN = 1;
    private final static int DEFAULT_TOP_MARGIN = 3;
    private final static int DEFAULT_BOTTOM_MARGIN = 1;
     
    private final static int DEFAULT_LEFT_PADDING = 5; 
    private final static int DEFAULT_RIGHT_PADDING = 5;
    private final static int DEFAULT_TOP_PADDING = 3; 
    private final static int DEFAULT_BOTTOM_PADDING = 3;
     
    private int topMargin = DEFAULT_TOP_MARGIN;
    private int bottomMargin = DEFAULT_BOTTOM_MARGIN;
    private int leftMargin = DEFAULT_LEFT_MARGIN;
    private int rightMargin = DEFAULT_RIGHT_MARGIN;
     
    private int topPadding = DEFAULT_TOP_PADDING;
    private int bottomPadding = DEFAULT_BOTTOM_PADDING;
    private int leftPadding = DEFAULT_LEFT_PADDING;
    private int rightPadding = DEFAULT_RIGHT_PADDING;
     
    private int totalHorizontalEmptySpace = leftMargin + leftPadding + rightPadding + rightMargin;
    private int totalVerticalEmptySpace = topMargin + topPadding + bottomPadding + bottomMargin;
     
    private int minHeight = 21 + totalVerticalEmptySpace;
    private int width;
    private int height = minHeight;
    private int text_colour = 0xFF0000;
    private int border_color = 0x000066;
    private int background_color = 0xFFFF99;
    private String label = "";
    private Font headingFont = getFont().derive(Font.PLAIN, 20);
    private EditField editField;
    
    public TextFieldCustom(){
        super(0);
        this.label = "";
        this.width = Display.getWidth()/2;
        editField = new EditField();
        add(editField);
    }

    public TextFieldCustom(long style){
        super(0);
        this.label = "";
        this.width = Display.getWidth()/2;
        editField = new EditField(style);
        add(editField);
    }
    
    public TextFieldCustom(int panjang){
        super(0);
        this.label = "";
        this.width = panjang;
        editField = new EditField();
        add(editField);
    }
    
    public TextFieldCustom(int panjang, long style){
        super(0);
        this.label = "";
        this.width = panjang;
        editField = new EditField(style);
        add(editField);
    }
     
    protected void sublayout(int width, int height)
    {
        Field field = getField(0);
        layoutChild(field, this.width - totalHorizontalEmptySpace , this.height - totalVerticalEmptySpace);
        setPositionChild(field, leftMargin+leftPadding, topMargin+topPadding);
        setExtent(this.width, this.height);
    }     
     
    protected void paint(Graphics graphics){     
        graphics.setColor(border_color);
        graphics.drawRoundRect(leftMargin, topMargin, width - (leftMargin+rightMargin), height - (topMargin+bottomMargin), 7, 7);
        graphics.setColor(background_color);
        graphics.fillRoundRect(leftMargin+1, topMargin+1, (width - (leftMargin+rightMargin))-2, (height- (topMargin+bottomMargin))-2, 7, 7);
        
        graphics.setColor(Color.BLACK);
        if(headingFont!=null){
            setFont(headingFont);
            graphics.drawText(label, 2, 10);
        }else{
            graphics.drawText(label, 2, 7);
        }
        
        graphics.setColor(text_colour);
        EditField ef = (EditField)getField(0);
        String entireText = ef.getText();
        
        boolean longText = false;
        String textToDraw = "";
        Font font = headingFont;
        int availableWidth = width - totalHorizontalEmptySpace;
        if (font.getAdvance(entireText) <= availableWidth)
        {
            textToDraw = entireText;
        }
        else
        {
            int endIndex = entireText.length();
            for (int beginIndex = 1; beginIndex < endIndex; beginIndex++)
            {
                textToDraw = entireText.substring(beginIndex);
                if (font.getAdvance(textToDraw) <= availableWidth)
                {
                    longText = true;
                    break;
                }
            }
        }
        
        if (longText == true)
        {        
            ef.setText(textToDraw);          
            super.paint(graphics); 
            ef.setText(entireText);
        }
        else
        {
            super.paint(graphics);
        }
         
    }
     
    public int getPreferredWidth(){
        return width;
    }
     
    public int getPreferredHeight(){
        return height;
    }
     
    protected boolean keyChar(char ch, int status, int time){        
       if (ch == Characters.ENTER)
       {
            return true;
       }     
       else
       {
            return super.keyChar(ch, status, time);
       }
    } 
   
    protected void onUnfocus() {
       super.onUnfocus();
    }
   
    protected void onFocus(int direction) {
       super.onFocus(direction);
    }
  
    protected void drawFocus(Graphics graphics, boolean on) {
       super.drawFocus(graphics, on);
    }

    public String getText(){
       return ((EditField) getField(0)).getText();
    }
         
    public void setText(final String text){
       ((EditField)getField(0)).setText(text);
    }  
}

Sekarang Tambahkan Code berikut di MainScreen untuk menampilkan TextFieldCustom.
   LabelField nama = new LabelField("Nama: ");        
   TextFieldCustom textField = new TextFieldCustom();
   ButtonField namaBtn = new ButtonField("OK");
        
   HorizontalFieldManager hfm = new HorizontalFieldManager();
   hfm.add(nama);
   hfm.add(textField);
   hfm.add(namaBtn);
   add(hfm); 

Outpunya:













Friday, May 03, 2013

Mewarnai Label Field di Blackberry

Berikut adalah beberapa contoh code untuk mewarnai LabelField, mengubah warna background LabelField, dan lain-lain yang di jabarkan di bawah ini.

1. Mengubah warna text









Outputnya:














2. Mengubah warna background dan text Label Field









outputnya:














3. Memberi warna fokus pada LabelField






































outputnya: