Help LabelField

How to make a labelfield only select this text in brief (as rectangular selction blue) with the red color of the selected text?

Thanks in advance

Then, you will need to substitute drawFocus do nothing:

protected void drawFocus(Graphics g, boolean on) {
}

Tags: BlackBerry Developers

Similar Questions

  • MenuItem / JDE 4.5

    I created an app for JDE 4.7 and have managed to add menus using the following code:

    private class AboutScreen extends MainScreen {
        public AboutScreen() {
            super();
                setTitle(" About");
                LabelField about = new LabelField();
                about.setText("Some text");
                add(about);
        }
    }
    
    private MenuItem _aboutItem = new MenuItem("About", 110, 100) {
        public void run() {
            _aboutScreen = new AboutScreen();
            UiApplication.getUiApplication().pushScreen(_aboutScreen);
        }
    };
    
    private class HelpScreen extends MainScreen {
        public HelpScreen() {
            super();
            setTitle(" Help");
            LabelField about = new LabelField();
            about.setText("Some text");
            add(about);
        }
    }
    
    private MenuItem _helpItem = new MenuItem("Help", 120, 100) {
        public void run() {
            _helpScreen = new HelpScreen();
            UiApplication.getUiApplication().pushScreen(_helpScreen);
        }
    };
    
    //create a menu item for users to close the application
    private MenuItem _closeItem = new MenuItem("Close", 200000, 10) {
        public void run() {
            onClose();
        }
    };
    
    //override makeMenu to add the new menu items
    protected void makeMenu( Menu menu, int instance ) {
        menu.add(_aboutItem);
        menu.add(_closeItem);
        menu.add(_helpItem);
    }
    

    When I compile the same application using JDE 4.5, the application compiles without any problem. The application runs as well. However, when I select the menus I add (comments or help), I get a "JVM error 104 Eception: IllegalStateException. Once I click on continue, the menu screen appears however the labelField does not work.

    Can someone point me in the right direction? I am a new developer to learn the tricks of the trade. Look through the forums, I found nothing useful found in my particular case. I appreciate any input that helps me learn what I am doing wrong.

    I don't know what I thought when I started to fill a labelField with text and layout form then she. I should have used a RichTextField from the outset. I changed the labelField for RichTextFields in my two menu items and all is well. No more error JVM 104.

    When I said I'm new to application development, I really wanted to say that I am new to application development. I find that what I have learned in my classes of college only takes you so far. You must get your nose to the grindstone and write applications to get the experience to know what works and what does not work.

    In any case, I appreciate your comments as well as the entrance, I got Peter.

  • Help function LabelField

    Hello

    I use many LabelField controls in the project do not wish to repeat the same code & would like help in creating a reusable function.

    Example:

    Import net.rim.blackberry.api.phone.Phone;

    LabelField lfOwner = new LabelField ("owner:" + OwnerInfo.getOwnerName (), DrawStyle.LEFT)
    {
    public void paint (Graphics g)
    {
    g.setColor (Color.DARKGREEN);
    g.setBackgroundColor (Color.WHITE);
    Super.Paint (g);
    }
    };

    LabelField lfOwnerInfo = new LabelField ("owner:" + OwnerInfo.getOwnerInformation (), DrawStyle.LEFT)
    {
    public void paint (Graphics g)
    {
    g.setColor (Color.DARKGREEN);
    g.setBackgroundColor (Color.WHITE);
    Super.Paint (g);
    }
    };

    As you can see, the two are LabelFields with graphics by placing of the same color. It makes no repeat the code point and would be better to be able to pass information to a function to set the color for label... Creating a class using a variable public to access the info above which is converted into a string before being passed to the LabelField control. Each LabelField will be in the same format:

    LabelName (sText + ":" + sText2, DrawStyle.LEFT);

    or

    MyLabelName ("owner", PhonesOwner(), DrawStyle.LEFT);

    producing a

    Owner: [name of the owner of some here]

    Following label:

    The owner Info: [info from the owner here]

    and so on

    That's what I wrote, but doesn't seem to work:

    ' Public Sub SetGreenLabel (field field, String sLabelText, String sFunctionName)
    {
    field = new LabelField (sLabelText + ":" + sFunctionName, DrawStyle.LEFT)
    {
    public void paint (Graphics g)
    {
    g.setColor (Color.DARKGREEN);
    g.setBackgroundColor (Color.WHITE);
    Super.Paint (g);
    }
    };
    };

    May extend to pass the ForeColor as parameter

    ' Public Sub SetLabelColour (String sLabelText, String sFunctionName, PlayStations color field, field)
    {
    field = new LabelField (sLabelText + ":" + sFunctionName, DrawStyle.LEFT)
    {
    public void paint (Graphics g)
    {
    g.setColor (cColour);
    g.setBackgroundColor (Color.WHITE);
    Super.Paint (g);
    }
    };
    };

    Perhaps an overload of the function as follows:

    SetLabelColour (String sText, String sText2)

    SetLabelColour (String sText2, String sText, color cForeColour)

    SetLabelColour (String sText2, String sText, cBackColour color, color cForeColour)

    My public variable

    MyClass mc = new MyClass();

    Label

    LabelField lf1;

    MC. SetLabelColour (lf1, 'Owner', PhonesOwner());

    Any ideas on how to write the correct functions?

    Thanks in advance

    Sure. Here is a more elaborate version of the idea of the subclass that has multiple constructors, commented to indicate what is happening. I have also set the colours.

    public class ColorLabelField extend LabelField {    /** Foreground color */    private int fg;
    
        /** Background color */    private int bg;
    
        /**     * Construct a ColorLabelField with empty text, default     * colors of dark green foreround and white background,     * and default style as determined by LabelField.     */    public ColorLabelField() {        this("", Color.DARKGREEN, Color.WHITE);    }
    
        /**     * Construct a ColorLabelField with indicated initial text,     * foreground and background colors, and default style.     * @param text the initial text     * @param fg the foreground color for the text     * @param bg the background color for the text     */    public ColorLabelField(String text, int fg, int bg) {        super(text);        this.fg = fg;        this.bg = bg;    }
    
        /**     * Construct a ColorLabelField with indicated initial text,     * foreground and background colors, and style.     * @param text the initial text     * @param fg the foreground color for the text     * @param bg the background color for the text     * @param style the style for the field     */    public ColorLabelField(String text, int fg, int bg, long style) {        super(text, style);        this.fg = fg;        this.bg = bg;    }
    
        /* No Javadoc comment. Just because. :) */    public void paint(Graphics g) {
            g.setColor(fg);
            g.setBackgroundColor(bg);
            super.paint(g);
        }
    }
    

    If you wish, you can add accessor functions to set the foreground and background colors after the ColorLabelField was built. As written, once you create them, the colors are immutable. (As far as the style of any field bits are immutable). If you add these accessor functions, you should consider if disabled then automatically the field when colors are changed or if it must remain until the client code to invalidate after everything he's done.

  • Organize the help button

    HY everybody, I am creating a Blackberry application and I created a LabelField with text and I want to make a button in the same row with the text, but I don't know how to do this.

    Here is the code:

    public StakeMenu() {}
            
    LabelField game = new LabelField ("chicken stock", Field.FIELD_LEFT);
    Add (stake);
            
    HorizontalFieldManager buttonManager = new HorizontalFieldManager (Field.VISUAL_STATE_ACTIVE);
            
    ButtonField add = new ButtonField ("Add", ButtonField.CONSUME_CLICK);
    buttonManager.add (add);
    Add (buttonManager);
    }

    Unfortunetly my code puts the button under the text, but I want to be on the same line with it. Please help me!

    From your code, I think that you don't really understand BlackBerry Ui - which is not surprising given that you are new to the platform.  So I suggest general information on unemployment insurance and the field of reading.  The Java micro site contains information that will be useful, for example this:

    http://developer.BlackBerry.com/BBOS/Java/documentation/managers_1969899_11.html

    I suggest as you advance through the whole site - leanring not everything but to find where is the useful documentation:

    http://developer.BlackBerry.com/BBOS/Java/documentation/

    Once you have done this, I think you will then fall into the trap others fell when the labels and buttons at the side.  So if you have any problems with it, then use the search (see above right) field to find the questoins that others have asked and solved.

  • How do CONSUME_CLICK on a LabelField?

    Hello

    I listed suruneliste of names I used LabelField to display names. Now, I want to open a popup when the user clicks the labelfield. I can't find CONSUME_CLICK to use for LabelField. How to achieve it. ? I've already implemented navigationClick.

    The code so far I coded is:

        public static LabelField getClickableLabelField(String label) {
            LabelField lb = new LabelField(label, Field.FOCUSABLE | Field.FIELD_LEFT | Field.FIELD_VCENTER ) {
                public void paint(Graphics g){ g.setColor(Color.WHITE); super.paint(g); }
                protected boolean navigationclick(int status, int time) {
                    fieldChangeNotify(1);
                    return true;
                }
            };
            return lb;
        }
    
    IN THE IMEPLEMENTING CLASS :
    
                LabelField lf = Common.getClickableLabelField(nm);
                lf.setCookie(new Integer(i));
                lf.setChangeListener(this);
    
                public void fieldChanged(Field field, int context) {
                   if (field instanceof LabelField) {
                      LabelField lf = (LabelField) field;
                      // Wanted to check if this is the correct field or not
                      if (lf.isFocus())
                         System.out.println("YES HAS FOCUS, CORRECT ONE !!! Text = " + lf.getText());
                  }
                  return;
                }
    

    Can anyone help me know how to get the clicked labelfield and fieldNotify is called, and therefore the implementation class fieldChanged().

    Any help is very appreciated.

    Thank you

    Override navigationUnclick() to always return true.

  • Custome Field took a nullpointexception in the labefiled and 7.1 paint method only you have this problem! Pls help me?

    KIM I create a custom entry field as below:

    public class AddEditField extends HorizontalFieldManager {
        private LabelField labelField;
        private EditField contentField;
        private RichTextField wrapaddField;
        HorizontalFieldManager textMgr;
        HorizontalFieldManager wrapMgr;
        private static final int HPADDING = Display.getWidth() <= 320 ? 6 : 8;
        Font font;
    
        public AddEditField(String label, Font font, int maxSpace) {
            this(label, 0, font, maxSpace);
        }
    
        public AddEditField(String label, long style, Font cfont, int maxSpace) {
            super(NO_HORIZONTAL_SCROLL);
            this.font = cfont;
            textMgr = new HorizontalFieldManager(HORIZONTAL_SCROLL | FIELD_VCENTER);
            wrapMgr = new HorizontalFieldManager(FIELD_VCENTER);
            wrapaddField = new RichTextField(RichTextField.TEXT_ALIGN_LEFT);
            long cstyle = 0;
            if (style == 0) {
                cstyle = EditField.NO_NEWLINE | EditField.FOCUSABLE
                        | EditField.EDITABLE | FIELD_VCENTER;
            } else {
                cstyle = EditField.NO_NEWLINE | EditField.FOCUSABLE
                        | EditField.EDITABLE | style | FIELD_VCENTER;
            }
            contentField = new EditField(cstyle) {
                protected void paint(Graphics graphics) {
    
                    // Font font = getFont().derive(Font.PLAIN, fontSize);
                    graphics.setFont(font);
                    graphics.setColor(0x666666);
                    super.paint(graphics);
                }
    
                protected void onFocus(int direction) {
                    super.onFocus(direction);
                    invalidate();
                }
    
                protected void onUnfocus() {
                    super.onUnfocus();
                    // if (VirtualKeyboard.isSupported()) {
                    // VirtualKeyboard vKeyboard =getVirtualKeyboard();
                    // vKeyboard.setVisibility(VirtualKeyboard.HIDE);
                    // }
    
                }
            };
            labelField = new LabelField(label, FIELD_LEFT | FIELD_VCENTER) {
                protected void paint(Graphics graphics) {
                    graphics.setColor(0x006699);
                    graphics.setFont(font);
                    super.paint(graphics);
                }
            };
            LabelField spaceF = new LabelField() {
    
                protected void layout(int width, int height) {
                    // TODO Auto-generated method stub
                    //super.layout(HPADDING, font.getHeight() + 10);
                    setExtent(HPADDING, font.getHeight() + 10);
                }
            };
            add(spaceF);
            add(labelField);
            final int space = maxSpace - font.getAdvance(labelField.getText());
            LabelField spaceF2 = new LabelField() {
    
                protected void layout(int width, int height) {
                    // TODO Auto-generated method stub
                    // super.layout(space, font.getHeight() + 10);
                    setExtent(space, font.getHeight() + 10);
                }
            };
            add(spaceF2);
            textMgr.add(contentField);
            wrapMgr.add(wrapaddField);
            add(textMgr);
        }
    
        public String getText() {
            return contentField.getText();
        }
    
        public void setText(String text) {
            synchronized (UiApplication.getEventLock()) {
                wrapaddField.setText(text);
                contentField.setText(text);
            }
        }
    
        public void setEditMode(boolean editable) {
            String text = wrapaddField.getText();
            synchronized (UiApplication.getEventLock()) {
                if (editable) {
                    contentField.setText(text);
                    if (wrapMgr.getManager() == this) {
                        delete(wrapMgr);
                    }
                    if (textMgr.getManager() != this) {
                        add(textMgr);
                    }
                } else {
                    if (textMgr.getManager() == this) {
                        delete(textMgr);
                    }
                    if (wrapMgr.getManager() != this) {
                        add(wrapMgr);
                    }
                }
            }
        }
    
    }
    

    Then I create: new AddEditField ("address:", cFont, maxSpace);  and add it to a screen.

    When I try to open this form. It is nullpointexception: the eclipse debugger show the info such as:

    AddEditField$ 4labelfield.paint line 385.

    Please help me to check the code. why it can run in 0 s 7.0 and before, only 7.1 has had this problem?

    Thank you

    Hi Flybrid,

    I checked at the time of your code,

    I am able to run your code by deleting page layout override methods in two fields of the label.

    The problem with the substitution of the method of layout in the spaceF and spaceF2 fields.

    But I can't explain why.

    I think that you can achieve the same thing by replacing getPrefferedWidth() and getPrefferedHeight() above the fields instead of page layout.

    Thank you.

  • problem in the scroll bar, please help...

    I have a problem with the scroll bar, why my horizontal scroll bar did not work on my labelfield?

    It works when I change the labelfield in a buttonfield.

    is there a different code for labelfield scrollbar?

    Please help me...

    This is my simple code...

    You have to edit it like this...

    Source language:

    a = new LabelField ("tessssst1");

    change:

    a = new LabelField ("tessssst1", FOCUSABLE);

    in the same way for all the fields in the label...

  • Persistent Store problem, need your help! ~

    Forgive and I would like to make a short story.

    Days, I am according to the A13_Storing_Persistent_Data_V2 document and fantasize for only a class useful for my application, but I am failed completely, here is that the source code written in the document.

    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.system.*;
    import net.rim.device.api.util.*;
    import java.util.*; 
    
    public class MusicStores extends UiApplication { 
    
      private AutoTextEditField namefield;
      private AutoTextEditField addressfield;
      private EditField phonefield;
      private EditField specialtyfield;
      private static Vector _data;
      private static PersistentObject store; 
    
      public static void main(String[] args) {
        MusicStores app = new MusicStores();
        app.enterEventDispatcher();
      } 
    
      public MusicStores() {
        MainScreen mainScreen = new MainScreen();
        mainScreen.setTitle(new LabelField("Favourite Music Store"));
        namefield = new AutoTextEditField("Store Name: ", "");
        addressfield = new AutoTextEditField("Address: ", "");
        phonefield = new EditField("Phone Number: ", "", Integer.MAX_VALUE, BasicEditField.FILTER_PHONE);
        specialtyfield = new EditField("Music Type: ", "", Integer.MAX_VALUE, BasicEditField.FILTER_DEFAULT);
        mainScreen.add(namefield);
        mainScreen.add(addressfield);
        mainScreen.add(phonefield);
        mainScreen.add(specialtyfield);
        mainScreen.addMenuItem(saveItem);
        mainScreen.addMenuItem(getItem);
        pushScreen(mainScreen);
      } 
    
      private MenuItem saveItem = new MenuItem("Save", 110, 10) {
        public void run() {
          StoreInfo info = new StoreInfo();
          info.setElement(StoreInfo.NAME, namefield.getText());
          info.setElement(StoreInfo.ADDRESS, ddressfield.getText());
          info.setElement(StoreInfo.PHONE, phonefield.getText());
          info.setElement(StoreInfo.SPECIALTY, specialtyfield.getText());
          _data.addElement(info);
          synchronized (store) {
            store.setContents(_data);
            store.commit();
          }
          Dialog.inform("Success!");
          namefield.setText(null);
          addressfield.setText(null);
          phonefield.setText("");
          specialtyfield.setText("");
        }
      }; 
    
      private MenuItem getItem = new MenuItem("Get", 110, 11) {
        public void run() {
          synchronized (store) {
            _data = (Vector) store.getContents();
            if (!_data.isEmpty()) {
              StoreInfo info = (StoreInfo) _data.lastElement(); 
    
              namefield.setText(info.getElement(StoreInfo.NAME));
              addressfield.setText(info.getElement(StoreInfo.ADDRESS));
              phonefield.setText(info.getElement(StoreInfo.PHONE));
              specialtyfield.setText(info.getElement(StoreInfo.SPECIALTY));
            }
          }
        }
      }; 
    
      static {
        store = PersistentStore.getPersistentObject(0xdec6a67096f833cL);
        synchronized (store) {
          if (store.getContents() == null) {
            store.setContents(new Vector());
            store.commit();
          }
        }
        _data = new Vector();
        _data = (Vector) store.getContents();
      } 
    
      private static final class StoreInfo implements Persistable {
        private Vector _elements;
        public static final int NAME = 0;
        public static final int ADDRESS = 1;
        public static final int PHONE = 2;
        public static final int SPECIALTY = 3; 
    
        public StoreInfo() {
          _elements = new Vector(4);
          for (int i = 0; i < _elements.capacity(); ++i) {
            _elements.addElement(new String(""));
          }
        } 
    
        public String getElement(int id) {
          return (String) _elements.elementAt(id);
        } 
    
        public void setElement(int id, String value) {
          _elements.setElementAt(value, id);
        }
      }
    }
    

    I put this code into two parts, the first part to record the second part to get info and the info, and they use the same class of StoreInfo, here is the code of the first part.

    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.system.*;
    import net.rim.device.api.util.*;
    import java.util.*; 
    
    public class SaveMusicInfo extends UiApplication { 
    
      private AutoTextEditField namefield;
      private AutoTextEditField addressfield;
      private EditField phonefield;
      private EditField specialtyfield;
      private static Vector _data;
      private static PersistentObject store; 
    
      public static void main(String[] args) {
        SaveMusicInfo app = new SaveMusicInfo();
        app.enterEventDispatcher();
      } 
    
      public SaveMusicInfo() {
        MainScreen mainScreen = new MainScreen();
        mainScreen.setTitle(new LabelField("Favourite Music Store"));
        namefield = new AutoTextEditField("Store Name: ", "");
        addressfield = new AutoTextEditField("Address: ", "");
        phonefield = new EditField("Phone Number: ", "", Integer.MAX_VALUE, BasicEditField.FILTER_PHONE);
        specialtyfield = new EditField("Music Type: ", "", Integer.MAX_VALUE, BasicEditField.FILTER_DEFAULT);
        mainScreen.add(namefield);
        mainScreen.add(addressfield);
        mainScreen.add(phonefield);
        mainScreen.add(specialtyfield);
        mainScreen.addMenuItem(saveItem);
        mainScreen.addMenuItem(getItem);
        pushScreen(mainScreen);
      } 
    
      private MenuItem saveItem = new MenuItem("Save", 110, 10) {
        public void run() {
          StoreInfo info = new StoreInfo();
          info.setElement(StoreInfo.NAME, namefield.getText());
          info.setElement(StoreInfo.ADDRESS, ddressfield.getText());
          info.setElement(StoreInfo.PHONE, phonefield.getText());
          info.setElement(StoreInfo.SPECIALTY, specialtyfield.getText());
          _data.addElement(info);
          synchronized (store) {
            store.setContents(_data);
            store.commit();
          }
          Dialog.inform("Success!");
          namefield.setText(null);
          addressfield.setText(null);
          phonefield.setText("");
          specialtyfield.setText("");
        }
      }; 
    
      static {
        store = PersistentStore.getPersistentObject(0xdec6a67096f833cL);
        synchronized (store) {
          if (store.getContents() == null) {
            store.setContents(new Vector());
            store.commit();
          }
        }
        _data = new Vector();
        _data = (Vector) store.getContents();
      } 
    
      private static final class StoreInfo implements Persistable {
        private Vector _elements;
        public static final int NAME = 0;
        public static final int ADDRESS = 1;
        public static final int PHONE = 2;
        public static final int SPECIALTY = 3; 
    
        public StoreInfo() {
          _elements = new Vector(4);
          for (int i = 0; i < _elements.capacity(); ++i) {
            _elements.addElement(new String(""));
          }
        } 
    
        public String getElement(int id) {
          return (String) _elements.elementAt(id);
        } 
    
        public void setElement(int id, String value) {
          _elements.setElementAt(value, id);
        }
      }
    }
    

    Following is the code of the second part.

    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.system.*;
    import net.rim.device.api.util.*;
    import java.util.*; 
    
    public class GetMusicInfo extends UiApplication { 
    
      private AutoTextEditField namefield;
      private AutoTextEditField addressfield;
      private EditField phonefield;
      private EditField specialtyfield;
      private static Vector _data;
      private static PersistentObject store; 
    
      public static void main(String[] args) {
        GetMusicInfo app = new GetMusicinfo();
        app.enterEventDispatcher();
      } 
    
      public GetMusicInfo() {
        MainScreen mainScreen = new MainScreen();
        mainScreen.setTitle(new LabelField("Favourite Music Store"));
        namefield = new AutoTextEditField("Store Name: ", "");
        addressfield = new AutoTextEditField("Address: ", "");
        phonefield = new EditField("Phone Number: ", "", Integer.MAX_VALUE, BasicEditField.FILTER_PHONE);
        specialtyfield = new EditField("Music Type: ", "", Integer.MAX_VALUE, BasicEditField.FILTER_DEFAULT);
        mainScreen.add(namefield);
        mainScreen.add(addressfield);
        mainScreen.add(phonefield);
        mainScreen.add(specialtyfield);
        mainScreen.addMenuItem(saveItem);
        mainScreen.addMenuItem(getItem);
        pushScreen(mainScreen);
      } 
    
      private MenuItem getItem = new MenuItem("Get", 110, 11) {
        public void run() {
          synchronized (store) {
            _data = (Vector) store.getContents();
            if (!_data.isEmpty()) {
              StoreInfo info = (StoreInfo) _data.lastElement(); 
    
              namefield.setText(info.getElement(StoreInfo.NAME));
              addressfield.setText(info.getElement(StoreInfo.ADDRESS));
              phonefield.setText(info.getElement(StoreInfo.PHONE));
              specialtyfield.setText(info.getElement(StoreInfo.SPECIALTY));
            }
          }
        }
      }; 
    
      static {
        store = PersistentStore.getPersistentObject(0xdec6a67096f833cL);
        synchronized (store) {
          if (store.getContents() == null) {
            store.setContents(new Vector());
            store.commit();
          }
        }
        _data = new Vector();
        _data = (Vector) store.getContents();
      } 
    
      private static final class StoreInfo implements Persistable {
        private Vector _elements;
        public static final int NAME = 0;
        public static final int ADDRESS = 1;
        public static final int PHONE = 2;
        public static final int SPECIALTY = 3; 
    
        public StoreInfo() {
          _elements = new Vector(4);
          for (int i = 0; i < _elements.capacity(); ++i) {
            _elements.addElement(new String(""));
          }
        } 
    
        public String getElement(int id) {
          return (String) _elements.elementAt(id);
        } 
    
        public void setElement(int id, String value) {
          _elements.setElementAt(value, id);
        }
      }
    }
    

    I'm runing the Project One (first part) and record information to be stored, and then I WANT TO runing the project two (part two), but I received an error message telling me there are two same defined the class in the system, I try to change the class name of StoreInfo in two project, the last of error messge disappeared , instead of a CastClassException error, I am so sad...

    For a long time debugging I found some interesting things, look at the below codes to two projects, please read the name of the StoreInfor class, not StoreInfo.

     private MenuItem getItem = new MenuItem("Get", 110, 11) {
        public void run() {
          synchronized (store) {
            _data = (Vector) store.getContents();
            if (!_data.isEmpty()) {
              StoreInfor info = (StoreInfor) _data.lastElement();
            }
          }
        }
      };
    

    Now the _data class name is StoreInfo@xxxxxx (using _data.getClass () .getName ()) and class StoreInfo project two was renamed to StoreInfor, of course, I received a CastClassException error.

    I finished the story, and I need some guys to help solve this problem, tks a lot! ~

    Creating a descriptor application blackberry project and inside, choose library. Then, each project must refer to this library.

  • Horizontal labelfield and choisefield Center

    Hi out there,.

    How can I Center a label and a horizontal field of choise that etiquette is the horizontal center of the choise?

    In my source the align attribute is not as I want to:

    LABEL CHOISEFIELD
    CHOISEFIELD
    CHOISEFIELD

    but I want the attribute align as:

    CHOISEFIELD
    LABEL CHOISEFIELD
    CHOISEFIELD

    what I am doing wrong?

    Here is my source:

    HorizontalFieldManager  hManagerLandSuche = new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER);
    
    LabelField Landl = new LabelField(Main.myData._res.getString(LanguagesResource.KEY_lbl_land), LabelField.FIELD_LEFT|LabelField.FIELD_HCENTER); 
    
    choice = new ObjectChoiceField("", choiceArray, 0,ObjectChoiceField.FIELD_LEFT|ObjectChoiceField.FIELD_HCENTER);
    choice.setChangeListener(listenerSuche);
    Object ob = choice.getChoice(choice.getSelectedIndex());
    searchLand = ob.toString();
    
    hManagerLandSuche.add(Landl);
    hManagerLandSuche.add(choice);
    
    vManager.add(hManagerLandSuche);
    
    tab3Manager.add(vManager);
    tab3Manager.add(new SpacerField(480, 2));
    

    Try

    FIELD_VCENTER for manager rather HCENTER.

    But he can't help - it is sometimes difficult to push the alignment for the good work.

  • Issue by dynamically assigning text in LabelField

    I have a timer job where I change LabelFields after certain time interval. I send you a vector of labelfield provenance because dynamically and add to the screen. Here is my code

    package mypackage;
    
    import java.util.Hashtable;
    import java.util.TimerTask;
    import java.util.Vector;
    import net.rim.device.api.system.Bitmap;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.component.BitmapField;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.decor.BackgroundFactory;
    import com.imimobile.app.util.Utils;
    import com.imimobile.controls.CustomVerticalLayout;
    
    class Slider extends TimerTask {
        int count=0;
        BitmapField bmp;
        Vector imageSet;
        int wd,ht;
        CustomVerticalLayout vfm;
        LabelField lb,lb1;
        Vector bmpfield,imageWd,imageHt;
        Hashtable resultsTable;
        int j=0;
         public Slider(CustomVerticalLayout itemVfm,BitmapField bmp,LabelField lb,Vector bmpfield,Vector imgSet,Vector wd,Vector ht)
         {
              this.vfm=itemVfm;
              this.bmpfield=bmpfield;
              imageWd=wd;
              this.bmp=bmp;
              this.lb=lb;
              this.lb1=lb;
              imageHt=ht;
              imageSet=imgSet;
         }
        public void run() {
            UiApplication.getUiApplication().invokeLater(new Runnable() {
                public void run() {
                    if(imageSet.size()==count){
                        count=0;
                    }
                resultsTable = (Hashtable) imageSet.elementAt(count);
                vfm.setBackground(BackgroundFactory.createBitmapBackground(Utils.resizeImage(Bitmap.getBitmapResource((String) resultsTable.get("image")),CustomVerticalLayout.mWidth,CustomVerticalLayout.mHeight)));
                    for(int i=0;i
    

    I check if the "bmpfield" vector is and LabelField instance and if so I'm changing the text with the setText method. But the problem is that it recovers the last egg of attribute. Description for both the LabelField.I want that must first set title and then put Description.Kindly help

    Remove the static keyword

  • help with my HorizontalFieldManager &amp; EditFields on the same line, 2nd column is not displayed

    Hi all, I've written a bean (called LabelAndEditField) that sets out a label and editfield as follows

    someLabel

    _________________

    |                                 |

    -----------------------

    It seems to work perfectly when it is the only component on a line of a

    VerticalFieldManager

    now I want to reuse this compenent such that I can have a screen that looks like

    someLabel another label

    ______________              ______________

    |                                 |             |                                |

    --------------------------             --------------------------

    and perhaps a third column.

    However, when you add my components of LabelAndEditField, the 2nd does not appear

    I used a HorizontalFieldManager and make

    HFM HorizontalFieldManager = new HorizontalFieldManager();

    HFM. Add (new LabelAndEditField ("someLabel"));

    HFM. Add (new LabelAndEditField ("another label"));

    then I just on the screen

    Add (hfm);

    but it does not show my second column, the second component of the LabelAndEditField

    Here is the snippet of code below, some can please help me get this to display

    (Sorry, that the code of my insert is wacked)

    public class LabelAndEditField extends VerticalFieldManager
    {
        private EditField _editField;
    
        public LabelAndEditField(String label,
                                 String initialValueOfTextField,
                                 int maxChars,
                                 long style)
        {
            super(NO_HORIZONTAL_SCROLL);
    
            add(labelField);
    
            HorizontalFieldManager textMgr = new HorizontalFieldManager(
                    Manager.NO_HORIZONTAL_SCROLL
                    | Manager.NO_HORIZONTAL_SCROLLBAR);
    
            _editField = new EditField("", initialValueOfTextField, maxChars,
                         style | EditField.NO_NEWLINE | EditField.FOCUSABLE
                         | EditField.NON_SPELLCHECKABLE
                         | Field.FIELD_VCENTER | Field.FIELD_LEFT);
    
            textMgr.add(_editField);
    
            add(textMgr);
    
        }
    
    }
    

    and the code that adds as that on the screen

    super(NO_HORIZONTAL_SCROLL); // this is a VerticalFieldManager
    
    HorizontalFieldManager rowMgr =
         new HorizontalFieldManager(Manager.NO_HORIZONTAL_SCROLL
                 | Manager.NO_HORIZONTAL_SCROLLBAR);
    
    LabelAndEditField col1=
           new LabelAndEditField("some label","initial value",12,Field.READONLY);
    
        LabelAndEditField col2=
           new LabelAndEditField("another some label","initial value",12,Field.READONLY);
    
    rowMgr.add(col1);
    rowMgr.add(col2);
    

    did anyone see anything wrong with that?

    As you can see for yourself, there is no place for the mktShare.  Try to go with FlowFieldManager and no HorizontalFieldManager as a container for your gadgets MyLabelAndEditField and see

    There is another possibility:

    The key in the code I provided is the super.layout (myWidth, maxHeight).  This myWidth tells your EditField its maximum size in pixels.  If you want to further restrict the domain, you have several options.  The only problem is - if you limit it too much, you will not be able to see the rest of the field.  To solve this, wrap your EditField (in which you now don't have to override the layout) in a HorizontalFieldManager (HORIZONTAL_SCROLL) (all this inside your MyLabelAndEditField) and limit the Manager rather than the field itself.  Then your customer will be able to scroll through the left field and right.

    In order to limit your HorizontalFieldManager, give him the width that you want in pixels (add that, as a parameter to the constructor of your MyLabelAndEditField) and substitute his sublayout like this:

    HorizontalFieldManager textMgr = new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL | Manager.HORIZONTAL_SCROLLBAR) {
      protected void sublayout(int maxWidth, int maxHeight) {
        int myWidth = Math.min(_desiredWidth, maxWidth);
        super.sublayout(myWidth, maxHeight);
      }
    };
    

    Thanks to his style HORIZONTAL_SCROLL, the infield will be almost infinite width, so the EditField inside fortunately "will display" all his characters.

    Then, when you design your MyLabelAndEditField, give him a maximum pixel value.  Say, you want three areas in a row.  Take your Display.getWidth (), subtract the margins planned, divide by 3 and pass that value to each of these areas.  Then add them to a HorizontalFieldManager (line2mgr in your example) and check the result.

    You seem to be competent enough to easily integrate my illegible bubbles in your code - let us know the results.

  • LabelField text position

    Hi, I have created fat labelfields by adding some padding on them and have managed to align the text in the Middle through DrawStyle.HCENTER.

    I wonder how I can make centered vertically as VCENTER does nothing.

    I can think of a way to achieve what I want - by adding the margin calculated upwards, but this seems to be a lot more work.

    Any help will be appreciated!

    I solved the problem by positioning the text manually (replacing the graphics).

    Thank you very much for your help!

  • a strange problem on quite demand. Pls help me. Thank you very much

    public class Searchbox extends Manager {
        private Bitmap searchbarBitmap;
        private int searchbarheight;
        private int searchbarwidth;
        public Searchbox() {
            super(NO_VERTICAL_SCROLL);
            if(Display.getHeight()<440){
                searchbarheight = getFont().getHeight() + 13;
                searchbarwidth=Display.getWidth()-60;
                searchbarBitmap = Scaleimage.resizeBitmap("Bold/fake_search_bar.png",
                        searchbarwidth, searchbarheight);
            }else{
            searchbarheight = getFont().getHeight()+10;
            searchbarwidth=Display.getWidth();
            searchbarBitmap = Scaleimage.resizeBitmap("Storm/fake_search_bar.png",
                    searchbarwidth, searchbarheight);
            }
        }
    
        protected void sublayout(int width, int height) {
            Field field = getField(0);
            layoutChild(field, searchbarBitmap.getWidth(), searchbarBitmap
                    .getHeight());
            if(Display.getHeight()<440){
            setPositionChild(field, 30, 6);}
            else{
                setPositionChild(field, 45, 6);
            }
            setExtent(searchbarBitmap.getWidth(), searchbarBitmap.getHeight());
        }
        public int getPreferredWidth()
        {
            return searchbarBitmap.getWidth();
        }
        public int getPreferredHeight()
        {
            return searchbarBitmap.getHeight();
        }
        protected void paint(Graphics graphics) {
            graphics.drawBitmap(0, 0, searchbarBitmap.getWidth(), searchbarBitmap
                    .getHeight(), searchbarBitmap, 0, 0);
            super.paint(graphics);
        }
    
        public String getText() {
            return ((EditField) getField(0)).getText();
        }
    
    }
    

    I'm writing a screen, this screen is the first screen of this application. This screen have a lot of buttons and a search box. The problem is:

    When I click on the button esc to quite this request if the searchbox onfocus, it will get the Eception message: NullpointException

    public class StorelistScreen extends MainScreen implements Container {
        private Merchant merchant;
        private VerticalFieldManager backgroundmanager;
        private LabelField title;
        private ListField storelist;
        private storelistCallback storelistCallback;
        private VerticalFieldManager listmanager;
        private String titleString;
        private Vector storeVector;
        private String imageurl;
        private String cat;
        private Mapbar mapbar;
        private double curlat;
        private double curlng;
        private Vector imageVector;
        private boolean offer;
        private BitmapField offerlogoField;
        private Bitmap offerBitmap;
        private HorizontalFieldManager titleManager;
        private Vector offerVector;
        private HorizontalFieldManager bottombuttonManager;
        private VerticalFieldManager bottomManager;
    
        public StorelistScreen(Merchant merchant, String tilesString,
                Vector storeVector, String cat, Vector imageVector,
                final boolean offer, double curlat, double curlng,
                Vector offerVector) {
            super(NO_VERTICAL_SCROLL | NO_VERTICAL_SCROLLBAR|DEFAULT_CLOSE);
            this.merchant = merchant;
            this.titleString = tilesString;
            this.storeVector = storeVector;
            this.cat = cat;
            this.imageVector = imageVector;
            this.offer = offer;
            this.offerVector = offerVector;
            setCurlat(curlat);
            setCurlng(curlng);
            VirtualKeyboard vk = null;
            if ((vk = UiApplication.getUiApplication().getActiveScreen()
                    .getVirtualKeyboard()) != null) {
                vk.setVisibility(VirtualKeyboard.HIDE);
            }
            if (Display.getWidth() < 440&&Display.getHeight()>440) {
                imageurl = "Storm/amex-splash.png";
            } else {
                imageurl = "Bold/detail_background_without_webview.png";
            }
            int backgroundwidth=Display.getWidth();
            int backgroundheight=Display.getHeight();
            final Bitmap backgroundbitmap = Scaleimage.resizeBitmap(imageurl,
                    backgroundwidth,backgroundheight);
            backgroundmanager = new VerticalFieldManager(NO_VERTICAL_SCROLL
                    | NO_VERTICAL_SCROLLBAR | USE_ALL_HEIGHT | USE_ALL_WIDTH
                    | NO_SYSTEM_MENU_ITEMS) {
                protected void sublayout(int width, int height) {
                    super.sublayout(Display.getWidth(), Display.getHeight());
                    Field field = (Field) getField(0);
                    Manager field2 = (Manager) getField(1);
                    layoutChild(field, Display.getWidth(), field.getHeight());
                    if (Display.getHeight() < 480) {
                        setPositionChild(field, 0, 10);
                        setPositionChild(field2, 5, 70);
                        layoutChild(field2, Display.getWidth() - 10, Display
                                .getHeight()
                                - 70 - mapbar.getPreferredHeight());
                    } else {
                        setPositionChild(field, 0, 10);
                        setPositionChild(field2, 5, 60);
                        layoutChild(field2, Display.getWidth() - 10, Display
                                .getHeight()
                                - 60 - mapbar.getHeight() - 30);
                    }
                    setExtent(Display.getWidth(), Display.getHeight());
                }
    
                protected void paint(Graphics graphics) {
                    graphics.clear();
                    graphics.drawBitmap(0, 0, Display.getWidth(), Display
                            .getHeight(), backgroundbitmap, 0, 0);
                    super.paint(graphics);
                }
            };
            if (offer) {
                if (titleString.equalsIgnoreCase("1")) {
                    offerBitmap = Bitmap
                            .getBitmapResource("Bold/list_logo_selects.png");
                } else if (titleString.equalsIgnoreCase("2")) {
                    offerBitmap = Bitmap
                            .getBitmapResource("Bold/list_logo_10X.png");
                } else {
                    offerBitmap = Bitmap.getBitmapResource("Bold/list_logo_15.png");
                }
                offerlogoField = new BitmapField(offerBitmap, FIELD_HCENTER
                        | USE_ALL_WIDTH);
            } else {
                title = new LabelField() {
                    public void layout(int width, int height) {
                        setExtent(Display.getWidth(), 30);
                    }
    
                    public void paint(Graphics g) {
                        g.setColor(5934280);
                        g.drawText(titleString, 0, 0, DrawStyle.HCENTER, Display
                                .getWidth());
                        super.paint(g);
                    }
                };
            }
            titleManager = new HorizontalFieldManager(NO_HORIZONTAL_SCROLL
                    | NO_HORIZONTAL_SCROLLBAR) {
                protected void sublayout(int width, int height) {
                    super.sublayout(width, height);
                    if (getField(0) == title) {
                        if (Display.getHeight() < 440) {
                            setPositionChild(getField(0), 0, 10);
                        } else {
                            setPositionChild(getField(0), 0, 20);
                        }
                    } else {
                        if (Display.getHeight() < 440) {
                            setPositionChild(getField(0), 150, 0);
                        } else {
                            setPositionChild(getField(0), 100, 0);
                        }
                    }
                    setExtent(Display.getWidth(), height);
                }
            };
            if (offer) {
                titleManager.add(offerlogoField);
            } else {
                titleManager.add(title);
            }
            backgroundmanager.add(titleManager);
            listmanager = new VerticalFieldManager(VERTICAL_SCROLL
                    | VERTICAL_SCROLLBAR);
            backgroundmanager.add(listmanager);
            final Bitmap mapbuttonbitmap = Bitmap
                    .getBitmapResource("Storm/map_button.png");
            storeDTO sDto = (storeDTO) storeVector.elementAt(0);
            double storelat = sDto.getLat();
            double storelng = sDto.getLng();
            String firstdbname = sDto.getDbaname();
            String firstadd1 = sDto.getAdd1();
            mapbar = new Mapbar(mapbuttonbitmap, storelat, storelng, firstdbname,
                    firstadd1);
            if (Display.getWidth()<440&& Display.getHeight()>440) {
            bottombuttonManager = new HorizontalFieldManager(NO_HORIZONTAL_SCROLL
                    | NO_HORIZONTAL_SCROLLBAR);
            int offersize = offerVector.size();
            int buttonwidth = Display.getWidth() / (offersize + 2);
            StatusButton home = new StatusButton("Home", true, Field.FIELD_HCENTER,
                    buttonwidth, 30, merchant);
            StatusButton cards = new StatusButton("Cards", false,
                    Field.FIELD_HCENTER, buttonwidth, 30, merchant);
            bottombuttonManager.add(home);
            for (int i = 0; i < offersize; i++) {
                offerDto offerdto = (offerDto) offerVector.elementAt(i);
                final String offernum = offerdto.getOffer();
                String offertitle = offerdto.getTitle();
             String offersString =null;
                if (cat.equalsIgnoreCase("0")) {
                    offersString = "http://amex.isingeo.com/search?lat=lat="
                            + Double.toString(getCurlat())
                            + "&lng="
                            + Double.toString(getCurlng())
                            + "&udid=wibble&nearby=1&offer=" + offernum;
                } else {
                    offersString = "http://amex.isingeo.com/search?lat="
                            + Double.toString(getCurlat()) + "&lng="
                            + Double.toString(getCurlng())
                            + "&udid=wibble&nearby=1&cat=" + cat
                            + "&offer=" + offernum;
                }
                StatusButton statusButton = new StatusButton(offertitle, offernum,
                        Field.FIELD_HCENTER, offersString, merchant, buttonwidth,
                        30, this);
                bottombuttonManager.add(statusButton);
    
            }
            bottombuttonManager.add(cards);
            bottomManager = new VerticalFieldManager(NO_VERTICAL_SCROLL
                    | NO_VERTICAL_SCROLLBAR | FIELD_HCENTER);
                bottomManager.add(mapbar);
                bottomManager.add(bottombuttonManager);
                setStatus(bottomManager);
            } else {
                setStatus(mapbar);
            }
            add(backgroundmanager);
            setstoreinfo();
        }
    
        protected boolean onSavePrompt() {
            return false;
        }
    
        public void setstoreinfo() {
            int storelistlength = storeVector.size();
            storelist = new ListField() {
                private boolean hasFocus = false;
    
                public void onFocus(int direction) {
                    hasFocus = true;
                }
    
                public void onUnfocus() {
                    hasFocus = false;
                    super.onUnfocus();
                    invalidate();
                }
    
                public void paint(Graphics graphics) {
                    int width = Display.getWidth();
                    XYRect redrawRect = graphics.getClippingRect();
                    if (redrawRect.y < 0) {
                        throw new IllegalStateException("Error with clipping rect.");
                    }
                    int rowHeight = getRowHeight();
    
                    int curSelected;
    
                    if (hasFocus) {
                        curSelected = getSelectedIndex();
    
                    } else {
                        curSelected = -1;
                    }
    
                    int startLine = redrawRect.y / rowHeight;
                    int endLine = (redrawRect.y + redrawRect.height - 1)
                            / rowHeight;
                    endLine = Math.min(endLine, getSize() - 1);
                    int y = startLine * rowHeight;
                    int[] yInds = new int[] { y, y, y + rowHeight, y + rowHeight };
                    int[] xInds = new int[] { 0, width, width, 0 };
    
                    ListFieldCallback callBack = this.getCallback();
    
                    for (; startLine <= endLine; ++startLine) {
                        storeDTO dtostore = (storeDTO) callBack
                                .get(this, startLine);
                        if (startLine == curSelected) {
    
                            graphics.setColor(11584734);
                            graphics.drawFilledPath(xInds, yInds, null, null);
                            if(Display.getWidth()<440&&Display.getHeight()>440){
                                drawforStorm(graphics, dtostore, y, width);
                            }
                            else{
                            drawforBold(graphics, dtostore, y, width);}
    
                        } else {
                            if(Display.getWidth()<440&&Display.getHeight()>440){
                                drawforStorm(graphics, dtostore, y, width);
                            }
                            else{
                            drawforBold(graphics, dtostore, y, width);}
                        }
                        y += rowHeight;
                        yInds[0] = y;
                        yInds[1] = yInds[0];
                        yInds[2] = y + rowHeight;
                        yInds[3] = yInds[2];
                    }
    
                    // super.paint(graphics);
                }
    
                private void drawforBold(Graphics graphics, storeDTO dtostore,
                        int startLine, int width) {
                    Bitmap imageBitmap = dtostore.getImagebitmap();
                    int imagewidth = imageBitmap.getWidth() + 10;
                    String cuisine = dtostore.getCuisine();
                    String dbname = dtostore.getDbaname();
                    String add1 = dtostore.getAdd1();
                    String add2 = dtostore.getAdd2();
                    String distance = dtostore.getDistance();
                    double distancedouble = Double.parseDouble(distance);
                    distancedouble = Math.floor(distancedouble * 10) / 10;
                    String finaldistance = String.valueOf(distancedouble) + "km";
                    String state = dtostore.getState();
                    graphics.drawBitmap(10, startLine, width, imageBitmap
                            .getHeight(), imageBitmap, 0, 0);
                    FontFamily family = null;
                    try {
                        family = FontFamily.forName(FontFamily.FAMILY_SYSTEM);
                    } catch (ClassNotFoundException e) {
                        e.printStackTrace();
                    }
                    Font font = family.getFont(Font.APPLICATION, 15);
                    graphics.setFont(font);
                    graphics.setColor(5929160);
                    graphics.drawText(dbname, imagewidth, startLine,
                            DrawStyle.LEFT, width);
                    Font font2 = family.getFont(Font.APPLICATION, 12);
                    graphics.setColor(5925199);
                    graphics.setFont(font2);
                    graphics.drawText(cuisine, imagewidth, startLine
                            + font.getHeight(), DrawStyle.LEFT, width);
                    graphics.setColor(6908265);
                    graphics.drawText(add1, imagewidth, startLine
                            + font.getHeight() + font2.getHeight(), DrawStyle.LEFT,
                            width);
                    graphics.drawText(add2 + " " + state, imagewidth, startLine
                            + font.getHeight() + font2.getHeight() * 2,
                            DrawStyle.LEFT, width);
                    graphics.setColor(5929160);
                    graphics.drawText(finaldistance, Display.getWidth() - 80,
                            startLine, DrawStyle.LEFT, Display.getWidth() - 40);
                    graphics.drawLine(5, startLine, Display.getWidth() - 10,
                            startLine);
                }
                private void drawforStorm(Graphics graphics, storeDTO dtostore,
                        int startLine, int width) {
                    Bitmap imageBitmap = dtostore.getImagebitmap();
                    int imagewidth = imageBitmap.getWidth() + 10;
                    String cuisine = dtostore.getCuisine();
                    String dbname = dtostore.getDbaname();
                    String add1 = dtostore.getAdd1();
                    String add2 = dtostore.getAdd2();
                    String distance = dtostore.getDistance();
                    double distancedouble = Double.parseDouble(distance);
                    distancedouble = Math.floor(distancedouble * 10) / 10;
                    String finaldistance = String.valueOf(distancedouble) + "km";
                    String state = dtostore.getState();
                    graphics.drawBitmap(10, startLine, width, imageBitmap
                            .getHeight(), imageBitmap, 0, 0);
                    FontFamily family = null;
                    try {
                        family = FontFamily.forName(FontFamily.FAMILY_SYSTEM);
                    } catch (ClassNotFoundException e) {
                        e.printStackTrace();
                    }
                    Font font = family.getFont(Font.APPLICATION, 13);
                    graphics.setFont(font);
                    graphics.setColor(5929160);
                    graphics.drawText(dbname, imagewidth, startLine,
                            DrawStyle.LEFT, width);
                    Font font2 = family.getFont(Font.APPLICATION, 12);
                    graphics.setColor(5925199);
                    graphics.setFont(font2);
                    graphics.drawText(cuisine, imagewidth, startLine
                            + font.getHeight(), DrawStyle.LEFT, width);
                    graphics.setColor(6908265);
                    graphics.drawText(add1, imagewidth, startLine
                            + font.getHeight() + font2.getHeight(), DrawStyle.LEFT,
                            width);
                    graphics.drawText(add2 + " " + state, imagewidth, startLine
                            + font.getHeight() + font2.getHeight() * 2,
                            DrawStyle.LEFT, width);
                    graphics.setColor(5929160);
                    graphics.drawText(finaldistance, Display.getWidth() - 80,
                            startLine, DrawStyle.LEFT, Display.getWidth() - 10);
                    graphics.drawLine(5, startLine, Display.getWidth() - 10,
                            startLine);
                }
    
                protected boolean navigationClick(int status, int time) {
                    if (getSize() != 0) {
                        if ((status & KeypadListener.STATUS_TRACKWHEEL) != KeypadListener.STATUS_TRACKWHEEL) {
                            storeDTO storedto = (storeDTO) storelistCallback.get(
                                    storelist, getSelectedIndex());
                            if (!offer) {
                                merchant.showStoreDetail(storedto, false);
                            } else {
                                merchant.showStoreDetail(storedto, true);
                            }
                        }
                    }
                    return super.navigationClick(status, time);
                }
            };
            storelistCallback = new storelistCallback();
            storelist.setCallback(storelistCallback);
            storelist.setRowHeight(50);
            for (int i = 0; i < storelistlength; i++) {
                storeDTO store = (storeDTO) storeVector.elementAt(i);
                storelist.insert(i);
                storelistCallback.Insert(store, i);
            }
            listmanager.add(storelist);
        }
    
        public void formenuitem(String urlstring, String offernum) {
            Bitmap offernewBitmap = null;
            this.offer = true;
            final String title = offernum;
            if (offer) {
                if (title.equalsIgnoreCase("1")) {
                    offernewBitmap = Bitmap
                            .getBitmapResource("Bold/list_logo_selects.png");
                } else if (title.equalsIgnoreCase("2")) {
                    offernewBitmap = Bitmap
                            .getBitmapResource("Bold/list_logo_10X.png");
                } else {
                    offernewBitmap = Bitmap
                            .getBitmapResource("Bold/list_logo_15.png");
                }
            }
            BitmapField offernewBitmapField = new BitmapField(offernewBitmap,
                    FIELD_HCENTER);
            titleManager.replace(titleManager.getField(0), offernewBitmapField);
            String jString = GetPostJson.getjsonString(urlstring);
            JSONObject jsonObject = null;
            try {
                jsonObject = new JSONObject(jString);
                int num = jsonObject.getInt("n");
                if (num>0) {
                    int blistlength = storelist.getSize();
                    for (int n = 0; n < blistlength; n++) {
                        storelist.delete(0);
                        storelistCallback.removeItem(0);
                    }
                    JSONArray jsonArray = jsonObject.getJSONArray("merchants");
                    int jlength = jsonArray.length();
                    for (int i = 0; i < jlength; i++) {
                        storeDTO storedto = new storeDTO();
                        JSONObject storeJsonObject = jsonArray.getJSONObject(i);
                        String curcat = Integer.toString(storeJsonObject.getInt("cat1"));
                        Bitmap iconBitmap = null;
                        int imagelength = imageVector.size();
                        for (int n = 0; n < imagelength; n++) {
                            imagedto image = (imagedto) imageVector.elementAt(n);
                            if (curcat.equalsIgnoreCase(image.getCat())) {
                                iconBitmap = image.getIcon();
                            }
                        }
                        if (iconBitmap != null) {
                            storedto.setOfferlink(storeJsonObject
                                    .getString("offer_link"));
                            storedto.setAdd1(storeJsonObject.getString("add1"));
                            storedto.setAdd2(storeJsonObject.getString("add2"));
                            storedto.setDbaname(storeJsonObject
                                    .getString("dbaname"));
                            storedto.setDistance(storeJsonObject
                                    .getString("distance"));
                            storedto.setImagebitmap(iconBitmap);
                            storedto.setLat(storeJsonObject.getDouble("lat"));
                            storedto.setLng(storeJsonObject.getDouble("lng"));
                            storedto.setPhone(storeJsonObject.getString("phone"));
                            storedto.setState(storeJsonObject.getString("state"));
                            if (cat.equalsIgnoreCase("0")) {
                                storedto.setCuisine(storeJsonObject
                                        .getString("description"));
                            } else {
                                storedto.setCuisine(storeJsonObject
                                        .getString("cuisine"));
                            }
                            storelist.insert(i);
                            storelistCallback.Insert(storedto, i);
                        }
    
                    }
                }
                else{
                    int blistlength = storelist.getSize();
                    for (int n = 0; n < blistlength; n++) {
                        storelist.delete(0);
                        storelistCallback.removeItem(0);
                    }
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
            titleManager.invalidate();
            storelist.invalidate();
        }
    
        private MenuItem cardItem = new MenuItem("Cards", 100, 10) {
            public void run() {
                String cardurl = "http://amex.isingeo.com/cards";
                String jString = GetPostJson.getjsonString(cardurl);
                Vector cardsVector = new Vector();
                try {
                    JSONArray jsonArray = new JSONArray(jString);
                    int jlength = jsonArray.length();
                    for (int i = 0; i < jlength; i++) {
                        JSONObject jsonObject = jsonArray.getJSONObject(i);
                        CardDto cardDto = new CardDto();
                        String imageurl = jsonObject.getString("face_url");
                        Bitmap faceBitmap = Getimage.getbitmapdata(imageurl);
                        if (faceBitmap != null) {
                            cardDto.setFaceBitmap(Scaleimage.resizeBitmap(
                                    faceBitmap, 90, 57));
                            cardDto.setCard_title(jsonObject
                                    .getString("card_title"));
                            cardDto.setDescription(jsonObject
                                    .getString("description"));
                            cardsVector.addElement(cardDto);
                        }
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                merchant.showCardsScreen(cardsVector);
            }
        };
    
        protected void makeMenu(Menu menu, int instance) {
             if (!(Display.getHeight() == 480 && Display.getWidth() == 360)) {
            int offersize = offerVector.size();
            for (int i = 0; i < offersize; i++) {
                offerDto oDto = (offerDto) offerVector.elementAt(i);
                final String offertitle = oDto.getTitle();
                final String offernum = oDto.getOffer();
                menu.add(new MenuItem(offertitle, 100, 10) {
                    public void run() {
                        String offersString = null;
                        if (cat.equalsIgnoreCase("0")) {
                            offersString = "http://amex.isingeo.com/search?lat=lat="
                                    + Double.toString(getCurlat())
                                    + "&lng="
                                    + Double.toString(getCurlng())
                                    + "&udid=wibble&nearby=1&offer=" + offernum;
                        } else {
                            offersString = "http://amex.isingeo.com/search?lat="
                                    + Double.toString(getCurlat()) + "&lng="
                                    + Double.toString(getCurlng())
                                    + "&udid=wibble&nearby=1&cat=" + cat
                                    + "&offer=" + offernum;
                        }
                        formenuitem(offersString, offernum);
                    }
                });
            }
            menu.add(cardItem);
             }
        }
    
         protected void sublayout(int width, int height) {
         setPositionDelegate(0, 0);
         layoutDelegate(width, height);
         setPosition(0, 0);
         setExtent(width, height);
         }
    
        // public boolean onClose(){
        // this.close();
        // return true;
        // }
        public void setCurlat(double curlat) {
            this.curlat = curlat;
        }
    
        public double getCurlat() {
            return curlat;
        }
    
        public void setCurlng(double curlng) {
            this.curlng = curlng;
        }
    
        public double getCurlng() {
            return curlng;
        }
    }
    

    If you run this application via a simulator, simply press the debug icon (it's the one that looks like a bug, just left of the "Run" icon), but make sure that you debug the correct application. If you are running on a simulator application, attach the device to your computer via USB and go to--> Debug configurations--> BlackBerry device debugging--> debugging the server (1) (or any other profile you want to use this topic). He will have to use the JDE 'Join all connected', but you can specify the device. Then from there, you can select the debug icon. All output of the Simulator will be displayed in the console at the bottom of the screen window. Also, there is a default debugging view that can be used to display the stack traces, etc. Breakpoints will work only in debug mode.

    Hope that helps,

    ~ Dom

  • Set the position of a LabelField

    JDE 4.5 using.

    I need to define fields (LabelField, ButtonField, etc.) in arbitrary positions on the screen of the application.  Official methods I found seem to be facing left and right, but I need my fields to appear in other places.  I got something that works well.  This is the essence of my solution, where I place two labels where I want them. :

    verticalFieldManager = new VerticalFieldManager (...);
    Scrn.Add (verticalFieldManager);
      
    LabelField labelField = new LabelField ("blah");
    VFM VerticalFieldManager = new VerticalFieldManager();
    VFM. Add (labelField);
    vfm.setPadding (25,0,0,100);
      
    LabelField labelField2 = new LabelField ("foo bar");
    VerticalFieldManager vfm2 = new VerticalFieldManager();
    vfm2. Add (labelField2);
    vfm2.setPadding (80,0,0,100);

    verticalFieldManager.add (vfm);
    verticalFieldManager.add (vfm2);

    As you can see, the secret sauce is setPadding () - which I read in these forums.  But it is undocumented...  Now, of course I'm very happy to be part of a secret cabal... But I wonder what is the official way to do this.

    Thanks for any help - fd

    Hello

    Take a look at this link

    http://supportforums.BlackBerry.com/Rim/Board/message?board.ID=java_dev&message.id=3797&query.ID=413...

    This will help you. setPositionChild() is the method that should help you get the desired result.

  • a LabelField can blink?

    a LabelField can blink? And if so, can she blink during an interval?

    Cheers...

    This code might help.

    http://supportforums.BlackBerry.com/T5/Java-development/repeating-background-color-change/m-p/104938...

Maybe you are looking for

  • deletion of perfetnight

    I followed the instructions on an old thread to remove that and took the screen shots, but it fails the next steps.  Any help after seeing the following screenshots?

  • Upgrade to Maverick and can not select my headphones as the speakers

    I switch to Maverick and now can't go to Skype preferences > audio/video > speakers and select my headphones more as I used to be able to do the upgrade. Now, my only options are the same as system, AirPlay (Apple TV) and built-in output (loudspeaker

  • Fact my tablet / computer laptop support WiDi?

    Hello I just bought a new laptop / Tablet: PC HP Split 13-m100la x 2 (E7H88LA). * I bought the tablet in South America (particularly here in Chile) However, I'm confused.  I am not sure whether or not it supports WiDi. I read similar tech specs on si

  • iPad 2 is stuck on update checking

    My 2A ipade was slain on "update check" for 2 days.  I can't disable or stop the updates.  Any suggestions

  • How to change a. REM file to a. JPEG

    original title: change the rem to JPEG file Problems with a few photo that have been converted to the ext.rem file files, now I'm tryin to convert these files to JPEG any help would be appreciated