LabelFields in the pop-up screen centering

I am centering a PopUp screen and add a few LabelFields which must be centered too. I put the position of the Popup manually, but the LabelFields aren't always align properly... What have I done wrong?

The PopupScreen position which focuses more or less now:

private final static int _X = (Display.getWidth() - 510);
private final static int _Y = (Display.getHeight() - _Height) >> 1;

public void sublayout(int width, int height) {
        super.sublayout(getPreferredWidth(), Integer.MAX_VALUE);
        setExtent(getPreferredWidth(), getPreferredHeight());
        setPosition(_X, _Y);
    }

These are the LabelFields thereon that are even more on the left side:

LabelField title = new LabelField("UI Test App",
                Field.FIELD_HCENTER);
LabelField version = new LabelField("Version X.Y",
                LabelField.FIELD_HCENTER);

add(title);
add(version);

"It seems that the separatorField has a standard in a popup length if you don't customize it?

Sort of.  In fact, the SeparatorField wants to put in a separator that is as wide as Manager it is in. so, indeed, it will force the Manager to use the full width that it is given.

One way round this is to limit width is given by the Manager. Here's some code to show how do.  See screen capture for the result.

   public InfoScreen() {
        super(new VerticalFieldManager() {
            public void sublayout(int width, int height) {
                super.sublayout(Math.min(width, Display.getWidth()/2), height);
            }
        });
        LabelField title = new LabelField("UI Test App", Field.FIELD_HCENTER);
        LabelField version = new LabelField("Version X.Y",
                LabelField.FIELD_HCENTER);
        ButtonField closeBtn = new ButtonField("Close", ButtonField.FIELD_HCENTER);
        add(title);
        add(version);
        add(new SeparatorField());
        add(closeBtn);
    }

There are other options, for example, you can use the page layout in the SeparatorField to restruct its width.  Then the Director would not forced to use any of its width by the SeparatorField.  The best option will depend on exactly what you are trying to reach and what other restrictions you have.

Tags: BlackBerry Developers

