What wrong with this Manager?

Hello

I created a simple Manager where I put a label and a button. Here is the code:

public class TitleManager extends Manager {
    private Bitmap bg = Bitmap.getBitmapResource("res/top_btm_bar.png");
    protected Field field;
    private String title;
    private LabelField titleLbl;

    public TitleManager(String titleText, Field field) {
        super(Manager.USE_ALL_WIDTH);
        this.title = title;
        this.field = field;
        titleLbl = Common.getLabelFieldForList(title);
        titleLbl = new LabelField(title) {
            public void paint(Graphics g){
                g.setColor(Color.WHITE);
                super.paint(g);
            }
        };
        setBackground(BackgroundFactory.createBitmapBackground(bg));
        add(titleLbl);
        add(field);
    }

    protected void sublayout(int width, int height) {
        int displayWidth = Display.getWidth();
        int displayHeight = bg.getHeight();

        layoutChild(titleLbl, width, height); //displayWidth, displayHeight
        layoutChild(field, displayWidth - titleLbl.getPreferredWidth(), displayHeight);

        setPositionChild(titleLbl, 50, 3);
        setPositionChild(field, 272, 3); 

        setExtent(displayWidth, displayHeight);
    }
    /*
    protected void paint(Graphics g) {
        g.setFont(Font.getDefault().derive(Font.PLAIN, 18));
        g.setColor(Color.WHITE);
        g.drawText(title, (bg.getWidth()/2)-50, field.getContentTop()+8);
    }*/

    public int getPreferredWidth() {
        return Display.getWidth();
    }

    public int getPreferredHeight() {
        return bg.getHeight();
    }
}

I'm passing a text to display as the title and a button to be placed next to him. I create LabelField using the text and I try to place the labelfield.

But I don't see the button, but not the titleLbl. Can someone tell me what is the problem with the above code. Why don't I see the titleLbl. Even I tried to paint text using object, but failed their also.

Any line help is very much appreciated.

Thank you

It's much better than before. You may want to consider laying off field (button?) first because it has a width the better, then with the label - making it an operation of a single pass (without calculations of rgdSpace). Something like

        layoutChild(field, displayWidth, displayHeight);
        layoutChild(titleLbl, displayWidth - field.getWidth(), displayHeight);

I always use the width rather than displayWidth in all your calculations (and ditch displayWidth altogether).

I do not mean the same thing with height is because you're likely to add that the Manager of a MainScreen() which, by default, gives to his 'children' a total of Integer.MAX_VALUE > 1 height (due to having a default VERTICAL_SCROLL value - see screen explained knowledge base article for more information). Using height in this case needlessly will propel the way the fields past the bottom of the screen. You can avoid this by using MainScreen (MainScreen.NO_VERTICAL_SCROLL) constructor, as explained in the article - then you can bring your Display.get... call and use the width and height as basis.

Tags: BlackBerry Developers

