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

Tags: BlackBerry Developers

Similar Questions

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

  • How to activate the pop-up windows?

    I can't fill a demand for services with ASCAP because I've not enabled popups. So, how to activate the pop-up windows?

    You can uncheck the block pop-up windows under the Orange Firefox button > Options > Options > content tab.

    See more details here

  • I'm a novice-how I Center the copy on a 6500 a Plus

    How to center the print on my main-outs? It starts on the side right of the and ends on the left.

    No problem.

    Instead of using Notepad, please try WordPad. You will find the notebook is very basic and does not have the option to allow you to Center your text.

    You can highlight your text from Notepad and paste it into WordPad, and then with her all highlighted, click the Center icon. WordPad has many more formatting options.

    It is quite possible, I get too many details, with instructions to copy / paste and so on, but I thought it would be better to have too much than not enough details. Yes, I'm the kind of girl who packs a value of weeks of clothes for a 1 night trip

  • How to disable the pop-up window of assisted reading?

    How to disable the pop-up window of assisted reading?  It is so boring, and this terrible program aid is non-existent.  If I find a different program I won't use it.

    Not easy to use at all.

    Hello

    Please, try the following:

    Open Acrobat/Reader

    Go in Edition > Preferences

    Under categories, click Accessibility

    Other Accessibility Options pane

    Uncheck the option Enable assistive technology support

    Thank you

    Abhishek

  • How to disable the mode full screen

    The toolbar has disappeared. Can you tell me how to disable the mode full screen? Apparently this is going to give back me the toolbar.

    F11 activates / deactivates the mode full-screen.

    Versions of Firefox 3.6 + have a feature to allow the user to hide the Menu bar.

    Press the Alt key to temporarily show the Menu bar, then open view > toolbars and select menu bar, so it has a check mark.

    The F10 can also be used on most PCs to temporarily reveal the menu bar.

    https://support.Mozilla.com/en-us/KB/menu+bar+is+missing

  • How to keep the Macbook pro screen and cin on position?

    How to keep the Macbook pro screen and computer in position 'on '.  I don't want the computer shuts down or cut unless I ask him to...

    If you talk to keep your machine to fall asleep, take a look at the caffeine.

  • How to stop the blue e screen to start the computer and also if you try to download anything

    Remember - this is a public forum so never post private information such as numbers of mail or telephone!

    How to stop the blue e screen to start the computer and also if you try to download anything:

    • You have problems with programs
    • Error messages
    • Recent changes to your computer
    • What you have already tried to solve the problem

    Hello

    We need numbers BBCode or Code to stop the bluescreens and utilities below will help you
    provide us information. Also the methods here can help you solve the bluescreens.

    Look in the Event Viewer to see if something is reported on those.
    http://www.computerperformance.co.UK/Vista/vista_event_viewer.htm

    MyEventViewer - free - a simple alternative in the standard Windows Event Viewer.
    TIP - Options - Advanced filter allows you to see a period of time instead of the entire file.

    http://www.NirSoft.NET/utils/my_event_viewer.html

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

    Here are a few ways to possibly fix the blue screen issue. If you could give the info from the blue screen that would be
    Help. Such as ITC and 4 others entered at the bottom left. And any other information such as STOP error
    codes and info like IRQL_NOT_LESS_OR_EQUAL or PAGE_FAULT_IN_NONPAGED_AREA and similar messages.

    As examples:

    BCCode: 116
    BCP1: 87BC9510
    BCP2: 8C013D80
    BCP3: 00000000
    BCP4: 00000002

    or in this format:

    Stop: 0 x 00000000 (oxoooooooo oxoooooooo oxoooooooo oxooooooooo)
    Tcpip.sys - address blocking 0 x 0 00000000 000000000 DateStamp 0 x 000000000

    It is an excellent tool for displaying the blue screen error information

    BlueScreenView scans all your minidump files created during "blue screen of death," collisions
    Displays information on all the "crash" of a table - free
    http://www.NirSoft.NET/utils/blue_screen_view.html

    BlueScreens many are caused by old or damaged drivers, video drivers in particular, but there are other causes.

    You can follow these steps in the Safe Mode if necessary or the command prompt Vista DVD or Options of recovery if your
    system installed by the manufacturer.

    This tells you how to access the System Recovery Options and/or a Vista DVD
    http://windowshelp.Microsoft.com/Windows/en-us/help/326b756b-1601-435e-99D0-1585439470351033.mspx

    You can try a system restore to a point before the problem started when one exists.

    How to make a Vista system restore
    http://www.Vistax64.com/tutorials/76905-System-Restore-how.html

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

    Start - type this in the search box-> find COMMAND at the top and RIGHT CLICK – RUN AS ADMIN

    Enter this at the command prompt - sfc/scannow

    How to analyze the log file entries that the Microsoft Windows Resource Checker (SFC.exe) program
    generates in Windows Vista cbs.log
    http://support.Microsoft.com/kb/928228

    The log can give you the answer if there is a corrupted driver. (Says not all possible driver problems).

    Also run CheckDisk, so we cannot exclude as much as possible of the corruption.
    How to run the check disk at startup in Vista
    http://www.Vistax64.com/tutorials/67612-check-disk-Chkdsk.html

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

    Often drivers up-to-date will help, usually video, sound, network card (NIC), WiFi, 3rd party keyboard and
    smile, as well as of other major device drivers.

    Look at the sites of the manufacturer for drivers - and the manufacturer of the device manually.
    http://pcsupport.about.com/od/driverssupport/HT/driverdlmfgr.htm

    How to install a device driver in Vista Device Manager
    http://www.Vistax64.com/tutorials/193584-Device-Manager-install-driver.html

    How to disable automatic driver Installation in Windows Vista - drivers
    http://www.AddictiveTips.com/Windows-Tips/how-to-disable-automatic-driver-installation-in-Windows-Vista/
    http://TechNet.Microsoft.com/en-us/library/cc730606 (WS.10) .aspx

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

    How to fix BlueScreen (STOP) errors that cause Windows Vista to shut down or restart unexpectedly
    http://support.Microsoft.com/kb/958233

    Troubleshooting, STOP error blue screen Vista
    http://www.chicagotech.NET/Vista/vistabluescreen.htm

    Understanding and decoding BSOD (blue screen of death) Messages
    http://www.Taranfx.com/blog/?p=692

    Windows - troubleshooting blue screen errors
    http://KB.wisc.edu/page.php?id=7033

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

    In some cases, it may be necessary.

    The Options or Vista recovery disk Startup Repair

    How to do a startup repair
    http://www.Vistax64.com/tutorials/91467-startup-repair.html

    This tells you how to access the System Recovery Options and/or a Vista DVD
    http://windowshelp.Microsoft.com/Windows/en-us/help/326b756b-1601-435e-99D0-1585439470351033.mspx

    I hope this helps.
    Rob - bicycle - Mark Twain said it is good.

  • How to center the buttons at the top of the page?

    I try to center the top of the home, products page, buttons etc. on a site I'm building, but just can not understand!  I don't know what I'm doing wrong here.  Can someone help me?  Thank you!

    http://www.myworthlesscrap.com/temp/elite/index.html

    Put a div inside of your menu div that surrounds your menu and give the following attributes:

    Width: # #px;

    margin: 0 auto;

    # Must be replaced by a fixed, defined width in pixels.  The margin 0 auto it will focus within the menu div tag you have now.

  • How to disable the pop up "Windows Media Player cannot download the information on the media... "after the extraction of a CD without activation of network connectivity.

    When I copy a CD with Windows Media Player, I get the message pop up after the investigation period is over: "Windows Media Player cannot download the media for this CD information. The other titles, artist, and album will be identified as "Unknown" in your library. For best results, connect to the Internet or manually add media for CD information. »

    I know that the message appears when I turn on the setting to allow WMP to connect to the internet to get information about the media, but I don't want WMP does. What I want is a button I can push on the pop-up that says "don't show this message again" (similar to the warnings seen in internet explore). How can I disable this pop-up window without activating the internet connection option.

    In case you're wondering, the data from the internet are incompatible in the naming convention so when I rip an audio book, so I can listen to my mp3 player, I can't completely post-processing script because not all of the disks in a set have a coherent on the slopes or even name the disc etc. At least drives marked 'Unknown' is consistent and so easy to script for the reduction to a single MP3 file.

    Hello

    Do the following and see if they help.

    Registry warning
    Important: This section, method, or task contains steps that tell you how to modify the registry. However, serious problems can occur if you modify the registry incorrectly. Therefore, make sure that you proceed with caution. For added protection, back up the registry before you edit it. Then you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click on the number below to view the article in the Microsoft Knowledge Base:

    How to back up and restore the registry in Windows
    http://support.Microsoft.com/kb/322756/

    a. start Windows Media Player. Right click on the toolbar at the top, select 'Tools' and select 'Options '.

    b. Select the "Privacy" tab uncheck all options in the tab.

    c. Select the 'Network' tab uncheck all the options in this tab as well. Click on 'OK '.

    d. click "Start", select "Run" and then type "regedit" in the appropriate field. Press "Enter". Click on "File" and "export." Type a file name of registry backup that you can remember, which contains the current date. Navigate to the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MediaPlayer\PlayerUpgrade." Under 'Name', double-click "EnableAutoUpgrade." Under 'ValueData,' type 'no.' Go to "HKEY_LOCAL_MACHINE."

    e. click 'Edit', 'New' and 'key '. Type "WindowsMediaPlayer." Click on 'OK '. Select the new key, and then click on 'Edit', 'New' and 'DWORD value'. Type "DisableAutoUpdate" and press "enter." Select 'Edit' and then 'change '. Type '1' and click on 'OK '. Click on 'OK '. Click on "File" and "Exit" to close the registry editor.

    f. click "Start", "Control Panel" and "Security Center." Under ' Manage Security Settings for, "click on"Windows Firewall ". Click the 'Exceptions' scroll down until you see "Windows Media Player." Make sure that the box next to the entry is unchecked. Click on 'OK '.

    g. right click on the toolbar in Windows Media Player. Select 'File' and 'Work offline' to completely prevent Windows Media Player to access the Internet somehow. When you want to restore Internet access, right click on the toolbar, click on "File" and remove the check mark next to "Work offline."

    That should do it.

  • How to jump the pop-up message when it is running a program?

    Referring as a result of post, the proposed network indicator is nice, and I think the place to start lists, but the pop-up confirmation message is the main problem.

    Anyone have any suggestions on how to ignore those who jump to the top of the message?

    Thanks in advance for your suggestions

    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-networking/how-to-show-traffic-on-network-icon-for-window-7/685c7920-d89a-460B-9EA9-c51fd9ec2595

    You should be able to uncheck this box:

    However, you can also do this:

    1. Go to where you stored the EXE file
    2. Right-click and choose Properties
    3. Click on the "Unlock" button, then OK.
  • How to create the pop-up search object...

    Hello. I have a flex application that displays a DataGrid containing line items. the user can add new items to the line. each line has a product search button - so that the user can choose the product of this line item. When you click on it, I think it will open a new window (popup?) which has a text input and a DataGrid for search results. Thus, the user begins to type the name of the product and it queries the table product for entries - and populates the datagrid control. the user chooses an and that the info is returned to the data grid on the home page.

    Please tell me how to do this. I can put this kind of functionality in a popup window? States? (I don't think so in this case.) Something else?

    Thank you
    Chris

    Sure. You can use the pop-up window. Yes. Popup can send events, have public properties that can be linked to that parent component allows you to add filters to the underlying table collection.

    I just thought that the States would probably produce better interaction of the user as a popup. But then, it was just a thought. Lack of real estate may make necessary the user a doll.

    ATTA

  • How to center the bookmarks in the toolbar?

    duh. duh.

    2nd thread about this issue is here - https://support.mozilla.org/en-US/questions/915664

    Open customize and place a flexible space on each side the bookmarks toolbar items. Your bookmarks will be somewhat focused, but offset to the left, half of the amount that the Bookmarks button, and word on the right side again.

    https://support.Mozilla.com/en-us/KB/how+to+customize+the+toolbar

    http://KB.mozillazine.org/Toolbar_customization

  • How to disable the pop of the Web menu on my Satellite camera?

    I have a laptop satellite which has a boring pop out menu on the left side of the screen. The one with four marked icons, Photo/video, settings, effect and face recognition.

    Is it possible to turn it off. Any help would be greatly appreciated.

    When the pop-up window appears, click on it with the right button of the mouse and disable AutoPlay.
    Next laptop time at the start of this application will not start.

    If you want to have mentioned all the time on the screen, clear the Auto hide option.

  • How to stop the pop up message: do you want to add the _ directory to your search path?

    After you install LabVIEW 8.6.1f1 on a new PC, every time I choose one of my screws via her select a VI... palette, I get a pop up message saying: ' you want to add the "P:\CWalker\COREYs LabVIEW subs projects\Phoenix" directory to your search path?

    I've already added 'LabVIEW P:\CWalker\COREYs subs projects\Phoenix' in the option search for VI and restarted path LabVIEW, but the message does not appear.

    Yes, this is how I added the directory.

    Since then, I managed to stop the pop-up message.

    Of course, I had deleted some of the default values, such as "-*" of the VI option search path and that caused the popup message.

    Thank you!

    Corey

Maybe you are looking for