Similar Questions

  • How to center the button on the pop-up screen

    Look at the picture, I've created a popup screen click the menu key and I have that transparent and make it mode full screen and I added four buttons vertically please, u can correct me how can I Center this button in the pop up screen.

    Here is my code

    if (Keypad.key(keycode) == Keypad.KEY_MENU)
            {
                  MysettingMenu mymenu = new MysettingMenu();
                  UiApplication.getUiApplication().pushModalScreen(mymenu);
                System.out.println("--------------Menu -key -Pressed-----------------");
    
            }
     public class MysettingMenu extends PopupScreen{
             public MysettingMenu(){
                 super(new VerticalFieldManager(), Screen.DEFAULT_CLOSE); 
    
                 this.setBackground(BackgroundFactory.createSolidTransparentBackground(Color.WHITE, 80));
    
                 setBorder(BorderFactory.createSimpleBorder(new XYEdges(),Border.STYLE_TRANSPARENT));
    
                 this.add(new ButtonField("Favourites"));
                 this.add(new ButtonField(" Settings "));
                 this.add(new ButtonField("  About    "));
                 this.add(new ButtonField("  Exit    "));
    
             }
    
            protected void sublayout(int width, int height) {
                // TODO Auto-generated method stub
                 super.sublayout(Display.getWidth(), Display.getHeight());
                  setExtent(Display.getWidth(),Display.getHeight());
                  int leftMargin = (Display.getWidth() - width)/8;
                  int topMargin = (Display.getHeight() - height)/8;
                  setPosition(leftMargin, topMargin);
            }
    
         }
    

    There are a variety of ways that this could be done, but in your case the easiest is to allow the screen to use only as much space as it needs and then place it at the Center.

    Then

    (1) change this call

    Super.sublayout (Display.GetWidth (), Display.getHeight ());

    in fact, supply the same width and height that you have been given.

    (2) remove this:

    setExtent (Display.getWidth (), Display.getHeight ());

    (3) change margin settings so that they use the actual width and height, and on this basis.  For example:

    leftMargin = int (Display.getWidth () - this.getWidth (()) / 2;

    By the way, I recommend strongly that you never call super.layout (...) ignore the size that he gave you and you deliver own setExtent.  Unless you know what you are doing, this can cause fields to display incorrectly.  If you think that you must set your own size, then I suggest you create your own Manager and do you do the layout.  More information on that here:

    http://supportforums.BlackBerry.com/T5/Java-development/how-to-extend-Manager/Ta-p/446749

  • Button in the pop-up screen problem

    Hi all

    I did a pop-up screen in which there are two buttons and an EditField. Now, I am faced with very weird problem. First button that I added in my code doesnot seem to work. It doesnot clicking and the second button is working well, why is it so can any body help out me of this.

    I provided the code here: -.

    public class PinPopup extends PopupScreen{
    public static  EditField texts;
    static String _userName=null;
    
    PinPopup()
        {
        super(new HorizontalFieldManager());
        Font f = Font.getDefault().derive(Font.BOLD, 16);
        setFont(f);
        texts=new EditField("","",200,Field.EDITABLE);
    
        ButtonField sendButton = new ButtonField(" Send  "){
            protected boolean navigationClick(int status, int time) {
                   Dialog.inform("Send");
                return true;
                }
        };
    
        ButtonField cancelButton = new ButtonField("Cancel"){
             protected boolean navigationClick(int status, int time) {
                   Dialog.inform("Cancel");
                return true;
                }
        };
    
        VerticalFieldManager _fieldManagerContext = new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH | VerticalFieldManager.USE_ALL_HEIGHT)
            {
    
                public void sublayout(int width,int height) {
                    //super.sublayout(width, height);
                    int xpos = 0;
                    int ypos = 0;
                    Field field = getField(0);
                    layoutChild(field, 280, 50);
                    setPositionChild(field, xpos, ypos);
                    Field field1 = getField(1);
                    layoutChild(field1, 280, 50);
                    setPositionChild(field1, xpos+20, ypos+80);
                    Field field2 = getField(2);
                    layoutChild(field2, 280, 50);
                    setPositionChild(field2, xpos+145, ypos+80);
                    setPosition(150, 220);
                    setExtent(300, 220); 
    
                   }
                    public void paint(Graphics graphics)
                    {
                        //graphics.setColor(Color.WHITE);
                        Font f = Font.getDefault().derive(Font.BOLD, 16);
                        graphics.setFont(f);
                        graphics.drawText("SEND PIN",90, 20,0,200);
                        graphics.drawText( _userName,110,40,0,200);
                        graphics.setColor(Color.WHITE);
                        super.paint(graphics);
                    }
    
            }; 
    
                  _fieldManagerContext.add(texts);
                  _fieldManagerContext.add(cancelButton);
                  _fieldManagerContext.add(sendButton);
                  add(_fieldManagerContext);
    
        }
    
    }
    

    Hi Please help me in this

    Thanks in advance

    Why do you not use Horizontalfieldmanager for horizontal alignment.

    This is the code and it works fine.

    package com.winit.mobiads.ui.screens;

    Import net.rim.device.api.ui.Color;
    Import net.rim.device.api.ui.Field;
    Import net.rim.device.api.ui.Font;
    Import net.rim.device.api.ui.Graphics;
    Import net.rim.device.api.ui.component.ButtonField;
    Import net.rim.device.api.ui.component.Dialog;
    Import net.rim.device.api.ui.component.EditField;
    Import net.rim.device.api.ui.container.HorizontalFieldManager;
    Import net.rim.device.api.ui.container.PopupScreen;

    SerializableAttribute public class PinPopup extends PopupScreen {}
    public static EditField texts;
    public static String _userName = null;

    PinPopup()
    {
    Super (new HorizontalFieldManager());
    Police f = Font.getDefault () .derive (Font.BOLD, 16);
    setFont (f);
    texts = new EditField("","",200,Field.EDITABLE);
           
    ButtonField sendButton = new ButtonField ("send") {}
    protected boolean navigationClick (int status, int time) {}
    Dialog.Inform ("Send");
    Returns true;
    }
    };
         
    ButtonField cancelButton = new ButtonField ("Cancel") {}
    protected boolean navigationClick (int status, int time) {}
    Dialog.Inform ("Cancel");
    Returns true;
    }
    };

    HorizontalFieldManager _fieldManagerContext = new HorizontalFieldManager (USE_ALL_WIDTH)
    {
               
    ' public void sublayout (int width, int height) {}
    Super.sublayout (width, height);
    int xPos = 0;
    int yPos = 0;
    Field = getField (0);
                       
    setPositionChild (field, xpos, ypos);
    layoutChild (field, 280, 50);
                       
    Field Field1 = getField (1);
                       
    setPositionChild (Field1, xpos ypos + 80 + 20);
    layoutChild (Field1, 100, 50);

    Field Field2 = getField (2);
                       
    setPositionChild (Field2, xpos ypos + 80 + 145);
    layoutChild (Field2, 100, 50);
                       
    setPosition (150, 220);
    setExtent (width, height);
                        
    }
    public void paint (Graphics graphics)
    {
    graphics.setColor (Color.WHITE);
    Police f = Font.getDefault () .derive (Font.BOLD, 16);
    graphics.setFont (f);
    graphics.drawText ("SEND PIN", 90, 20,0,200);
    graphics.drawText (_userName, 110, 40, 0, 200);
    graphics.setColor (Color.WHITE);
    Super.Paint (Graphics);
    }
             
    };

    _fieldManagerContext.Add (texts);
    _fieldManagerContext.Add (CancelButton);
    _fieldManagerContext.Add (sendButton);
    Add (_fieldManagerContext);
                     
    }

    }

  • How to close the pop-up screen with timer

    Hello

    How to close pop-up display with timer .assuming I want to close pop-up screen after 10 seconds please share code me complete.

    Hello

    See this sample program,

    import java.util.Timer;
    import java.util.TimerTask;
    
    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;
    import net.rim.device.api.ui.container.PopupScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    
    public class Example extends UiApplication {
        public static void main(String[] args) {
            Example app = new Example();
            app.enterEventDispatcher();
        }
    
        public Example() {
            pushScreen(new ExampleScreen());
        }
    
        private class ExampleScreen extends MainScreen {
            public ExampleScreen() {
    
                ButtonField but = new ButtonField("Click",ButtonField.CONSUME_CLICK);
                but.setChangeListener(new FieldChangeListener() {
    
                    public void fieldChanged(Field field, int context)
                    {
                        UiApplication.getUiApplication().pushScreen(new exmplePopup());
    
                    }
                });
    
                add(but);
            }
        }
    
        private class exmplePopup extends PopupScreen
        {
    
            public exmplePopup()
            {
                super(new VerticalFieldManager());
                GuestPop p=new GuestPop();
                add(p);
            }
    
            public class GuestPop extends VerticalFieldManager
            {
                public GuestPop()
                {
                    add(new LabelField("Hi How r u"));
    
                    Timer timer  = new Timer();
                     timer.schedule(new CountDown(), 5000);
                }
    
            }
    
            private class CountDown extends TimerTask {
                public void run() {
                    UiApplication.getUiApplication().invokeLater(new Runnable() {
    
                        public void run() {
                            UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
    
                        }
                    });
    
                }
            }
    
        }
    }
    

    Here, I've given 5 seconds.

    Thank you.

  • Need for a method to be called when the pop-up screen

    Hello

    I have a requirement in my application. I have a screen from which I'm moving to screen B. When I Pop the screen B, I need a method that must be called in the screen has. Looks same as onActivityResult() in Android.

    I am currently using onExpose(). But this method is called for all in the screen has. In the menu click or button also. Is there another way to do this?

    Help, please...

    You have two options I can think immediately, which do not have to change anything in screen B.

    (1) use pushModal when you call B screen.  The statement immediately after the pushModal will be executed as soon as B screen is popped.  In general, I try to avoid the modal screens, but in this case, it's probably what I would do.

    (2) set an indicator immediately before you tap screen B.  Test the flag in onExposed().  If the flag is not set, then the onExposed was called for another reason and you can ignore it.  If the flag is set, then turn him off and process you want, knowing that the screen that has been exposed as screen B jumped.

    Either should work for you.

  • Closing the pop-up screen also close screen.

    Hello guys. In my application, I have a main screen which is actually my program with a bunch of buttons to choose which part of the program, you go to the start screen. Now when you press the ESC key, a context menu is supposed to appear and gives you the option of leaving the program, to hide the program in the background or cancel the popup.

    Now whenever I try to close this pop-up window, it also closes my screen which in turn closes the program which is supposed to be to produce. More information, is the popup screen must be declared global or modal modal or well screen just disspears and all that remains is the popup screen on a white background when the popup screen is pressed.

    Thanks for the help.

    return true instead of super to indicate that the ESC has been handled.

  • Dialog without buttons (cannot use the pop-up screen)

    Model of misconception for one applications that I am made me ask this question. I need a dialog without any button (I can't settle for a screen of poppies). Help of any kind is appreciated.

     

    A Y.

    Hi AVI,.

    You can create like that,

    Dialog box d = new dialog box ("Hi", null, null, 0, null);
    d.Show ();

    But remember this will not block the event thread.

    Thank you.

  • Push the pop-up screen at the top of the lock screen

    Hi, is it possible to grow a popup with some editfields screen, while the device is locked?

    I am currently using:

    Ui.getUiEngine().pushGlobalScreen(customPopUpScreen, 100, UiEngine.GLOBAL_QUEUE);
    UiApplication.getApplication().requestBackground();
    

    but it is not display the dialog box when the screen is locked. It seems possible, considering that the native app alarm shows the dialog box while the device is locked.

    Help please!

    I am sure that you are referring to http://supportforums.blackberry.com/t5/Java-Development/pushGlobalScreen-restrictions/m-p/19550/high...

    In this discussion, they came to the conclusion that nothing can get pushed on top of the screen to unlock except the native alarm alert dialog box. I guess I can push the alert dialog but I need user interaction while the device is locked, so I guess that answered my question

    Thanks Peter!

  • How to add images to the pop-up screen?

    How can we add popup screen images?

    the image should cover the screen whole popup.

    How can I substitute popupscreen so that I can change the look of popupscreen.

    Finally, I found the solution.

    We can add BitmapField directly to the class that extends popupscreen.

    Thankx

  • Return a value from the pop-up screen

    Long story short - I have a PopupScreen. This has two text boxes. What I want to do is to call a method on the original screen (the one that calls the popup), using these values in two text box.

    The only thing I can't do is pass back the two field values. Ive tried to call the method. Even tried passing the screen in the popupscreens constructor.

    private class goToMenuItem extends MenuItem {
            public goToMenuItem() {
                super( new StringProvider( "Test" ), 0, 0 );
            }
            public void run() {
                CustomPopUpScreen cstmScreen = new CustomPopUpScreen();
                UiApplication.getUiApplication().pushModalScreen(cstmScreen);
            }
         }
    
     public class CustomPopUpScreen extends PopupScreen {
    
                BasicEditField T1;
                BasicEditField T2;
    
                public CustomPopUpScreen() {
                    super(new VerticalFieldManager(CustomPopUpScreen.NO_HORIZONTAL_SCROLL));
    
                    BasicEditField T1= new BasicEditField( "T1: ", "", 20, BasicEditField.EDITABLE | BasicEditField.FILTER_REAL_NUMERIC);
                    BasicEditField T2= new BasicEditField( "T2: ", "", 20, BasicEditField.EDITABLE | BasicEditField.FILTER_REAL_NUMERIC);
    
                    ButtonField cancel = new ButtonField("Cancel");
                    ButtonField submit = new ButtonField("Go To");
                    add( T1);
                    add( T2);
                    add(submit);
                    add(cancel);
    
                    cancel.setChangeListener( new FieldChangeListener() {
                        public void fieldChanged(Field arg0, int arg1) {
                            close();
                        }
                    });
    
                    submit.setChangeListener( new FieldChangeListener() {
                        public void fieldChanged(Field arg0, int arg1) {
                            GoTo();
                            close();
                        }
                    });
                }
    
                public void GoTo()
                {
                        //GoTo(Double.parseDouble(T1.getText()),Double.parseDouble(T2.getText()));
                }
            }
    

    Just to add a bit to the response of Simon.

    "I want to do is call a method on the original screen.

    OK, I have to ask, why do you do this?  It doesn't seem very object ish.

    If you want to call this method once the screen has been closed, then the approach you use (modal form) works, you need to get the values in the treatment of menu and then you can call the transformation of in the menu on the screen who has access to the treatment method.

  • Enter key doesn't work is not for the pop-up screen

    Hello

    I am facing a problem in trying to close the context menu in my application. The enter (return) key does not work on my popup screen. I can close the popup with button screen central trackball or with the pointer of the mouse (in Simulator 9800). I want to close the same screen by using the Enter key. I develop application for Blackberry 9800 with OS 6.0 and also the part of the code I am using is as

    PopupScreen messageScreen = new PopupScreen(new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL)); messageField=new BasicEditField("Message:","Abc",20,Field.READONLY);
    closeButton=new ButtonField("Close", Field.USE_ALL_WIDTH){
      protected boolean navigationClick(int status, int time) {
        getScreen().deleteRange(0, getScreen().getFieldCount()-1);
        UiApplication.getUiApplication().popScreen(getScreen());                return true;
      }
    };messageScreen.add(messageField);
    messageScreen.add(closeButton);
    UiApplication.getUiApplication().pushScreen(messageScreen);
    

    Someone help me please on this issue.

    Thanks in advance

    Hi paabs,

    Here's what you need to do:

    1. create a function for each of your buttons. For example: okClicked() & cancelClicked().

    2. replace keyDown and check if the key pressed is the Enter key. If so, check the field with the focus and activate the correct function.

    3 replace the method "navigationClick. Locate the field with the update and select the correct function.

    E.

  • I get a pop up screen I need, but the screen is very low and does not allow more than 1 line of information while IE shows the window contextual integers of 27 lines

    I play games that allows me to send gifts to your facebook friends and when I click on send gift, a screen with the names of my friends will be displayed so that I can select the ones to send to... but since yesterday morning, the pop up screen using firefox became so weak that it allows only one line and it does not allow me scroll more than 5 times... While the IE pop-up window shows 27 lines at once, and I can scroll the following 27 and so on... I have pictures of the screen if you need...

    You should be able to resize the window pop - up to enlarge.

    You allow sites resize the popup window?

  • Pop - up screen to record images does not appear when you connect the camera

    Original title: when I plug in my camera to download photos I don't have a pop up screen to ask me some questions were to save you more pictures. I want the pop up screen to come back.
    Guest USB? Download the pictures?

    Hello

    1. Are you referring to the AutoPlay window that appears when you connect a device to the computer?

    What is the number and the model of the camera?

    In case you are referring to the Auto play option then try the troubleshooting steps provided in the link below to fix the problem.

    Troubleshoot AutoPlay

    http://Windows.Microsoft.com/en-us/Windows-Vista/Troubleshoot-AutoPlay-problems

  • How to stop pop-up screen 'See the keyboard, Switch Application, full Menu'?

    Hi all

    I always get this pop-up screen when switching from one screen to the other. I don't know what is the reason for the pop up screen and how to stop it. If you have encountered this problem before and know how to deal with it please give me help.

    The pop-up screen contains the following choices:

    Display the keyboard

    Switch application

    Full menu

    Thank you very much for your help!

    I found the solution to this problem here http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=10933

  • How to create pop-up screens?

    Hello, I try to recreate this Web page

    http://fkatwi.GS/#

    However, I am confused how I can create the pop-up screens that appear when you click on a navigation link.

    Also is there a way to imitate the smooth transition?

    Thank you!

    You can do this by using blank publication and then set the parameter to lightbox

Maybe you are looking for

  • Cannot open after update to v 30.0

    I run Windows 7 and cannot open Firefox after update to v 30.0. I uninstalled and reinstalled several times without success. I do, however, show: firefox.exe * 32 in the section of the Task Manager processes. No browser opens and the only way to "kil

  • Remove the Stand Z1

    I want to wall mount my Z1. Documentation says to remove the stand reveals the VESA mounting holes and yet I could not find instructions on how to remove the stand. It is not obvious by looking at. Can someone advise me on how to remove it?

  • location code product key my label disappeared

    location code product key my label disappeared The other post: my label is gone I have no box or cd for location code product key

  • any idea on the weather icon on cover smart scr42

    no idea how to get the icon of the weather on the cover smart screen scr42. Does not appear on my z5

  • Cannot install Vista

    I'm trying to fix the computer from a friend who crashed. She had installed XP but got a virus or something and the computer crashed. She asked me to install Vista instead of XP this time and got a copy. When I try to install the new OS, boot from th