Similar Questions

  • What wrong with this sql?

    What wrong with my sql? When I try to run a plain explain command against it. I get it that perfectly well... If the syntax was wrong, I won't get the plan to explain it, then why am I getting an error number invalid? What is the data? I'm on 10.2.0.3

    Published by: S2K on August 18, 2009 10:21

    Check out this site that has a lot of regular expressions submitted by users: [Library of regular expressions | http://regexlib.com/DisplayPatterns.aspx?cattabindex=2&categoryId=3]

    Then you should do something like you posted:

    WHERE REGEXP_LIKE(RSLT_QTY,)
    
  • Please tell me what wrong with this paypal purchase code?

    < form id = "form1" name = "form1" method = "post" action = "" >
    " < p > < form action =" https://www.PayPal.com/cgi-bin/webscr "method ="post"> "
    < input type = "hidden" name = "cmd" value = "_s-xclick" >
    < input type = "hidden" name = "hosted_button_id" value = "PBG8WAM6N6G2S" >
    < table >
    < tr > < td > < input type = "hidden" name = "on0" value = "& quot; Showtime & quot;-paper print "> & quot;" Showtime & quot; - paper printing < table > < /tr > < tr > < td > < select name = "os0" >
    < option value = '1-11 x 14' > 1-11 x $14 50.00 < / option >
    < option value = '1-12 x 18' > 1-12 x $18 65.00 < / option >
    < option value = "1-16 x 20" > 1-16 x $20 90.00 < / option >
    < option value = '1-24 x 36' > 1-24 x $36 170.00 < / option >
    < / select > < table > < /tr >
    < /table >
    < input type = "hidden" name = "currency_code" value = "Us $" >
    " < input type ="image"src =" https://www.PayPal.com/en_US/i/BTN/btn_buynowCC_LG.gif "border ="0"name ="submit"alt ="PayPal - the safer, easier way to pay online how!"> "
    < img alt = "" border = "0" src =" " https://www.PayPal.com/en_US/i/SCR/pixel.gif "width ="1"height ="1"> "
    < / make >

    When I insert this code and try the button 'Buy' nothing happens.  My site is www.ritacortesi.com.  PayPal doesn't really have a good Web site.

    [email protected] wrote:


             

    method https://www.paypal.com/cgi-bin/webscr"="post">




    "Showtime"-printed paper ".


    https://www.PayPal.com/en_US/i/BTN/btn_buynowCC_LG.gif' border = '0' name = "submit" alt = "PayPal - the safer, easier way to pay online how!" >
    https://www.PayPal.com/en_US/i/SCR/pixel.gif"width ="1"height ="1">

    When I insert this code and try the button 'Buy' nothing happens.  My site is www.ritacortesi.com.  PayPal doesn't really have a good Web site.

    Look at the first line of what you posted.  You have 2 opening tags form it and I suspect that there could be other HTML errors on your page.  Run your page through the validator and fix errors that come back.  Once you have done this, if you still have errors after return.

  • Pls whats wrong with this code?

     
    create or replace trigger o_time_trig
     after update on o_time
     for each row
     begin
     update o_time
     set hours_overtime =>35
     where emp_id = :NEW.emp_id;
     end;
     /
    Warning: Trigger created with compilation errors.
    
    SQL> show errors;
    Errors for TRIGGER O_TIME_TRIG:
    
    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    2/1      PL/SQL: SQL Statement ignored
    3/20     PL/SQL: ORA-00927: missing equal sign
    It gives me an error.

    I just want to write a trigger...

    create or replace trigger o_time_trig
    before update on o_time
    for each row
    begin
      :new.hours_overtime = :new.hours_worked - 35;
    end;
    
  • After reloading my system to windows 7 # 64, I have now no DD Realtek audio Manager... just a generic system of its whats up with this?

    * Original title: DD Realtek Audio Manager... »

    I had to do a cleaning and reloading my system 64 windows 7 # when I return it to the tecknician that I have now no DD Realtek audio Manager... just a generic system of its whats up with this? is there a way that I can download this from Microsoft or can I get it on the original disc supplied with my system or this tech who fixed my PC has changed my motherboard? can someone help me with this please... it's just not in my system and I'm very angry m.. .thank you.

    Hello

    Thank you for visiting Microsoft Community.

    According to the description, I understand that you want to download the Realtek audio Manager on your PC running Windows 7. I will certainly help you to question.

    I suggest you to download the software from the link below and check if it helps:
    http://www.Realtek.com.tw/downloads/downloadsView.aspx?langid=1&PNid=23&PFID=23&level=4&Conn=3&DownTypeID=3&GETDOWN=false

    Hope this information helps.

    Sincerely,
    Ankit Rajput

  • What is wrong with this sequence, it does not work when, after 3 inserts, I add a new record with the trigger it gives an error.

    Mr President.

    What is wrong with this sequence, it does not work when, after 3 inserts, I add a new record with the trigger it gives an error.

    --SL_CUSTOMERS table data
    
    
    INSERT INTO SL_CUSTOMERS VALUES(1,'Kamrul Hasan',NULL,NULL,'Moghbazar', 'Dhaka','0456789123',NULL,NULL,NULL,'Y',NULL);
    INSERT INTO SL_CUSTOMERS VALUES(2,'Rabiul Alam',NULL,NULL,'Motijheel', 'Dhaka','0567891234',NULL,NULL,NULL,'Y',NULL);
    INSERT INTO SL_CUSTOMERS VALUES(3,'Shahed Hasan',NULL,NULL,'2-G/1,2-2,Mirpur', 'Dhaka','0678912345',NULL,NULL,NULL,'Y',NULL);
    
    
    
    

    CREATE SEQUENCE  "ALIZA"."SL_CUSTOMERS_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER  NOCYCLE ;
    
    
    CREATE OR REPLACE TRIGGER SL_CUSTOMERS_TRG 
    BEFORE INSERT ON "ALIZA"."SL_CUSTOMERS"   
    FOR EACH ROW   
    BEGIN   
    IF :NEW.CUSTOMER_ID IS NULL OR :NEW.CUSTOMER_ID < 0 THEN  
      SELECT SL_CUSTOMERS_SEQ.nextval   
        INTO :NEW.CUSTOMER_ID  
        FROM DUAL;   
      END IF;   
    END;   
    /
    
    
    
    

    When I try to insert several records with the seq.nextval it gives error

    violation of primary key.

    INSERT INTO "ALIZA"."SL_CUSTOMERS" (CUSTOMER_NAME) VALUES ('sdfsd')
    ORA-00001: unique constraint (ALIZA.SL_CUSTOMERS_PK) violated
    ORA-06512: at line 1
    
    
    
    
    One error saving changes to table "ALIZA"."SL_CUSTOMERS":
    Row 4: ORA-00001: unique constraint (ALIZA.SL_CUSTOMERS_PK) violated
    ORA-06512: at line 1
    
    
    
    
    
    
    
    

    Concerning

    Mr President.

    I find the solution by creating a function before the triiger

    as below

    CREATE SEQUENCE  "ALIZA"."SL_CUSTOMERS_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER  NOCYCLE ;
    
    CREATE OR REPLACE FUNCTION get_SL_CUSTOMERS_vId RETURN VARCHAR2 AS
    BEGIN
       RETURN SL_CUSTOMERS_SEQ.NEXTVAL;
    
    END;
    /
    
    CREATE OR REPLACE TRIGGER SL_CUSTOMERS_TRG
    BEFORE INSERT ON "ALIZA"."SL_CUSTOMERS"
    FOR EACH ROW
    DECLARE
    dummy VARCHAR2(200);
    BEGIN
      dummy := get_SL_CUSTOMERS_vId();
      :NEW.CUSTOMER_ID := dummy;
    END;
    /  
    

    It works very well

    Thank you all for the suggestions.

    Concerning

  • Which is wrong with this query?

    SELECT THE PRODUCT. PRODUCT_ID PRODUCT. PRODUCT_DESCRIPTION, PRODUCT. PR_CURRENT_YEAR_SALES_GOAL, (ORDER_QUANTITY * PRODUCT_PRICE) AS sales so far
    ORDER, ORDER_LINE, PRODUCT, PRODUCT_LINE
    WHERE TO ORDER. ORDER_NUMBER = ORDER_LINE. ORDER_NUMBER
    AND THE PRODUCT. PRODUCT_ID = ORDERED_PRODUCT. PRODUCT_ID
    AND THE PRODUCT. PRODUCT_ID = PRODUCT_LINE. PRODUCT_ID
    AND THE PRODUCT. PRODUCT_LINE_NAME = 'Home Office ';

    There is something wrong with this request, but I don't see what it is. Anyone know whats wrong with it and perhaps what would be the correct way to request program?

    There is another thing that I noticed:

    You seem to have used a Table name: "ORDERED_PRODUCT. PRODUCT_ID' in your WHERE clause that is not in your FROM clause

    See you soon-

  • I don't know whats wrong with my windows live account. Somerone seems to be using it to send advertisements to my contacts.

    I don't know whats wrong with my windows but somerone direct email account seems to be to use it to send advertisements to my contacts. I clicked on air currents and there were hundreds of ads, but the meter does not have to indicate that I had at all drafty. I tried to change my password but I can't access the password reset function either. I used the same years email address and hate having to change.  What should I do?

    What happens when you connect to your Windows Live/Hotmail through Internet Explorer account on your computer, and try to change your password?

    Tips on creating a decent password:
    http://www.Microsoft.com/security/online-privacy/passwords-create.aspx

  • I was told that I have to disable my account from my PC to add to another computer... I've done it before and I lost many of my images that were on LR.  No matter WHAT HELP with this please

    I'm trying to load another computer with CC, I was told that I have to disable my PC mine.  I did once before and lost a lot of my images from LR, suggestions on this please.

    I do the LR back ups system too.

    Thank you very much

    PAM

    Hi goaliemom

    There is no way to disable CC products. When you enable a CC product on another computer, simply connect to Creative Cloud.CC will ask you if you it will activate on more than 2 computers.

    I've done it before and I lost many of my images that were on LR.  No matter WHAT HELP with this please

    On the computer on which you will see that your images are not displayed?

    Catalog check the most recently used file > open recent in Lightroom

    Try opening a recent backup made on your newly added computer

    ~ Assani

  • What am I doing wrong with this idea of menu?

    Hi team,

    I am trying to build a menu but have two problems, as you can see on the vid when I press one of my button fly, closing at all (which could be authorized)

    Quen worst is that even if I have the names of instance for all the steps and the target tool allows you to find the path to these buttons, I can't access it from the main timeline.

    Here's the code...

    import flash.events.MouseEvent;

    import flash.display.MovieClip;

    GSmain.gsshape.gss1.gssr1.addEventListener (MouseEvent.CLICK, page2go);

    function page2go(e:MouseEvent) {}

    gotoAndStop (2);

    }

    and the error...

    TypeError: Error #1009: cannot access a property or method of a null object reference.

    to aavar / frame1 () [aavar::frame1:4]

    aavar is the document class associated with this file

    If

    GSmain.gsshape.gss1.gssr1.addEventListener (MouseEvent.CLICK, page2go);

    is frame 1/4, GSmain.gsshape.gss1.gssr1 does not exist when this code runs.

    you have also nested named functions which is always problematic:

    function whatever() {}

    function whatevernested() {}

    }

    }

    should be

    function whatever() {}

    }

    function nolongernested() {}

    }

  • What wrong with the search bar?

    Firefox is seriously p * ing me off today, what's wrong with the browser, it serves to be one of the best, now an absolute piece of software of the waste processed sound.

    Anway my problem is, AFTER upgrading firefox, I can't use my SEARCH BAR to look for anything!

    I continue to redirect to this

    file:///C:/users/Kamran/appdata/roaming/ToolbarInstaller/ToolbarInstaller/1.0.0.0/Google.html

    which is not very useful!

    I think it might be interesting to switch to google chrome and get rid of that junk!

    Edited by a moderator because of the language. See the rules and lines guidelines .

    Hi, I did what you said and disabled all add ons and one allowed them and managed to make it work. It was the 'googlebar update"add that I disabled it and everything went back to normal

    Thank you very much

  • Wrong with this request

    Hi friends,

    When I try to run the following query
    select user_name
    from xx_user
    where lower(user_name) in(
    select substr(lower(supf.first_name),1,1)|| lower(supf.last_name)
    from per_all_people_f papf,
         per_all_assignments_f paaf,
         per_all_people_f supf
    where papf.business_group_id = 216  
    and papf.person_id = paaf.person_id
    and NVL(paaf.supervisor_id, papf.person_id) = supf.person_id
    and sysdate between papf.effective_start_date and papf.effective_end_date
    and sysdate between paaf.effective_start_date and paaf.effective_end_date
    and sysdate between supf.effective_start_date and supf.effective_end_date
    and papf.person_type_id = 5145 and level >=1
    start with substr(lower(papf.first_name),1,1)|| lower(papf.last_name) in (select substr(lower(papf.first_name),1,1)|| lower(papf.last_name) 
    from xx_history xx, per_all_people_f papf
    where xx.emp_no=papf.person_id and xx.old_mrg_id <> xx.new_mgr_id)
    connect by  papf.person_id = prior paaf.supervisor_id
    and level <=1
    order by rownum desc)
    Im getting error as
    ORA-00907: lack the right parenthesis
    But if I run this part of the single application, it works very well
    select substr(lower(supf.first_name),1,1)|| lower(supf.last_name)
    from per_all_people_f papf,
         per_all_assignments_f paaf,
         per_all_people_f supf
    where papf.business_group_id = 216  
    and papf.person_id = paaf.person_id
    and NVL(paaf.supervisor_id, papf.person_id) = supf.person_id
    and sysdate between papf.effective_start_date and papf.effective_end_date
    and sysdate between paaf.effective_start_date and paaf.effective_end_date
    and sysdate between supf.effective_start_date and supf.effective_end_date
    and papf.person_type_id = 5145 and level >=1
    start with substr(lower(papf.first_name),1,1)|| lower(papf.last_name) in (select substr(lower(papf.first_name),1,1)|| lower(papf.last_name) 
    from xx_history xx, per_all_people_f papf
    where xx.emp_no=papf.person_id and xx.old_mrg_id <> xx.new_mgr_id)
    connect by  papf.person_id = prior paaf.supervisor_id
    and level <=1
    order by rownum desc)
    This query returns a correct in a row
    tmcdermott
    guess if I run as the means below, it works
    select user_name
    from xx_user
    where lower(user_name) in 'tmcdermott'
    But I don't know why it doesn't work if I run as the way to above(top-most).

    What's wrong with him

    Brgds,
    Mini

    Hello

    Move the bracket, so last two lines become

               AND LEVEL <= 1)
    ORDER BY   ROWNUM DESC
    

    Concerning
    Peter

  • Which is wrong with this reading of the audio files...! ???

    Hi all

    I try to read two different audio files with the following code piece. individually, they play well. When I try to play at the same time which is at the same time, it is give IllegalStateException and does not play any audio file.

    When I play them separately, they play well. My requirement is to play 1 file as background music and another as foreground.

    Audio playback code.

    public class Audio implements Runnable//extends Thread
    {
        private Class clazz;
        private InputStream is;
        public Player player;
        private String audiofile;
        private int fileType;
        private int mode;
        public Audio(String path, int type, int mode)
        {
         audiofile = path;
         fileType = type;
         this.mode = mode;
        }
        public void run()
        {
                       //this sample demonstrates playing an MP3 file that has been
                       //added as a resource to the project
    
                    try
                       {
                          //retrieve the MP3 file
                          clazz = getClass();
                        //create an instance of the player from the InputStream
                          is = clazz.getResourceAsStream(audiofile);
    
                          // 1-- mpeg, 2-- wav audio files
    
                          if(fileType == 1)
                              player = javax.microedition.media.Manager.createPlayer(is, "audio/mpeg");
                          else if(fileType ==2)
                              player = javax.microedition.media.Manager.createPlayer(is, "audio/x-wav");
                          player.setLoopCount(mode);
                          player.realize();
                          player.prefetch();
                          player.start();
    
                        } catch (Exception ex)
                        {
                            UiApplication.getUiApplication().pushScreen(new CloseScreen("Hello"));
                        }
                }
    }
    
    // if call this, commenting section2 it works well
                   //section1
        Audio at = new Audio("/neon1.wav",2, -1);
        Thread at1 = new Thread(at);
        at1.start();
    
    // if call this, commenting section1 it works well
                   //section2
            Audio at3 = new Audio("/neon1.wav",2, -1);
        Thread at2 = new Thread(at3);
        at2.start();
    
    // when i uncomment both section1 and section2 and execute it is not playing giving an exception IllegalStateException.
    

    all aid should be of great use.

    Thank you and best regards,

    PraveenG

    On the storm, it is not possible to play 2 sounds loaded from a file at a time.  If you try this, the first sound stops and the second sound will be played.

    You can, however, load and play a sound (background music) and play other sounds (sound effects) by using Alert.startAudio ().  The first noise not would be cut.  The only problem with this is that the Alert.startAudio sounds are not the best.

  • What wrong with my PLSQL

    Hi all
    Here are my stored procedure that returns a recordset of .net. It is a dynamic plsql, where I check if the parameter has value or not. According to the query condition is built and run.

    but it does not extend the IF condition. Guys please let me know what wrong I do.

    PROCEDURE RPT_CUSTOMER_DETAILS (OFFICE_ID_VAL VARCHAR, CUST_NAME VARCHAR,
    CPR_CR_NO VARCHAR, RECORDSET RECORDSET_CURSOR, STR_QUERY ON VARCHAR) AS
    < code >
    BEGIN
    STR_QUERY: ='select c.contract_id, c.cust_english_name, c.cpr_cr_number, t.contract_e_desc,.
    c.Status_ID STATUS,
    c.exp_date, c.cust_id
    from customers_list c inner join s contracts on c.cust_id = s.cust_id
    contract_type t on t.type_id = s.type_id inner join
    WHERE C.OFFICE_ID =' | OFFICE_ID_VAL | ";
    IF CUST_NAME! = "THEN
    STR_QUERY: = STR_QUERY +' AND C.CUST_ENGLISH_NAME '. CUST_NAME | » %';
    END IF;
    IF CPR_CR_NO! = "THEN
    STR_QUERY: = STR_QUERY + "AND C.CPR_CR_NUMBER = ' |" CPR_CR_NO | ";
    END IF;
    RECORDSET OPEN FOR STR_QUERY;
    END RPT_CUSTOMER_DETAILS;
    < code >


    any help is highly appreciated
    concerning

    fairozkhan

    Published by: fkhan on November 14, 2011 12:27 AM

    Published by: fkhan on November 14, 2011 12:31 AM
    PROCEDURE RPT_CUSTOMER_DETAILS(OFFICE_ID_VAL VARCHAR, CUST_NAME VARCHAR,
    CPR_CR_NO VARCHAR,RECORDSET OUT RECORDSET_CURSOR,STR_QUERY OUT VARCHAR)AS
    BEGIN
    STR_QUERY:='select c.contract_id, c.cust_english_name, c.cpr_cr_number,t.contract_e_desc,
    c.status_id STATUS,
    c.exp_date,c.cust_id
    from customers_list c inner join contracts s on c.cust_id=s.cust_id
    inner join contract_type t on t.type_id=s.type_id
    WHERE C.OFFICE_ID='||OFFICE_ID_VAL;
    IF CUST_NAME!='' THEN
    STR_QUERY:=STR_QUERY || ' AND C.CUST_ENGLISH_NAME like ''' ||CUST_NAME||'%''';
    END IF;
    IF CPR_CR_NO!='' THEN
    STR_QUERY:=STR_QUERY || ' AND C.CPR_CR_NUMBER = '||CPR_CR_NO;
    END IF;
    OPEN RECORDSET FOR STR_QUERY;
    END RPT_CUSTOMER_DETAILS;
    
  • What's wrong with this script?

    This opens a project in RoboHTML:

    projectPath var = "C:\\scratch\\test\\test.xpj";

    main();

    main() function

    {

    RoboHelp.openProject (projectPath);

    }

    This opens the RoboHTML but not the project:

    projectPath var = "C:\\scratch\\test\\test.xpj";

    main();

    main() function

    {

    if(ProjectPath = '')

    {

    Alert ("project path is not defined. \nPlease update the variable 'projectPath"in the script. ») ;

    RoboHelp.quit ();

    }

    RoboHelp.openProject (projectPath);

    }

    What is the error?

    Hello

    You set the path to the empty project with your statement:

    if(ProjectPath = '')

    should be

    If (projectPath == "")

    With a unique =, set the value of a variable. With double ==, you check if the variable has the same value as the variable/string/etc.

    Take a bow

    Willam

Maybe you are looking for

  • Default note length

    For percussion tracks I always manually changes the length of the note of 1/60th. But this manual change takes way too long then how I would do that by default? Or I guess I should ask I can do? 9.1.8 logic

  • Call subVIs. Absolute or relative paths?

    Hello How can I know what are called the subVIs? I would like to know what type of path is used; absolute or relative. The brilliant solution would be if I could choose a VI and a list of its subVIs with the path close to. K.

  • 2 files are labeled 2008 Aug. How CASN I put them together

    I have several folders of picturees.  2 of them are marked with August 2008.  I want that they set.  Also the numbers 47 and 48 and the first.  I can not their last.

  • Ring in silver on screen

    A few weeks ago an 'image' jumped on my desk (and it's always on the top of each application) a white/silver ring. I do not see it appear. It's just there the next time I went on my computer. It is about 1 inch in diameter and look exactly like a thi

  • Lock power display on the screen

    XP is used to display a message on the screen when you it turned on and off. How can I get that to happen in Windows 7?