PopupScreen + LocationListener

I have tried to create a Popup (PopupScreen) that displays "search satellite...". "while I'm waiting for LocationListener to call. Once it is called, I put the location listener to null, and I try to fill the PopupScreen. No matter what I do I can't close. I get an IllegalStateException.

I looked in the forums, I've seen 100 threads that tell you how to do this, people link to these articles KB, but nothing works. I don't know if I'm just not thinking clearly, but I just can't understand it.

Basically... I'm trying to do something like:

screen = new PopupScreen(); pertend this is a message in it

UiApplication.getUiApplication () .pushScreen (form);

Critier criteria = new Criteria();

LocationProvider provider = new LocationProvider.getInstance (criteria);

provider.setLocationListener (new MyLocationListenerHere (this));

Then in my MyLocationListenerHere I want to lie...

MyLocationListener (form) {}

This.some_holder = screen;

}

{public locationUpdated Sub (LocationProvider provider, a place)

do things for contact information

UiApplication.getUiApplication () .popScreen (this.some_holder.screen);

}

IllegalStateException

Note: I just write this code now for this post, it gives you a good example of what I'm trying to do. If anyone can help me it would be GREATLY appreciated.

locationUpdated() runs as a background Thread.  In my view, that it is running in your Application, just to get your pop on your event feed!  Usually, it's pretty easy.  Assuming this works, then that's all you need:

{public locationUpdated Sub (LocationProvider provider, a place)

Final anti-pop = this.some_holder.screen;

UiApplication.getUiApplication () .invokeLater (new Runnable() {}

public void run() {}

UiApplication.getUiApplication () .popScreen (anti-pop);

}

};

do things for contact information

}

This code is written from memory, not tested, but I hope that you can find in her compilation errors.

Let us know how you go.

Tags: BlackBerry Developers

