Update of the main screen at the click of the button

Hello world.

I am very new to BB programming without any programming background at all (I am a philologist). Just try to understand everything now.

I wrote a test code (in this case OS5) who must do the following - the main screen contains a key, which would add a text on the main screen.

The code goes here:

Class MyApp

package mypackage;

import net.rim.device.api.ui.UiApplication;

public class MyApp extends UiApplication
{
    public static void main(String[] args)
    {
        MyApp theApp = new MyApp();
        theApp.enterEventDispatcher();
    }

    public MyApp() {
        pushScreen(new MyScreen());
    }
}

Class MyScreen

package mypackage;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen; 

public final class MyScreen extends MainScreen implements FieldChangeListener {
    private ButtonField buttonField;
    private MyScreen myScreen;

    public MyScreen() {
        setTitle("Test clock");
        buttonField = new ButtonField("Press me", ButtonField.CONSUME_CLICK);
        add(buttonField);
        buttonField.setChangeListener(this);
    }

    public void fieldChanged(Field field, int context) {
        if (field == buttonField) {
            go();
        }
    }

    private void go() {
        synchronized(UiApplication.getEventLock()) {
            myScreen.appendLabelText("Update");
        };
    }

    public void appendLabelText(String text) {
        LabelField labelField;
        labelField = new LabelField();
        labelField.setText(labelField.getText() + " \r\n" + text);
    }
}

Could someone make it clear to me how I can get the expected result of what I have?

Thanks for your help.

to correct the code above you can:
-set the LabelField as a class variable
-Add the LabelField on-screen
-call setText on this LabelField rather than your method appendLabelText

Tags: BlackBerry Developers

