Add labelfield

Hi, I have a question about adding a labelfield n00bish

I have VerticalFieldManager added on the Screen class.

I start a thread and at the end of the thread, I add a field (i.e. LabelField) on VerticalFieldManager, I added on the screen, but I get IllegalStateException. That the exception occurs when "If the field already added to a Manager.'. What does that mean? How to avoid this exception?

Thanks for all the help!

Here is a message that explains in detail very purpose:

Peter Strange explanation about the execution of the code on the event Thread

Tags: BlackBerry Developers

Similar Questions

  • 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.

  • How to add an auto incremented counter on an image?

    Hello

    I need to develop the screens as above...

    I just added 3 images bitmap in Horizontalfield Manager and the Manager has added to the screen, now, my problem is that I must add labelField on the image of the middle... .i can't do

    someone help me pls

    pls reply fast...

    "my problem is that I must add labelField on the Middle image.

    Can you explain what you mean by that.

    I see two possibilities:

    (1) you want to add it immediately above or below the Bitmap image - in which case the display will show

    Bitmap image

    Label
    bitmap image

    Bitmap image

    or

    Bitmap image

    Bitmap image

    Label

    Bitmap image

    This is easily done with a VerticalFieldManager by inserting the LabelField to the right place - see insert method.

    (2) However, I suspect that you want to have the label on top of the Bitmap image, i.e.

    Bitmap image

    Bitmap and label on top

    Bitmap image

    It's a little more complicated.  The best way to do this is to create a BitmapField that will display the text or alternatively, a LabelField that display a bitmap in the background.  These two are possible.

    Another alternative is to use a different layout manager and set the LabelField where the Bitmap image was placed.  I think it's possible, but I never did.

    My personal preference is to create a LabelField, who has a background Bitmap.  When the LabelField is not text, it acts as a BitmapField

    In any case, tell us which of these options, you are actually after and we'll see what we can do to help.

  • getPreferredHeight does not change the height of a LabelField.

    Hello

    I add LabelFields at a screen. I replaced getPreferredWidth and the LabelField getPreferredHeight. GetPreferredHeight however does not change the height of LabelField.

    getPreferredWidth seems to work very well.

    I do not use the default vertical Manager that comes with the screen.

    Ideas/pointers in troubleshooting this would be greatly appreciated.

    -MO.

    Hello

    to change dimensions on a field, you must override the method of layout.

    protected final void layout(final int width, final int height) {
        int yourHeight = super.getFont() * 2;
        super.setExtent(width, yourHeight);
    }
    

    If you want the label is centered vertically, you must override the paint method.

  • illegalStateException during the updating of the labelField

    package com.GaugeField;
    
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.component.ButtonField;
    import net.rim.device.api.ui.component.GaugeField;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.container.MainScreen;
    
    public class GaugeFieldScreen extends MainScreen {
    
        GaugeField gField ;
        ButtonField startButton;
        int i = 0;
        boolean isRunning;
        Mythread mythread;
        LabelField labelField ;
        public GaugeFieldScreen() {
    
            mythread = new Mythread();
            startButton = new ButtonField("Start");
            labelField = new LabelField(i+"");
            startButton.setChangeListener(new FieldChangeListener() {
    
                public void fieldChanged(Field field, int context) {
    
                    isRunning =true;
    
                    mythread.start();
                    add(gField);
                    add(labelField);
    
                }
            });
            gField = new GaugeField("Gausefield", 0,100,0,GaugeField.PERCENT);
    
            add(startButton);
        }
        class Mythread extends Thread{
            public void run() {
                while (isRunning) {
    
                    i++;
                    if(i<=100){
                        gField.setValue(i);
                        labelField.setText(i+"");
    
                        try {
    
                            sleep(200);
                        } catch (Exception e) {
    
                        }
    
                    }
    
                }
            }
    
        }
    
    }
    

    I mean illegalState exception labelfield.setLabel (); method in class MyThread

    You try to update the user interface of another thread. Keep labelField.setText () next to the next block.

    synchronized (Application.getEventLock ())
    {

    labelField.setText)

    }

  • Add text dynamically to the SplashScreen...

    Hello

    I use the splash screen that opens during my xml application that loads all of the HTTP connection.

    This start screen is controlled by a timer thread which, after some specific time, transfer to the landing screen.

    I would like to add different text based on the time spent on the thread of Splash.

    My current thread is 32 seconds. I want after 10 seconds, I'd write "Loading News... »
    After 20 seconds, I should write "loading settings...". "after every 10 seconds etc. Then, total three changes will come during the time splashscreen transfers control to landingscreen.

    How can I achieve this. Post my code, which will help you understand the requirment.

    First file with UiApplication

    public class NewsArena extends UiApplication
    {
        public static void main(String[] args)
        {
            NewsArena hello = new NewsArena();
            hello.enterEventDispatcher();
        }
        public NewsArena()
        {
            pushScreen(new WelcomeScreen(this,new LandingScreen(Constants.NEWLYADDED)));
        }
    }
    

    Have the second class SplashScren

    public class WelcomeScreen extends MainScreen
    {
        private UiApplication application;
        private MainScreen next;
        private static final Bitmap _bitmap = Bitmap.getBitmapResource("wap_logo.gif");
        private Timer timer = new Timer();
    
        public WelcomeScreen(UiApplication application, MainScreen next)
        {
              this.application = application;
              this.next = next;
              this.add(new BitmapField(_bitmap,BitmapField.FIELD_HCENTER | BitmapField.FIELD_VCENTER));
              this.add(new LabelField("Loading application ....",LabelField.FIELD_HCENTER | LabelField.FIELD_VCENTER));
              timer.schedule(new CountDown(), 32000);
        }
    
        public void dismiss()
        {
    
            timer.cancel();
            application.popScreen(this);
            application.pushScreen(next);
        }
        private class CountDown extends TimerTask
        {
            public void run()
            {
                DismissThread dThread = new DismissThread();
                application.invokeLater(dThread);
            }
        }
    
        private class DismissThread implements Runnable
        {
            public void run()
            {
                dismiss();
            }
        }
    }
    

    Thus, instead of

    "Loading application...". "I want to add other texts defined above, on the basis of time expired on SplashScreen.

    Thank you

    Kind regards

    Amber

    In your SplasScreen, use the following for Timer constructor:

    hourly (task the TimerTask, delay, long)

    Schedules the task specified for the repeated execution of fixed / period, starting after the specified delay.

    Then task will be continuously called after the time (period) specified.

    And in the TimerTask:

    1. change the text of the label.

    2. If the total time of the display is greater than your total time then make disappear the splash screen.

    You can try with something like below:

    public class WelcomeScreen extends MainScreen{    private UiApplication application;    private MainScreen next;    private static final Bitmap _bitmap = Bitmap.getBitmapResource                                           ("wap_logo.gif");    private Timer timer = new Timer();
    
        //display the messages in the following order (0,1,..., 4,0,..)    //toggle after 1 second    private String msg[] = {"Loading 1", "Loading 2","Loading                              3","Loading 4","Loading 5"};    int totalMessage = msg.length;    int currentMessageIndex = 0;    int timeBetweenToggleMessage = 1000;
    
        long startTime;    int totalTime = 32000;
    
        LabelField labelField = new LabelField(msg[0], DrawStyle.HCENTER |                                                           LabelField.USE_ALL_WIDTH );
    
        public WelcomeScreen(UiApplication application, MainScreen next)    {        startTime = System.currentTimeMillis();        this.application = application;        this.next = next;        this.add(new BitmapField(_bitmap,BitmapField.FIELD_HCENTER |                                          BitmapField.FIELD_VCENTER));        this.add(labelField);        timer.schedule(new CountDown(), 0, timeBetweenToggleMessage);    }
    
        public void dismiss()     {
    
            timer.cancel();        application.popScreen(this);        application.pushScreen(next);    }    private class CountDown extends TimerTask     {        public void run()         {            synchronized(Application.getEventLock())            {                if(currentMessageIndex >= totalMessage )                      currentMessageIndex = 0;                labelField.setText(msg[currentMessageIndex]);                currentMessageIndex++;                long currentTime = System.currentTimeMillis();                if ( currentTime - startTime >= totalTime)                {                    DismissThread dThread = new DismissThread();                    application.invokeLater(dThread);                }            }        }    }
    
        private class DismissThread implements Runnable     {        public void run()         {                        dismiss();        }    }}
    

    Concerning

    Bika

  • How to set a background image

    HY guys, I'm trying to set a background image on a Blackberry screen. I used this code, but the image dousen can't cover the full screen. Can someone me say what the problem is, or give me an example of how's done it? package mypackage;

    SerializableAttribute public class BackgroundImage extends UiApplication
    {
    Imagearriereplan private bitmap;
    fieldBitmap private bitmap;
        
    Public Shared Sub main (String [] args)
    {
    BackgroundImage PAP = new BackgroundImage();
    theApp.enterEventDispatcher ();
    }
        
    public BackgroundImage()
    {
    The background image.
    Imagearriereplan = Bitmap.getBitmapResource ("loginBackground.png");
            
    Display display = new MainScreen();
            
    HorizontalFieldManager horizontalFieldManager = HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH | nouveau HorizontalFieldManager.USE_ALL_HEIGHT) {}
                
    Override the paint method to draw the background image.
    public void paint (Graphics graphics)
    {
    Draw the background image, then paint.
    graphics.drawBitmap (0, 0, 240, 240, Imagearriereplan, 0, 0);
    Super.Paint (Graphics);
    }
                
    };
            
    The LabelField will be visible through the transparent image.
    LabelField labelField is new LabelField ("is a label");.
            
    A bitmap with a transparent image field.
    The background image will be visible through the transparent BitMapField image.
    BitmapField bitmapField = new BitmapField (Bitmap.getBitmapResource ("field.png"));

    Add the handler to the screen.
    mainScreen.add (horizontalFieldManager);
            
    Add the fields to the Manager.
    horizontalFieldManager.add (labelField);
    horizontalFieldManager.add (bitmapField);
            
    Tap on the screen.
    pushScreen (mainScreen);
    }
    }

    Thanks in advance

    You can scale the image with EncodedImage, but it is usually best to use an image with a sufficient size

  • 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.

  • New error screen

    Hi, I have the following code

    import net.rim.device.api.system.Bitmap;
    import net.rim.device.api.ui.component.ButtonField;
    import net.rim.device.api.ui.component.BitmapField;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.container.MainScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    import net.rim.device.api.ui.*;
    public class AppLogoMainscreen extends MainScreen {
        public AppLogoMainscreen() {
                Bitmap logoBitmap = Bitmap.getBitmapResource("App_Logo.png");
                BitmapField bmf = new BitmapField(logoBitmap, BitmapField.FOCUSABLE)
                {
                    protected boolean navigationClick(int status, int time)
                    {
                        createAndDisplayMainMenu();
                        close();
                        return true;
                    }
                };
                add(bmf);
        }
        public void createAndDisplayMainMenu() {
            MainScreen newScreen = new MainScreen(Manager.NO_VERTICAL_SCROLL|Manager.NO_VERTICAL_SCROLLBAR);
            VerticalFieldManager backgroundManager = new VerticalFieldManager(Manager.USE_ALL_WIDTH|Manager.USE_ALL_HEIGHT)
            {
                Bitmap logoBitmap2 = Bitmap.getBitmapResource("football.jpg");
                Bitmap shirtBitmap1 = Bitmap.getBitmapResource("football.jpg");
                Bitmap shirtBitmap2 = Bitmap.getBitmapResource("football.jpg");
                Bitmap shirtBitmap3 = Bitmap.getBitmapResource("football.jpg");
                Bitmap shirtBitmap4 = Bitmap.getBitmapResource("football.jpg");
                Bitmap shirtBitmap5 = Bitmap.getBitmapResource("football.jpg");
                Bitmap shirtBitmap6 = Bitmap.getBitmapResource("football.jpg");
                Bitmap shirtBitmap7 = Bitmap.getBitmapResource("football.jpg");
                Bitmap shirtBitmap8 = Bitmap.getBitmapResource("football.jpg");
                int imgWidth = logoBitmap2.getWidth();
                int imgHeight = logoBitmap2.getHeight();
                int imgWidth1 = shirtBitmap1.getWidth();
                int imgHeight1 = shirtBitmap1.getHeight();
                int imgXPos = 5;
                int imgYPos = 15;
                int imgTop = 0, imgLeft = 0;
                public void paint(Graphics graphics)
                {
                    graphics.setBackgroundColor(Color.PALEGREEN);
                    graphics.clear();
                    graphics.setColor(Color.FORESTGREEN);
                    graphics.fillRect(0, 0, 480, 80);
                    graphics.fillRect(0,0, 20, 360);
                    graphics.fillRect(460, 0, 20, 360);
                    graphics.fillRect(0, 340, 480, 20);
                    graphics.drawBitmap(imgXPos, imgYPos, imgWidth, imgHeight, logoBitmap2, imgLeft, imgTop);
                    imgXPos = 425;
                    graphics.drawBitmap(imgXPos, imgYPos, imgWidth, imgHeight, logoBitmap2, imgLeft, imgTop);
                    graphics.drawBitmap(45, 95, imgWidth1, imgHeight1, shirtBitmap1, imgLeft, imgTop);
                    imgWidth1 = shirtBitmap2.getWidth();
                    imgHeight1 = shirtBitmap2.getHeight();
                    graphics.drawBitmap(45, 156, imgWidth1, imgHeight1, shirtBitmap2, imgLeft, imgTop);
                    imgWidth1 = shirtBitmap3.getWidth();
                    imgHeight1 = shirtBitmap3.getHeight();
                    graphics.drawBitmap(45, 217, imgWidth1, imgHeight1, shirtBitmap4, imgLeft, imgTop);
                    imgWidth1 = shirtBitmap4.getWidth();
                    imgHeight1 = shirtBitmap4.getHeight();
                    graphics.drawBitmap(45, 278, imgWidth1, imgHeight1, shirtBitmap3, imgLeft, imgTop);
                    imgWidth1 = shirtBitmap5.getWidth();
                    imgHeight1 = shirtBitmap5.getHeight();
                    graphics.drawBitmap(365, 95, imgWidth1, imgHeight1, shirtBitmap7, imgLeft, imgTop);
                    imgWidth1 = shirtBitmap6.getWidth();
                    imgHeight1 = shirtBitmap6.getHeight();
                    graphics.drawBitmap(365, 156, imgWidth1, imgHeight1, shirtBitmap5, imgLeft, imgTop);
                    imgWidth1 = shirtBitmap7.getWidth();
                    imgHeight1 = shirtBitmap7.getHeight();
                    graphics.drawBitmap(365, 217, imgWidth1, imgHeight1, shirtBitmap6, imgLeft, imgTop);
                    imgWidth1 = shirtBitmap8.getWidth();
                    imgHeight1 = shirtBitmap8.getHeight();
                    graphics.drawBitmap(365, 278, imgWidth1, imgHeight1, shirtBitmap8, imgLeft, imgTop);
                    super.paint(graphics);
                }
            };
            ButtonField premierButton;
            ButtonField champButton;
            ButtonField div1Button;
            ButtonField div2Button;
            ButtonField confButton;
            premierButton = new ButtonField("Premiership", Field.FIELD_HCENTER){
                protected boolean navigationClick(int status, int time)
                {
                    createAndDisplayPremiership();
                    getScreen().close();
                    return true;
                }
            };
            champButton = new ButtonField("Championship", ButtonField.CONSUME_CLICK|Field.FIELD_HCENTER);
            div1Button = new ButtonField("League 1", ButtonField.CONSUME_CLICK|Field.FIELD_HCENTER);
            div2Button = new ButtonField("League 2", ButtonField.CONSUME_CLICK|Field.FIELD_HCENTER);
            confButton = new ButtonField("Conference", ButtonField.CONSUME_CLICK|Field.FIELD_HCENTER);
            LabelField labelField = new LabelField();
            backgroundManager.add(labelField =  new LabelField("Football Ground App", Field.FIELD_HCENTER)
            {
                protected void paint(Graphics g) {
                    int prevColor = g.getColor();
                    prevColor = (Color.RED);
                    g.setColor(Color.WHITE);
                    super.paint(g);
                    g.setColor(prevColor);
                    }
            });
            Font myFont = Font.getDefault().derive(Font.BOLD | Font.ITALIC, 11, Ui.UNITS_pt);
            labelField.setFont(myFont);
            backgroundManager.add(labelField = new LabelField("For BlackBerry", Field.FIELD_HCENTER)
            {
                protected void paint(Graphics g) {
                    int prevColor = g.getColor();
                    g.setColor(Color.WHITE);
                    super.paint(g);
                    g.setColor(prevColor);
                }
            });
            labelField.setFont(myFont);
            premierButton.setMargin(10,20,3,20);
            backgroundManager.add(premierButton);
            champButton.setMargin(3,20,2,20);
            backgroundManager.add(champButton);
            div1Button.setMargin(3,20,2,20);
            backgroundManager.add(div1Button);
            div2Button.setMargin(3,20,2,20);
            backgroundManager.add(div2Button);
            confButton.setMargin(3,20,2,20);
            backgroundManager.add(confButton);
            newScreen.add(backgroundManager);
            UiApplication.getUiApplication().pushScreen(newScreen);
        }
        public void createAndDisplayPremiership(){
            MainScreen newScreen1 = new MainScreen(Manager.NO_VERTICAL_SCROLL|Manager.NO_VERTICAL_SCROLLBAR);
            LabelField labelField = new LabelField("For BlackBerry", Field.FIELD_HCENTER);
            newScreen1.add(labelField);
            UiApplication.getUiApplication().pushScreen(newScreen1);
        }
    }
    

    Hello

    Check this code.

    Please mark as resolved messages if you found a solution.
    Feel free to press the Bravo thank the user who has helped you

  • Fields button

    Hi, I have the following code, in which case I would have some button fields made visible within the application. My code is as follows:

    This is a replacement code that corrects a number of problems with your code.  I suggest you compare that with your code and see if you understand what the parties are trying to do.

    You will find a reference very valuable.

    http://supportforums.BlackBerry.com/T5/Java-development/MainScreen-explained/Ta-p/606644

    Import net.rim.device.api.system.Bitmap;
    Import net.rim.device.api.system.Display;
    Import net.rim.device.api.ui.component.ButtonField;
    Import net.rim.device.api.ui.component.BitmapField;
    Import net.rim.device.api.ui.component.LabelField;
    Import net.rim.device.api.ui.container.MainScreen;
    Import net.rim.device.api.ui.container.VerticalFieldManager;
    Net.rim.device.api.ui import. *;
    SerializableAttribute public class AppLogoMainscreen extends form {}
    public AppLogoMainscreen() {}
    Bitmap logoBitmap = Bitmap.getPredefinedBitmap (Bitmap.EXCLAMATION);
    BMF BitmapField = new BitmapField (logoBitmap, BitmapField.FOCUSABLE)
    {
    protected boolean navigationClick (int status, int time)
    {
    createAndDisplayMainMenu();
    Close();
    Returns true;
    }
    };
    Add (BMF);
    }
    public void createAndDisplayMainMenu() {}
    Screen newScreen = new MainScreen(Manager.NO_VERTICAL_SCROLL |) Manager.NO_VERTICAL_SCROLLBAR);
    VerticalFieldManager backgroundManager = VerticalFieldManager(Manager.USE_ALL_WIDTH | nouveau Manager.USE_ALL_HEIGHT)
    {
    Bitmap logoBitmap2 = Bitmap.getPredefinedBitmap (Bitmap.EXCLAMATION);
    int imgWidth = logoBitmap2.getWidth ();
    int imgHeight = logoBitmap2.getHeight ();
    int imgXPos = 5;
    int imgYPos = 15;
    int imgTop = 0, imgLeft = 0;
    public void paint (Graphics graphics)
    {
    graphics.setBackgroundColor (Color.PALEGREEN);
    Graphics.Clear;
    graphics.setColor (Color.FORESTGREEN);
    graphics.fillRect (0, 0, 480, 80);
    graphics.fillRect (0.0, 20, 360);
    graphics.fillRect (460, 0, 20, 360);
    graphics.fillRect (0, 340, 480, 20);
    graphics.drawBitmap (imgXPos, imgYPos, imgWidth, imgHeight, logoBitmap2, imgLeft, imgTop);
    imgXPos = 425;
    graphics.drawBitmap (imgXPos, imgYPos, imgWidth, imgHeight, logoBitmap2, imgLeft, imgTop);
    Super.Paint (Graphics);
    }
    };
    ButtonField premierButton;
    ButtonField champButton;
    ButtonField div1Button;
    ButtonField div2Button;
    ButtonField confButton;
    premierButton = new ButtonField ("Premiership", ButtonField.CONSUME_CLICK);
    champButton = new ButtonField ("Champtionship", ButtonField.CONSUME_CLICK);
    div1Button = new ButtonField ("L1", ButtonField.CONSUME_CLICK);
    div2Button = new ButtonField ("Leauge 2", ButtonField.CONSUME_CLICK);
    confButton = new ButtonField ("Conférence", ButtonField.CONSUME_CLICK);
    backgroundManager.add (premierButton);
    backgroundManager.add (champButton);
    backgroundManager.add (div1Button);
    backgroundManager.add (div2Button);
    backgroundManager.add (confButton);
    LabelField labelField = new LabelField();
    backgroundManager.add (labelField = new LabelField ("Football Ground App", Field.FIELD_HCENTER)
    {
    protected void paint (Graphics g) {}
    int prevColor = g.getColor ();
    g.setColor (Color.WHITE);
    Super.Paint (g);
    g.setColor (prevColor);
    }
    });
    Font myFont = Font.getDefault (.derive(Font.BOLD |)) Font.ITALIC, 11, Ui.UNITS_pt);
    labelField.setFont (myFont);
    backgroundManager.add (labelField = new LabelField ("For BlackBerry", Field.FIELD_HCENTER)
    {
    protected void paint (Graphics g) {}
    int prevColor = g.getColor ();
    g.setColor (Color.WHITE);
    Super.Paint (g);
    g.setColor (prevColor);
    }
    });
    labelField.setFont (myFont);
    newScreen.add (backgroundManager);
    UiApplication.getUiApplication () .pushScreen (newScreen);
    }
    }

    Good luck...

  • problem with the vertical field Manager

    Hello

    My application has a screen. On this, I add a Senior Manager vertical field. I add new labelfields dynamically to this vertical field Manager.  When I give the text in the constuctor of the etiquette field, each of them is the fine display. But when I tried to draw the text to the painting, it does not appear.

    Here is my code...

    vfm = new VerticalFieldManager(VERTICAL_SCROLL | FOCUSABLE);
            for (int i = 0; i < 4; i++) {
                index = i;
                LabelField labelField = new LabelField() {
                    protected void paint(Graphics graphics) {
                        // TODO Auto-generated method stub
    //                  super.paint(graphics);
                        graphics.setColor(Color.BLACK);
                        graphics.drawText(displayString[index], 0, 0);
                    }
                };
                vfm.add(labelField);
            }
            add(vfm);
    

    Please help me find a solution.

    First of all, stop saying that it is VerticalFieldManager who has done something bad for you. It has nothing to do with it.

    You use the index in your LabelField painting method. Use paint value is the current value of the index at the time of the painting. Painting happens way after you have created all your LabelFields, when the index stopped to change and has the last value of the loop variable (in your case, it's 3).

    This, as well as LabelFields width zero (that you seem to have supported) so are the problems of your original code. Store the value of i in your LabelField somehow if you insist on using the table values. If only check out you them once and do not change them, consider creating your LabelFields with the text from this displayString table.

    Even better: as you do not use the LabelField paint, why not create a custom field received a text and paint your smileys and all? Of course, you have to implement available as well, but it's useful even when your smileys will take a different width than the corresponding symbols.

    To summarize: your current approach is bad. Take a step back, work on the design, and then implement.

  • popupscreen extention problem

    Hello everyone.

    I am trying to open a java popupscreen of an extention and shows me the following error message, telling me that I am doing wrong or if it is an example.

    java.lang.IllegalStateException: interface engine user accessed without holding the lock on the event.

    package samplecode;
    
    import net.rim.device.api.script.ScriptableFunction;
    import net.rim.device.api.system.Alert;
    import net.rim.device.api.ui.UiApplication;
    
    public final class AlertFunction extends ScriptableFunction {
    
        public Object invoke(Object obj, Object[] args) throws Exception {
           if (!Alert.isVibrateSupported()) {
              return UNDEFINED;
           }
           if (args.length == 1) {
              int duration = ((Integer)args[0]).intValue();
              Alert.startVibrate(duration);
              box vbox = new box();
                UiApplication.getUiApplication().pushScreen(vbox);
                //UiApplication.getUiApplication().popScreen(vbox);
           }
           return UNDEFINED;
        }
    }
    
    package samplecode;
    
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.component.ButtonField;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.container.PopupScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    
    public class box extends PopupScreen {
    
        /**
         *
         */
        public box() {
            super(new VerticalFieldManager());
            LabelField labelField = new LabelField("Popup Screen",
                    Field.FIELD_HCENTER);
            add(labelField);
            ButtonField btnfldOk = new ButtonField("OK", ButtonField.CONSUME_CLICK
                    | Field.FIELD_HCENTER);
            btnfldOk.setMinimalWidth(100);
            add(btnfldOk);
            ButtonField btnfldCancel = new ButtonField("Cancel",
                    ButtonField.CONSUME_CLICK | Field.FIELD_HCENTER);
            add(btnfldCancel);
            // TODO Auto-generated constructor stub
        }
    
    }
    

    Hi chicoxml,

    This line is your problem:

    UiApplication.getUiApplication () .pushScreen (vbox);

    The problem and the solution is very well described in this thread. Check it out and let me know if it solved for you:

    http://supportforums.BlackBerry.com/T5/Java-development/updating-UI-from-system-thread-UI-engine-ACC...

  • 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.

  • Adding fields to a Manager different button clicks

    if (field == buttonField && label.equals("First")) {
                LabelField label = new LabelField("1");
            add(label);
            buttonField.setLabel("Last");}
    else if (field == buttonField && label.equals("Last")) {
            buttonField.setLabel("First");
            labelField2 = new LabelField("2");
            add(labelField2);
            labelField3 = new LabelField("3");
            add(labelField2);
    }
    

    Here is an example of my FieldChangeListener. It is clear what he does (even for me clear ). It simply adds fields - a field to the first button clicks - and two others to the second click.

    What I want to do is to add these fields to a manager - regardless of the vertical or horizontal, I just need to get the concept of how it should be done. The idea is to build a manager at the first click on a button and add labelField. When the second click occurs, I need this Manager to add an other field (s), for example as in my example code.

    Could you please indicate the way to do this? It might be very obvious of sth, yet lack me.

    EDIT: spelling errors, sorry...

    Edit2: Can it be reached via setter/getter?

    Setter / getter did the trick.

    if (field == buttonField && label.equals("First")) {
                getHFM();
                    LabelField label = new LabelField("1");
            setHFM().add(label);
            buttonField.setLabel("Last");
    }
    else if (field == buttonField && label.equals("Last")) {
            buttonField.setLabel("First");
            labelField2 = new LabelField("2");
            setHFM().add(labelField2);
            labelField3 = new LabelField("3");
            setHFM().add(labelField2);
    }
    
    public HorizontalFieldManager getHFM(){
            hfm = new HorizontalFieldManager(USE_ALL_WIDTH);
            add(hfm);
            return hfm;
    }
    public HorizontalFieldManager setHFM() {
            return hfm;
    }
    
  • In the vertical scroll text Manager

    I have a Vertical Manager who has a background image. I add LabelFields number above it. My manager Vertical is scrollable. But wen I scroll the image background all scrolls, while I want the text to scroll only

    You have two options:

    (a) either paint the picture in a new position whenever you highlight, or

    (b) have a scroll with no specific experience (transparent) Manager and adds it to a full screen, no Manager scroll that contains the background Image.

    (b) is my choice.

    You can learn more about this sort of thing here:

    http://supportforums.BlackBerry.com/T5/Java-development/MainScreen-explained/Ta-p/606644

    Make sure you read the comments too.

Maybe you are looking for

  • system tray icon

    How can I reduce a VI to an icon in the tray (7,8,8.1) Windows system?

  • Unable to add the printer connection

    Add a new workstation to a domain, and when I try to use a printer on the network, I get this error when choosing a printer.

  • PAP2 - other party hears their voice in echo

    Hi all I love using my PAP2 because calls are massively less expensive but when you call people they often say I its really quiet or they can hear their own voice when they speak, using echo to come back home they find boring. Can someone help me fix

  • Network adapter wireless Xbox 360 for use in Windows 7 64 bit?

    I had a load of questions to try to locate the driver for the xbox 360 Wireless network adapter to use on my 64-bit windows computer 7. Is there a rare pilot that I've simply not found? or is there something entirely inconsistent with a material more

  • wireless clients do not receive correct dhcp addresses

    Hi all, I'm sorry first if this is a stupid problem. I am new to Cisco network. I need assistance with an existing configuration made by my seller. Environment: 1 core switch - 6509e catalyst VLANS configured: a. vlan 50 (wireline customers) 10.0.50.