Similar Questions

  • Set the position of a PopupScreen

    Is there a way to define the position of top, on the left of a PopupScreen? SetPosition(x,y) call will throw this error:

    java.lang.IllegalStateException: setPosition called outside the layout

    I use JDE 4.2.1 8800 Simulator.

    Thank you

    Ryan

    Quote from the old forum:

    ligraseac

    Messages: 2
    Join date: Jun 2007

    Screen Popup position
    Posted the: June 29, 2007 05:45
     
    Hello

    How can I set the position of a popup screen? I want to set its position next to a field that has the focus.

    Thank you

    Comments: fjarlier
    Re: Screen Popup Position
    Posted the: 5 July 2007 17:10
     
    Hello

    In your class that extends the PopupScreen, you must override sublayout like this:

    ' public void sublayout (int width, int height) {}

    Super.sublayout (Width, Height);
    setPosition (50,50);
    }

    Because the setPosition can occurs only in the layout method. And then, you can position your PopupScreen anywhere you want.

    For me it works...

    If you have another solution, that I take.

    So long

    Fred

  • Problem with PopupScreen.updateLayout)

    Hello guys '

    I have a problem with PopupScreen. I'm doing the cursor on the PopupScreen. This popupScreen includes BitmapField with transparent image. And the main screen is BitmapField larger than the size of the screen. I want to move the cursor (PopupScreen) on the BitmapField.

    You see what I'm doing here. And I found the solution how to move PopupScreen since the last post. Now, I am facing the problem when the cursor (PopupScreen) on the left. In other words, when I move the slider to the left, it is not clear previous position. I don't know why.

    It works fine when moves right.

    And it is not clear the previous, when position moves to the left.

    So, you can see the code that I use.

    import net.rim.device.api.ui.component.*;import net.rim.device.api.ui.container.*;import net.rim.device.api.ui.*;import net.rim.device.api.system.Bitmap;import net.rim.device.api.system.KeyListener;
    
    public class CursorField extends UiApplication {
    
      private InfoPopupScreen progressPopup;    int x = 180;  int y = 120;  ManagedScreen managedScreen;  Bitmap _bitmap1;  Bitmap _bitmap2;  Bitmap _bitmap;   int [] fillTrans = new int[100];
    
      public CursorField() {
    
          _bitmap = Bitmap.getBitmapResource("cursor1.png");        _bitmap1 = Bitmap.getBitmapResource("cursor1.png");       _bitmap2 = Bitmap.getBitmapResource("cursor2.png");
    
          for(int i = 0; i < 100; i++) {         fillTrans[i] = 0xFFFFFF;      }
    
          managedScreen = new ManagedScreen();      pushScreen(managedScreen);    }
    
      private class InfoPopupScreen extends PopupScreen implements KeyListener {
    
          protected void applyTheme() {         //Nothing     }
    
          public boolean keyStatus(int keycode, int time) {         return false;     }
    
          public boolean keyRepeat(int keycode, int time) {         return false;     }
    
          public boolean keyUp(int keycode, int time) {         return false;     }
    
          public InfoPopupScreen(Manager manager){          super(manager);       }
    
          protected boolean navigationMovement(int dx, int dy, int status, int time) {
    
              return true;      }
    
          protected void paintBackground(Graphics graphics) {           graphics.setBackgroundColor(16777215);        }
    
          public void sublayout(int width, int height){         super.sublayout(width, height);           setPosition(x, y);        }
    
          public boolean keyDown(int keycode, int time) {
    
              char key =  net.rim.device.api.ui.KeypadUtil.getKeyChar(keycode, net.rim.device.api.ui.KeypadUtil.MODE_UI_CURRENT_LOCALE);            //To left         if(key == 79 || key == 111) {             x = x - 5;                progressPopup.updateLayout();         }                      if(key == 73 || key == 105) {             x = x + 10;               progressPopup.updateLayout();         }
    
              if(key == net.rim.device.api.system.Characters.ESCAPE) {              this.close();         }         return true;      }
    
          public boolean keyChar(char key, int status, int time) {          return false;     }
    
          public boolean trackwheelRoll(int amount, int status, int time) {         return false;     }
    
          public boolean trackwheelUnclick( int status, int time ) {            return false;     }
    
          public boolean trackwheelClick( int status, int time ) {          super.trackwheelClick(status, time);          return true;      } }
    
      private class ManagedScreen extends MainScreen {      private BitmapField _cursorField;
    
          public ManagedScreen() {
    
              _cursorField = new BitmapField(_bitmap) {             public void paint(Graphics graphics) {                    graphics.setBackgroundColor(16777215);                    super.paint(graphics);                }         };
    
              FlowFieldManager manager = new FlowFieldManager(FlowFieldManager.USE_ALL_HEIGHT | FlowFieldManager.USE_ALL_WIDTH) {               public void paint(Graphics graphics) {                    graphics.setBackgroundColor(16777215);                    super.paint(graphics);                }         };
    
              manager.add(_cursorField);            progressPopup = new InfoPopupScreen(manager);
    
              Bitmap pic = Bitmap.getBitmapResource("background.jpg");          BitmapField picField = new BitmapField(pic);          add(picField);
    
              ButtonField _closeButton = new ButtonField("Push screen", ButtonField.CONSUME_CLICK | ButtonField.FIELD_HCENTER);         _closeButton.setChangeListener(new FieldChangeListener() {                public void fieldChanged(Field field, int context) {                  pushScreen(progressPopup);                }         });
    
              add(_closeButton);        } }
    
      public static void main(String[] args) {      CursorField application = new CursorField();      application.enterEventDispatcher();   }}
    

    I hope you can solve my problem.

    TNX in advance"

    Ttry this...   In paintBackground(), call clear after you set the background color.

  • How to remove the global popupscreen?

    Hello everyone,

    I create the application such that when the application starts at the beginning so I put this request

    in the background and then I push the global popupscreen for help

    UiApplication.getUiApplication () .pushGlobalScreen (currentpopupScreen, 1, UiApplication.GLOBAL_MODAL);

    afterwords when I want to delete this global else popupscreen class, I used the following line of code

    UiApplication.getUiApplication () .popScreen (UiApplication.getUiApplication () .getActiveScreen ());

    but this gives the exception because UiApplication.getUiApplication () .getActiveScreen () returns null.

    So how to remove this global popupscreen? because the other class getActiveScreen () method returns null.

    Thanks in advance

    If I push two (or more) screens with the same priority, newest pushed overall appears on top. I tested.

    Thank you for your suggestion.

  • Quick question PopupScreen VerticalFieldManager:

    I'm building a contextual menu screen custom that displays two text fields, an OK and CANCEL button.  I use the VerticalFieldManager as the Manager.  I used the styles Field.FIELD_RIGHT and Field.FIELD_LEFT for the OK and CANCEL buttons to the OK button on the left side of the dialog box (under the text fields) and the button CANCEL on the right side.

    The only problem I have with the screen, it is that, since I'm on the VerticalFieldManager, the OK and CANCEL button are on different lines.  Is there a style of field that will put them on the same line, even if I use the VerticalFieldManager?  Or should I use a different Manager.

    Thanks in advance...

    mlisaoverdrive wrote:

    johnbibs wrote:

    Hi mlisaoverdrive,

    By defalt, popupscreen uses the vertical area manager, so that you can do is put two buttons in a HorizontalFieldManager. Then add the Manager of horizontalfield on the screen.

    Wait I'm confused... According to the docs, you must provide a handler delegate for PopupScreen.  Does not mean that it is not a default Manager?

    Sorry my bad, I was talking about the screen. in any case, just use the VerticalFieldManager as your cost of Manager. Then put your buttonFields in a single horizontal FieldManager. then after the addition of some fields in your form, add the horizontalfieldmanager in the last.

  • UiApplication using PopupScreen

    Hi all

    This is my first post on this amazing forum. I read through many large threads with lots of answers to the questions I had in my short time developing applications for the BlackBerry smartphone. Unfortunately, I hit my first stumbling block, which I'm sure will be very easy, but hey, we all start somewhere.

    The question that I'm doing the experience simply creates a PopupScreen in the mainevent thread and wait for user input before continuing. In my days of Swing I just use an observable model and notify the application of change, but I seem to have trouble with this concept here. I tried to use the pushModalScreen and the pushGlobalScreen of the UiApplication class methods, but both give me a runtime... error pushGlobalScreen called by thread of non-event.

    It seems to me missing something probably just in front of me, but I would appreciate help on this. I just use this example using the 9000 Simulator that is packed with the JDE v4.6

    public static void main(String[] args) {
            MyApp app = new MyApp();
            app.enterEventDispatcher();
        }
    
        MyApp() {
            final PromptTest prompt = new PromptTest();
            invokeLater(new Runnable() {
                public void run() {
                    pushGlobalScreen(prompt,1,UiApplication.GLOBAL_MODAL);
                }
            });
            continueProcess();
        }
    
        public void continueProcess() {
        // do something with input from PopupScreen
        }
    }
    

    Thank you.

    Well, I'm a little bit embarrassed. I have solved my problem. Using just pushScreen, like any other approach and all simply migrate code to deal with in my fieldChangeListener. I don't know what I thought earlier. I'm sorry to have lost someone's time on this one.

  • Cannot close the PopupScreen

    I have a PopupScreen, NHCustomPopupScreen.

    When a function is called, I display this screen:

    NGCustomPopupScreen ngcps = new NGCustomPopupScreen();
    UiApplication.getUiApplication () .pushScreen (ngcps);

    After the function finishes its work, I want to close the NGCustomPopupScreen.  I'm sure that this is my problem, but I'm not sure what to change here.

    UiApplication.getUiApplication () .popScreen (UiApplication.getUiApplication () .getActiveScreen ());

    The NGCustomPopupScreen does not close.  Everything continues to operate.  Looks like I'm missing something small on this one.

    Hey Champ,.

    the problem could be that the other screen is active at the moment.

    You can try adding the next checkig as:

    Screen = UiApplication.getUiApplication () .getActiveScreen ();

    If (NHCustomPopupScreen instanceof screen)
    {
    UiApplication.getUiApplication () .popScreen (screen);
    }

    Also if you have the screen reference I would more simple:

    NGCustomPopupScreen ngcps = new NGCustomPopupScreen();

    .....

    UiApplication.getUiApplication () .popScreen (ngcps);

    And also please wrap all the UI code inside the following construction (you will find more in the UI Developer's guide):

    Synchronize (UiApplication.getUiApplication (.getEventLock))

    {}

  • How to start a PopupScreen?

    Hello

    I am facing a strange problem with PopupScreen and how to throw one.

    I try to make a page "load" that is displayed during the execution of a thread.

    I started with a sample code here: http://supportforums.blackberry.com/t5/Java-Development/Sample-Please-Wait-or-Progress-Bar-Code/td-p...

    That's why the way I call the PopupScreen can be weird.

    My problem is that when I want to launch the anti-pop in the constructor of the screen, I have a RuntimeException and when I put it in a ButtonField change event and simulate the click event it works fine.

    So I was wondering what is the difference?

    For your information, this is my code that works:

    public final class ScreenCache extends MainScreen
    {
        Screen s;
        PleaseWaitPopupScreen waitScreen = null;
    
        public ScreenCache()
        {
            super(NO_VERTICAL_SCROLL | USE_ALL_WIDTH);
            s = this;
    
            ButtonField startButton = new ButtonField("Start", ButtonField.LEFT | ButtonField.CONSUME_CLICK);
            startButton.setChangeListener( new FieldChangeListener()
            {
                public void fieldChanged(Field field, int context)
                {
                    waitScreen = new PleaseWaitPopupScreen("Chargement", "Chargement des données");
    
                    ThreadCache _requestThread = new ThreadCache(waitScreen);
                    _requestThread.start();
    
                    UiApplication.getUiApplication().pushModalScreen(waitScreen);
    
                    UiApplication.getUiApplication().popScreen(s);
                    UiApplication.getUiApplication().pushScreen(new ScreenList());
                }
            });
            this.add(startButton);
    
            EventInjector.invokeEvent(new EventInjector.NavigationEvent(EventInjector.NavigationEvent.NAVIGATION_CLICK, 0, 0, 0));
            EventInjector.invokeEvent(new EventInjector.NavigationEvent(EventInjector.NavigationEvent.NAVIGATION_UNCLICK, 0, 0, 0));
        }
    
       protected void paint(Graphics graphics)
        {
            EncodedImage ei = EncodedImage.getEncodedImageResource("img/SplashScreen.png");
            EncodedImage ei2 = new ToolsImage().ResizeImage(ei, Display.getWidth(), 0);
    
            graphics.drawBitmap(new XYRect(0, 0, Display.getWidth(), Display.getHeight()), ei2.getBitmap(), 0, 0);
        }
    
       protected boolean onSavePrompt()
       {
           return true;
       }
    
    }
    

    My PopupScreen is very simple, it only shows text and animated images, so the problem probably isn't there.

    I'm on version 5.0 and I'm on the BlackBerry 9550 Simulator tetsing.

    Try using invokeLater pushModal, anti-pop and pushScreen calls.

    Scott

  • Menu remains visible after you make the selection, and does not show Popupscreen

    Hey. Unable to get a (a gaugefield) on a Popupscreen progress bar to show. It is called from a menu. The user clicks a menu item, and a method is called. The method among other pushes a Popupscreen containing a Gaugefield on display battery-code below. Then, he starts a thread which downloads an image and using join() to wait for it complete (long story). Then, in the thread of events, it appears the Popupscreen.

    The menu does not disappear when you click on it in the Simulator (JDE 4.7, the Bold 9700 sim), but the download happens. Once the download is complete, the menu disappears, the Popupscreen is shown and he tried to pop() Popupscreen, causing an IllegalArgumentException.

    I tried to split the method into two methods, the download happened in the 2nd method, because I read the forum search that the UIEngine don't update the display until the method finishes (it runs in the event thread). But it made no difference...

    How can I get this menu to disappear immediately and the push (popup) to work?

    See you soon!

    Justin.

                            progressbar = new GaugeField("", 0, 100, 50, GaugeField.NO_TEXT);
                            progress = new PopupScreen(new FlowFieldManager()) { protected void OnDisplay() { super.onDisplay(); /*cancelButton.setFocus();*/  }  };
                            globalTiles.pushScreen(progress);
    
                            progress.add(new LabelField("Downloading (rest of) picture ..."));
                            progress.add(progressbar);
                            progress.setFocus();
    
                            if (!threadbg.isAlive()) {
                                       threadbg = new ThreadForBgDownload();
                                       threadbg.start();
                            }
                            else {
                                       // Show the progress bar, mostly complete (it is running and was in the bg). Game will start after last bit done
                            }
    
                            threadbg.join(); // Wait for download thread to complete and 'die'
    
                            globalTiles.popScreen(progress);
    

    Rule #1: all display updates should occur on the thread event or synchronized on the lock of the event.

    Rule #2: the thread of events (or now the lock of the event) should never be blocked by lengthy operations.

    The scenario you sketched out is usually handled like this: menu item run() method don't whatever immediate user interface updates are necessary and starts a worker thread. It does not wait until the thread ends before returning. (If so, updates the user interface include pushing a "Please wait" or progress pop up). The worker, at the same time, begins to do its stuff. When it's time to update the user interface (either because the task is completed or to view progress) the worker thread usually called invokeLater (Runnable) (a method in the Application class) where the executable run() method updates the user interface. If the worker thread must receive user input in his work, he can use invokeAndWait (Runnable), where the executable not all interactions of the user and stores the user entry somewhere so that the worker thread can grab after invokeAndWait() returns.

    Although the synchronization on event lock works perfectly well, it is more common for some reason any to invoke a Runnable, perhaps because the latter clearly encapsulates in a separate object the work to be done on the event thread.

    The above policy is the basis of the excellent Peter Strange example I linked to before.

  • View PopupScreen on TouchEvent.DOWN - who is TouchEvent.UP?

    I am writing this post so much hope to get a response and, in the case I find myself, to post the answer with my findings.

    Here's the situation:

    I display (pushScreen invokeLater inside) a small PopupScreen (a bubble) when a user touches a field containing the ToolTip (title text, in HTML terminology) defined.

    When the user deletes the finger, I want the balloon go (anti-pop or close() the popup itself).  However, I can't know what screen - the screen below or above the PopupScreen - Gets the TouchEvent.UP in this situation.  Debugger does not help as much as it disrupts the sequence of key events.

    If someone has done something similar, please answer.

    Found the answer - person don't be TouchEvent.UP!  Thanks to a screen pushed the screen gets TouchEvent.CANCEL immediately, as soon as the balloon is visible.  Use the information as you see fit.

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

  • getVerticalScroll (PopupScreen) still 0?

    Hello

    IM using a PopupScreen to display options that will be painted by a BitmapField.

    Sometimes I have so many options, that the popupscreen scrolls down. With the touchEvent I use getY, but it returns there without the offset of scrolling. So I tried the getVerticalScroll of the screen. But, this method always returns 0?

    I build my dialog like this:

    public class OptionsDialog extends PopupScreen {
        public OptionsDialog() {
            super(new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL|VerticalFieldManager.VERTICAL_SCROLLBAR));
        }
    }
    

    I tried getVerticalScroll and getScreen (.getVerticalScroll).

    Funny, getManager returns null?

    Am I missing something?

    Thanks for your help

    Matthias

    Try

    this.getDelegateManager (.getVerticalScroll).

  • Size PopupScreen

    I have a popupScreen with a label on the inside. I think that my looks too big popupScreen for the font size of labels, it looks like this:

    I want to adjust the size of the popupScreen as the label to look like this:

    I tried to do this:

    public class myPoupScreen extends PopupScreen {
        private static LabelField etiqueta;
        private static int totalWidth;
        private static int totalHeight;
    
        public myPoupScreen(String text) {
            super(new VerticalFieldManager());
            etiqueta =  new LabelField(text, Field.FIELD_HCENTER);
            Font fuente = Font.getDefault().derive(Font.PLAIN, 5, Ui.UNITS_pt);
            etiqueta.setFont(fuente);
            totalWidth = Font.getDefault().getAdvance(etiqueta.getText()) + 6;
            totalHeight = fuente.getHeight() + 2;
            this.add(etiqueta);
        }
    
        public void sublayout(int width, int height){
            super.sublayout(totalWidth, totalHeight);
        }
    
    }
    

    But the screen is too small as if text when it is empty, I have the label can't be seen.

    As I understand it there is only a border for popup screens which is related theme.  The screen will always try to put it in, and so if you forced in a space that is large enough to display this fact and your label, then you will not see the label.

    I wibder if this is what is happening here: you can find this Thread useful for the removal of the border:

    http://supportforums.BlackBerry.com/T5/Java-development/how-to-remove-border-PopupScreen/m-p/42809#M...

  • Problem stop LocationListener

    Hello guys '

    My development proposal has associated GPS module. In this module, I am facing this problem.

    IE when stops and starts LocationListener, sometimes it can work and sometimes it does not.

    I use to start and stop LocationListener following code:

    private class GpsInternal implements LocationListener {
    
            LocationProvider lp;
    
            public GpsInternal() {      lp = null;    }
    
      public boolean isConnected() {        return (lp != null);  }
    
      public void start() {     if (lp == null) {         try {         lp = LocationProvider.getInstance(null);          if(lp != null) {          lp.setLocationListener(this, _interval, -1, -1);          }         } catch(LocationException e) {                }         }     }
    
      public void stop() {      if (lp != null) {         lp.reset();           lp.setLocationListener(null, -1, -1, -1);         lp = null;            }     }
    
      public void locationUpdated(LocationProvider provider, Location location) {
    
      if(location.isValid()) {  double longitude = location.getQualifiedCoordinates().getLongitude(); double latitude = location.getQualifiedCoordinates().getLatitude();   float altitude = location.getQualifiedCoordinates().getAltitude();        } }
    
      public void providerStateChanged(LocationProvider provider, int newState) {       //Nothing }}
    

    I think that the start() method has no problem. And the stop() method has something wrong. But I don't know what it is.

    If you have the idea to start and stop LocationListener, please share with me.

    TNX all '

    Try the lp.reset () after the lp.setLocationListener (null,-1, -1, -1).

    It's the way that I do and have not had any problems.

  • problem with PopupScreen

    Hi all

    I try to open a pop-up screen.

    I use the following code to open the popup screen

    UiApplication.getUiApplication () .pushScreen (new GetDirectionsScreen());

    GetDirectionsScreen() is the popupscreen

    When I open the first time, the popup screen opens. Next time when I open it, it gives me

    Eception: IllegalStateException.

    Could someone please tell me why what is happening and how can we fix it?

    Hi supriya, you use a static instance of verticalfieldmanager, now I changed and its fine, here is the code to work

    package com.winit.mobiads.ui.popupscreens;
    
    import net.rim.device.api.system.Characters;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.Manager;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.component.ButtonField;
    import net.rim.device.api.ui.component.EditField;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.component.SeparatorField;
    import net.rim.device.api.ui.component.Status;
    import net.rim.device.api.ui.container.PopupScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    
    public class GetDirectionScreen extends PopupScreen {
    
        EditField startPointEdit;
        EditField endPointEdit;
        String source,destination;
        public GetDirectionScreen(Manager delegate,long style){super(delegate, style);}
    
        public GetDirectionScreen()
        {
            super(new VerticalFieldManager(),Field.FOCUSABLE);
            addLayout();
        }
        private void addLayout() {
             LabelField getDirectionsLabel = new LabelField("Get Directions",Field.FIELD_VCENTER);
              startPointEdit = new EditField("Start Point: ","Current Location");
              endPointEdit = new EditField("End Point: ","");
             ButtonField goButton = new ButtonField("Go",Field.FIELD_VCENTER);
             goButton.setChangeListener(new GoButtonListener());
               add(getDirectionsLabel);
               add(new SeparatorField());
               add(startPointEdit);
               add(endPointEdit);
               add(new SeparatorField());
               add(goButton);
        }
           public void accept() {
               UiApplication.getUiApplication().popScreen(this);
           }
           public void close() {
               UiApplication.getUiApplication().popScreen(this);
           }
        final class GoButtonListener implements FieldChangeListener {
            public void fieldChanged(Field field, int context) {
               // Status.show("Button pressed: " );
    
                source = startPointEdit.getText().toString();
                destination = endPointEdit.getText().toString();    
    
                    if(source.length()==0)
                    {
                        Status.show("Please give a start point");
                      // isRoute = false;
                     }
                    else
                      if(destination.length()==0)
                      {
                          Status.show("Please give an end point");
                          //isRoute = false;
                      }
                      else
                          if(source.equals(destination))
                          {
                              Status.show("Please give a different start and end point");
                          }
                         else
                             accept();
                }
    
            }
    
               public boolean keyChar(char key, int status, int time) {
                   //intercept the ESC key - exit the app on its receipt
                   boolean retval = false;
                   switch (key) {
                       case Characters.ESCAPE:
                           close();
                           break;
                       default:
                           retval = super.keyChar(key,status,time);
                   }
                   return retval;
               }
        }
    

Maybe you are looking for

  • My new episodes of the podcast are numbered incorrectly

    My new podcast has only been approved by iTunes this morning. I have a "episode 0" this is something me episode, then I episodes1, 2, and 3. But these two problems: -Episode 0 does not at all appear -Episode 3 is up, as it should because it is newer,

  • Photo image variable (IMAQ)

    I'm trying to convert a type 'image' in 'image type. The 'image' type comes from the Toolbox graphics & Sound and image type comes from the Vision and movement of Toolbox. Writing in a jpg file and rereading such that an image is not an option. The p

  • problem with the Quick Launch bar - see the desktop icon missing

    original title: problem with the Quick Launch bar I've lost the 'show desktop' icon in my quick launch because of deleted by mistake the icon. I want that icon to return to the system to go to the office quickly within my work on computer... How can

  • Panel LED flashing - sensitive in low light and white background

    Hello I have a HP Pavilion 2 10 x and it has a very annoying problem. The screen flashes randomly especiall when the value in a low bringhtness setting. Pages with white backgrounds are much more noticeable, but still the screen flickers. Tried to di

  • Problem with system restore post on Vista update

    My Vista PC loses the internet connection so I tried to restore to the last known point of function after uninstalling Norton 360. This has created an error in rstrui.exe (system restore Microsoft Windows has stopped working) Please help! I think thi