Similar Questions

  • After I updated, now the buttons on sites are inactive (I clicked and nothing happens). I tried a lot of things. What is going on?

    I tried to reinstall Firefox - no change. In Internet Explorer, all the buttons are active - this only happens in Firefox. 'Some' buttons 'certain' sites are active. But most of the buttons are inactive - the cursor placed above the button does nothing.

    The extension of the Yahoo! toolbar and the extension of Babylon have been reported because of this problem. Disable or uninstall the modules.

       * https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes
    
  • Problems with the UI Flash CC. Mainly, I can't click on some buttons and textboxes on different modal windows. (for example. Scale and rotate the sound properties.

    Hello

    I was wondering if anyone else has problems of this kind. I basically only to find a bunch of different buttons, fields and the tabs do not respond to my clicks. This seems to be spread throughout the application.

    I had to work around most of this by using the tab and arrow keys to navigate around the modal buttons and fields... but it's a bit of a pain.

    There are certain parts of the interface that are not accessible via the tabs and the arrow keys... for example tab ActionScript in the Sounds Properties window... There is no way to do that... and by clicking on the tab itself does nothing, although I can see that the rollover of the tab State is enabled.

    I ended up having to run Flash CS6 in order to define the classes of the export of audio files, and it's a major pain.

    Interface issues similar user exist with other things... for example, the color picker (eyedropper) seems to choose colors near, but not directly under him.

    I'll be honest... I'm running on Windows 7... Via boot camp on a Mac Book Pro with the retina display... so questions could come from this combination. However... Flash CS6 has these questions... so I can only think that it is a matter of Flash CC.

    I appreciate any input you can provide. (Although the obvious 'it on OSX rather run' or "just use CS6" are not the kind of responses I'm looking for.) I have my reasons for installation. )

    Thank you.

    Cheerfully,.

    -JR

    Mohan thanks!

    Scaling text to 100% actually works!

    After that I changed the scale to 125%, it still works (which was not planned)

  • Lost the rear button after the update and the button how to get back home?

    Firefox updated to 7 and I lost all my Add ons including the home button and the front/rear button. I could get all my Add ons restored except for the home button and the forward/backward buttons. How to make a comeback? Wish now that I had not updated.

    Make sure that you are not running Firefox mode full screen with all the hidden toolbars.

    • Press F11 to toggle mode full screen (file/Firefox > fullscreen)

    If the menu bar is hidden, then press the F10 key or hold down the Alt key, which should make the convening of menu bar.

    Make sure the toolbars like the toolbar 'Navigation' and the 'personal bar' are visible: "view > toolbars".

    • Is he missing elements then open the window customize via "view > toolbars > customize" or "Firefox > Options > toolbars" (Linux, Windows)
    • If a missing element is located in the toolbar palette and then bring her back in the window customize the toolbar
    • If you don't see an item on a toolbar and in the toolbar palette, then click on the "Restore default" button to restore the default toolbar set up.

    See also:

  • Update of the main screen to a background thread

    Hi guys im trying to update the main screen from a background thread. in this case I'm using a 2 static pictures. Once I click on a butotn on the popupScreen when the application is loaded, it will update the image on the main screen.

    I wrote a small excerpt for it and can you please give me some help with this. because when I've debugged and one of the developers helped me thereby to discover that the screen im trying to update is not the active screen.  Please have alook please.ive extract have 3 classes here

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    SerializableAttribute public class MyApp extends UiApplication
    {

    Public Shared Sub main (String [] args)
    {
    Create a new instance of the application and make the currently
    who runs the thread of the application of the event dispatch thread.
    MyApp PAP = new MyApp();
    theApp.enterEventDispatcher ();
    }
        
    /**
    * Creates a new object MyApp
    */
    public MyApp()
    {
    Push a screen onto the stack in the user interface for rendering.
    pushScreen (new MyScreen());
    final Pinpopup pp = new Pinpopup();

    UiApplication.getUiApplication () .invokeLater (new Runnable()
    {
    public void run()
    {
    UiApplication.getUiApplication () .pushModalScreen (pp);
    }
    });
    }
    }
    ////////////////////////////////////////////////////////////////////////////////////////

    / public final class screen extends MyScreen
    {
    /**
    * Creates a new object of MyScreen
    */
    public Bitmap bmp image;
    public BitmapField bmpField;
    public ButtonField btnDisplay;
    public ImageThread imgThread;
            
    public MyScreen()
    {
            
    Set the displayed title of the screen
    setTitle ("MyTitle");
    BMP = Bitmap.getBitmapResource ("image.png");
    btnDisplay = new ButtonField ("Display");
    bmpField = new BitmapField (bmp);

    btnDisplay.setChangeListener (new FieldChangeListener() {}
                
    ' Public Sub fieldChanged (field field, int context) {}
    TODO self-generating method stub
                    
    if(Field == btnDisplay)
    {
    BMP = Bitmap.getBitmapResource ("image1.png");
    bmpField.setBitmap (bmp);
    signInButtonClicked ("07760926037", "1234");
    LaunchImageThread();
                        
    }
    }
    });
            
    Add (bmpField);
    Add (btnDisplay);
            
    }
        
        
    Public Sub LaunchImageThread()
    {
    imgThread = new ImageThread (this);
    System.out.println ("THIS screen:" + this.getScreen ()); I realized that the im screen update is not active but its strange I don't create any other refrence so
    New Thread (imgThread) m:System.NET.HttpListener.start ();
    }
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// POPUPSCREEN CLASS
    class Pinpopup extends PopupScreen //implements FieldChangeListener
    {
    private ButtonField btnOk;
        
    Pinpopup()
    {
            
    Super (new HorizontalFieldManager());

    btnOk = new ButtonField ("Sign In");

    btnOk.setChangeListener (new FieldChangeListener() {}

    ' Public Sub fieldChanged (field field, int context)
    {
    TODO self-generating method stub
    Try
    {
    if(Field == btnOK)
    {
    Close();
    MyScreen ms = new MyScreen();
    Mrs. LaunchImageThread();
    }
    } catch (IllegalArgumentException e) {}
    TODO: handle exception
    System.out.println ("Exception Popup all in signingIn" + e.getMessage ());
    }
    }
    });
            
    Manager fieldManagerContext = new Manager (USE_ALL_WIDTH)
    {
    ' public void sublayout (int width, int height) {}

    int xPos = 10;
    int ypos = 40;

    Field = getField (0);
    layoutChild (field, 280, 50);
    setPositionChild (field, xpos ypos + 100 + 165);

    setPosition (300, 300);
    setExtent (350, 225);
    }
    };
            
    fieldManagerContext.add (btnOk);
    Add (fieldManagerContext);
    }
    }

    /////////////////////////////////////////////////////////////////////////////////////////////////////

    / public class ImageThread implements Runnable
    {
    private MyScreen parent;
        
    public ImageThread (MyScreen myScreen)
    {
    parent = myScreen;
    }

    public void run()
    {
    Try
    {
    UiApplication.getUiApplication () .invokeLater (new Runnable() {}
                    
    public void run() {}
    TODO self-generating method stub
    System.out.println ("active screen:" + UiApplication.getUiApplication () .getActiveScreen ());
    System.out.println ("active screen:" + parent.getScreen ());
    parent.bmp = Bitmap.getBitmapResource ("image1.png");
    parent.bmpField.setBitmap (parent.bmp);
                        
    }
    });
    }
    catch (Exception ex)
    {
    System.out.println ("Exception in Thread:" + ex.getMessage ());
    }
    }
    }

    was soon thanks

    I suspect that this is your problem:

    MyScreen ms = new MyScreen();
    Mrs. LaunchImageThread();

    I suspect that if you did as I suggested on the other Thread and put a breakpoint in the constructor of MyScreen, you'd have foiund, this creates a second instance.

    I hope that you can take it from here.

  • How can I get the LR 5.7 update?  Whenever I click on the button download, trying to sell me stuff cloud the start screen appears.  I don't want to buy anything, I just want to download the update.  Anyone know how?

    How can I get the LR 5.7 update?  Whenever I click on the button download, trying to sell me stuff cloud the start screen appears.  I don't want to buy anything, I just want to download the update.  Anyone know how?

    Hi Don. You can find it here: updates

  • With the help of A6, must create menu screen which allows the user to click a button creates a branch to other screens and return to the main menu. When returning to the main screen on which button will be gray or inactive.  How can I do this?  I created

    I am trying to imitate a piece of equipment.  I need the user to be able to click on the specific buttons that have the user to another or screens.  After viewing these screens that will be the user to the main screen where the user which buttons were pressed and which still needed to be pressed.  I create buttons image with the 3 States - who has worked except when the user returns to that slide is reset to zero, and if the user does not see the 3rd State of the button.  How can I get this 3rd State of stay after the user returns to the main screen?

    You can not 'keep' a State, that's what I said in my first answer: "you can create an image with that look of '3' State, make it invisible and show it with the same action when a button is triggered. You will need to insert extra that third picture, first hide it out and make it visible to the advanced action, which I explained. I called this additional 'Done_one' image in the example. The three States you're talking about are in a totally different way to Captivate: for down, more and up-state. You can just tell Captivate to keep a low State, it will be down when the button is pressed. Where my explanation of an additional image.

    No need for all the variables. Looks like you have a lot to learn about variables and advanced actions. I don't see another easy way to achieve what you want. It is not so difficult, tons of examples on my blog.

  • 'Reply' / 'Write' form is hidden behind the main screen of you bird

    Since I updated to the latest version of you bird (v.24.6) last week, I am unable to make the electronic form forward when displaying the main screen of boxes to letters. By clicking on the edge of the screen to answer/write will show it only momentarily, then he is hiding behind the screen of mailboxes. To write a new email, I have to minimize the mailbox main screen.

    I looked for an option that will allow the form of response/writing stay on top, but fails. I made no changes to the options when I updated. I forget a new option somewhere?

    Thanks for any help
    P.S. Win 7 x 64

    Matt,

    You nailed it. Without the Add-ons, it works as it should. Now, I have to determine which of my modules is the culprit. I have day some after I installed the last you bird. I have not that much, so it should be an easy thing to disable all and then putting back one by one.

    Thank you.

  • How the external monitor, my main screen and not the laptop?

    I went to devices-> project->, extend, but the only option seems to be the laptop as main screen and the secondary monitor. I would like to the external monitor to the main screen. I did it on other computers, probably, it is possible with the updated technology?

    Any help would be appreciated.

    Thank you

    Hi tide,

    I suggest you follow these steps on an external monitor as the primary display.

    a. drag from the right edge of the screen, tap settings, and then click change PC settings.
    (If you use a mouse, point to the corner bottom right of the screen, move the mouse to the top, click settings and then click Change PC settings).

    b. press or click on PCs and devices, and then tap or click on display.

    c. in the image preview, tap or click the monitor you want to use as the main screen for the select.

    d. Select the checkbox make of this my main screen .

    See the article for more information.

    Get the best display on your monitor
    http://Windows.Microsoft.com/en-us/Windows-8/get-best-display-monitor

    Note: applies to Windows 8.

    Hope this information helps. Answer the post with an up-to-date issue report to help you further.

  • Apple Watch is a day of rest on the main screen

    I noticed this morning that my Apple Watch is one day behind the main screen. The calendar is correct, however. Is there any solution for this?

    Hello

    If you have not already done so, it can help to upgrade your iPhone and Apple Watch to the latest version of the software, from your iPhone:

    Otherwise, the following steps may help:

  • Problem with the main screen of firefox

    After the update of firefox to firefox 15.0 16.0.2's problem with the main screen. At the top of the main screen displays the bar (caption bar of the main form) that I have win xp and under this title is bar legend like win 7.

    Firefox is running on Windows Xp, if better, I can send the screen, but I don't know where is possible add image to this error report...

    Okay, the problem has been resolved, problem was with the Tab Mix Plus extension. I have an older version of this extension, because at work may not update directly, because I'm going to the Internet via a proxy. Download, update firefox extension directly through the proxy is not possible... I need to download via the other internet browser, in order to not do it often...

  • Windows move to the main screen when sleeping Satellite-S50T-B

    Satellite S50T-B, Windows 8.1. Whenever my laptop sleeps, it moves all the icons and windows open on the secondary external monitor on the laptop monitor. Like a lover double screen, it's extremely annoying. I keep having to set up my work space.

    I expect that there is a bug in the video driver, which means that she sees the monitor off as a result of the command 'sleep' of the laptop as a monitor "unplugged" and it is reported to the operating system for the operating system moves all the icons and windows on the main screen, so when I turn again, they are all in the wrong place.

    Please note that the disappearance of the screen as a direct result of it being sent a sleep command should not be interpreted in any way other than the monitor to sleep as said.

    The graphics driver is old way... When can we expect an update?
    When I can see a fix for this frustrating problem?

    Hello

    If you would google for this problem, you will find a lot of discussions and information about this system.

    From my point of few this issue is linked to the State in sleep mode. There are the States of sleep mode (S0, S1, S2, S3, S4)

    S3 is generally the default standby mode, while the S4 is generally the mode of hibernation by default.
    Here all the details:
    http://msdn.Microsoft.com/en-us/library/Windows/hardware/ff564575

    You can use the PowerCfg command to change these settings
    http://TechNet.Microsoft.com/en-us/library/cc748940%28V=WS.10%29.aspx

  • None of the icons are on the main screen of my office, how to make their comeback

    original title: a friend set a default language of English canada to American English, now none of my office, the icons are on the main screen, how can I get back them
    1. It seems that all my desktop icons are in a folder and when I click on an ex: banks in line, and click on move in or make shortcut, it is another in the same folder.
    1. It seems that all my desktop icons are in a folder and when I click on an ex: banks in line, and click on move in or make shortcut, it is another in the same folder.

    Try to return to the English Canada and see if the desktop icons reappear.  If they do, when the default language has changed he assumed you have created a new 'profile' perhaps and you see profile this profile's empty office.  Alternatively, if a new profile has been created, open the old profile (person) when you open a session.

  • Malwarebytes removed false windows recovery, but I don't have any main screen. I framed, the taskbar icon and firefox on the left side of the screen background

    Malwarebytes removed false windows recovery, but I don't have any main screen.  I have the sidebar, taskbar icon tasks and low firefox on the left side of the screen.  Any help appreciated

    Hello

    I see that the 1st poster came back and edited its reply which had erroneous information provided on the restoration of the system after reading my post

    Just click on the arrow next to the date in his response to the title "she may be useful" to see where it editing and time, it was edited

    I am pleased that the error was corrected by him

  • When I add a new file in a subfolder (folder in a folder) by using Solution Explorer, the 'date modified' in the subfolder is updated, however the "modification date" in the main folder is not changed.

    Is it possible to have the update of the main folder his "change date" when I change the contents of a subfolder?  I use VISTA.

    I don't know how to program so if you have a solution, I need step by step instructions.

    Thank you very much for your help.

    Donaldo

    This forum is dedicated to the issues of Windows 7.  To ask a question of Windows Vista, go to this page:

    http://answers.Microsoft.com/en-us/Windows/default.aspx#tab=3

    Furthermore, the parent folder (and her mother and so on) are not changed when the contents of a grandchild (or below) is updated, so their timestamp will not change.

    If it solves your problem, click on the link "Propose as answer" below and vote as useful by clicking on the green triangle for the lelft. Thank you!

Maybe you are looking for

  • Actual date is moved to the current if you click on the entry in the history

    So I have a weird problem. I need to retrieve the original date of my entry in navigation history because he moved to "today" and does not appear more where it was originally(3/3) after I clicked on it to verify that it was a correct URL I was lookin

  • Skype number forwarding does not...

    Hello I have setup a call forwarding for a Skype U.S. number So I have provided both fixed and mobile phone in Iran so all calls numbers can be sent to these numbers in case I'm not online, however, I get not all calls sent to these numbers? Can you

  • you will get a virus if you sign up for maplestory?

    you will get a virus if you sign up for maplestory?

  • Wireless signal detection

    I have a WRT160N router that I currently use. When I'm doing a my computer wireless signal, my router does not show up on top of the list. It is therefore on the list when I put up like WEP, but will not be displayed when I went back to WPA2. Does an

  • A undwanted in Windows 7 driver: vsflt53.sys

    How he removes one unwanted Windows 7 driver?  The driver is vsflt53.sys, that was installed when I used the Seagate Disk Wizard to migrate to a new drive.  Windows reported disk controller errors since the driver has been installed.  Wizard disk see