Substitution of CustomFields and getPreferredHeight()


Hello again, man.

I tried with a custom button field and my result was constant: 29 before and after the screen got active.

Probably, you might have a bad layout code or something. Consider this as an example (in fact, it's the code work for me) and understand what you're missing.

The custom field with the methods:

import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Graphics;

public class CustomButtonField extends Field {

    private static final int Y_PADDING = 8;
    private static final int X_PADDING = 8;

    private String label;
    private int backgroundColor;
    private int foregroundColor;
    private int focusedForegroundColor;
    private int focusedBackgroundColor;

    public CustomButtonField(String label, long style) {
        super(style);
        this.label = label;
        this.backgroundColor = Color.LIGHTGRAY;
        this.foregroundColor = Color.BLACK;
        this.focusedForegroundColor = Color.WHITE;
        this.focusedBackgroundColor = Color.BLACK;
    }

    protected void layout(int width, int height) {
        setExtent(getPreferredWidth(), getPreferredHeight());
    }

    protected void paint(Graphics graphics) {
        int bgColor = 0;
        int fgColor = 0;
        if (isFocus()) {
            bgColor = focusedBackgroundColor;
            fgColor = focusedForegroundColor;
        }
        else {
            bgColor = backgroundColor;
            fgColor = foregroundColor;
        }
        graphics.setColor(bgColor);
        graphics.fillRoundRect(1, 1, getPreferredWidth() - 2, getPreferredHeight() - 2, 12, 12);
        graphics.setColor(Color.WHITE);
        graphics.setGlobalAlpha(100);
        graphics.fillRoundRect(3, 3, getPreferredWidth() - 6, getPreferredHeight() / 2, 12, 12);
        graphics.setGlobalAlpha(255);
        graphics.setColor(fgColor);
        graphics.drawText(label, X_PADDING / 2, Y_PADDING / 2);
    }

    public int getPreferredHeight() {
        return getFont().getHeight() + Y_PADDING;
    }

    public int getPreferredWidth() {
        return getFont().getAdvance(label) + X_PADDING;
    }

          //The other methods you have to implement to manage focus and key listening go here
}

I used the code in my previous post to set a Manager on these buttons, but instances of the CustomButtonField instead of the ButtonField class.

Check it out and let me know if it works.

Tags: BlackBerry Developers

Similar Questions

  • Synchronize the values of variables of substitution between Essbase and planning

    Hello
    In EMP 11.1.2.1 version (but we noticed the problem also in previous versions of EPM) when we set the value of a variable substitution in Essbase, the value is not immediately updated in planning: for a while, we see the old value. The value in the planning remains unchanged even to disconnect or exit planning and reconnect.
    On the contrary if we restart the planning service, the value is immediately updated
    Since we would like to use the Essbase substitution variables to manage some selections in forms of Entru data planning, is it possible to force a synchronization, or increase the frequency of synchronization between Essbase and planning?

    Concerning

    Francesco Quaranta

    Take a look at the definition of ownership of planning SUBST_VAR_CACHE_LIFETIME

    http://docs.Oracle.com/CD/E17236_01/EPM.1112/hp_admin/properts.html

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • Getpreferredwidth and getpreferredheight custom text field

    I have a customtextfield that I have to get the width of textfields, I tried getpreferredwidth() substitution but I'm stacoverflowmethod, I can understand the reason for the error but I tried getwidth() substitution I get 10 as standard response. I am not able to understand the error.

    public class CustTextField extends RichTextField{
    
        private String _text;
        private FontFamily _fontFamily1;
        private int _size, _color;
        private Font _headFont = null;
    
        public CustTextField(String _text, int _size,int _color, long _property)
        {
            super(_text, _property);
            FontFamily _fontFamily1;
            this._color = _color;
            try{
                _fontFamily1 = FontFamily.forName("aerial");
            } catch(ClassNotFoundException e) {
                    _fontFamily1 = Font.getDefault().getFontFamily();
            }
             _headFont = _fontFamily1.getFont(Font.PLAIN,_size);
             super.setFont(_headFont);
        }
    
        public int getPreferredWidth() {
            // TODO Auto-generated method stub
            return getPreferredWidth();
        }
    
        protected void paint(net.rim.device.api.ui.Graphics g) {
            g.setColor(_color);
            super.paint(g);
        }
    }
    

    A Y

    You can use font.getAdvance

  • The substitution of hashCode and equals methods

    In the example below, it displays 'true' when the child objects and b are different. That I should overide equals and hashCode method for each class that extends the person?

    public class EqualsTest {
         public static void main(String[] args){
              
              Child a = new Child("Tom",10,1);
              Child b = new Child("Tom",10,2);
              System.out.println(a.equals(b));
              
              
         }
    }
    
    class Person{
         private String name;
         private int height;
    
         private volatile int hashCode = 0; 
    
         
         public Person(String n, int h){
              this.name = n;
              this.height = h;
         }
         
         @Override
         public boolean equals(Object obj) {
              if(this == obj){
                   System.out.println("hello");
                   return true;
              }
              if(obj instanceof Person){
                   Person a = (Person)obj;
                   if(this.name.equals(a.name)){
                        return true;
                   }else{
                        return false;
                   }
              }else{
                   return false;
              }
         }
         
         @Override
        public int hashCode () { 
            final int multiplier = 23; 
            if (hashCode == 0) { 
                int code = 133; 
                code = multiplier * code + name.hashCode(); 
                code = multiplier * code + new Integer(height).hashCode(); 
                hashCode = code; 
            } 
            return hashCode; 
        } 
    
    }
    
    class Child extends Person{
         
         private int age;
         
         public Child(String n,int h,  int a) {
              super(n,h);
              this.age = a;
         }
    }
    Thank you

    It is not "optimal", it is by definition the keys are unique. But what is unique? This means that any equal 2 keys do exist in the table and means 'equal' some equals() defines as equal.

    Published by: baftos on April 18, 2011 13:25

  • Can MapPoint 2011 - be installed without the substitution of previous versions?

    I need to be able to keep older versions of MapPoint on my laptop while having access to 2011.  I could install 2009 without the substitution of 2004 and 2006, but my IT people say it cannot be done with 2011.  Can he?

    Hello

    Check with the help of MapPoint and in the MapPoint Forums.

    Highway, Streets & Trips, MapPoint - Forum
    http://social.Microsoft.com/forums/is/streetsandtrips/threads

    MapPoiint - Support
    http://www.Microsoft.com/MapPoint/en-us/support.aspx

    Support for MapPoint, streets & trips and Highway
    http://support.Microsoft.com/ph/851

    I hope this helps.

    Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle=""><- mark="" twain="" said="" it="">

  • Google Chrome message "this computer will stop soon receive updates of Google Chrome for Windows Vista and Windows XP.

    Is someone can you please tell me when Google Chrome will stop supporting 2007 Service Pack 2 for Windows Vista Home

    Go Mary

    I posted a substitution for Vista and XP operating systems. Please follow my instructions in this thread, or switch to Mozilla Firefox or Opera browser:

    http://www.MSFN.org/Board/topic/175099-instructions-Google-chrome-end-of-support-VistaXp/

    I always highly recommend to switch to Mozilla Firefox, Opera, or one of many other supported browsers.

    While my dose turns off the message, you will NO longer receive updates of Google Chrome.

    Given that Microsoft will support Vista at least a year, I don't understand Google dropping support early reasoning.

  • 64 gb sd - 8 MB and why can not format?

    Hello, I have a 64 GB micro sd card that was working fine until yesterday, when I took out my Tablet and put it in my computer. He said then I needed to get in shape, not wanting to delete everything I put it in my tablet, it pops up then format sd card damaged? no other choice, I clicked format. He then format of such full, damaged the card sd, format? When I put in my computer it needs formatting, I click on format and where it says to select ability he says 8 MB, even when I try formatting to 8 MB is still does not work. When I try formatting in cmd normally and using substitution errors occur and are recorded in the newspapers.

    If two different computers cannot read the SD card, then it is probably damaged and is no longer usable.  They wear out over time.  I hope you had files saved somewhere.  If you just want to recover and re - format, I recommend to use the diskpart program to wipe the card, then try to re - format.  However, given these symptoms I would never trust it for something of important although you can reformat.

  • Background image of display and scrolling VFM

    Right now, I'm stuck trying to give the desired result work on my screen. I already know the basics of adding a background to a Manager (value bit flags USE_ALL_WIDTH and USE_ALL_HEIGHT so that paint void). However, I must also deal with a child growable VFM attached to the screen can scroll if the height is greater than the height the screen less the height of the top banner field. What I want to achieve is the following: having a screen that does not scroll with a background image that is attached to the dimensions of the screen less field height of the banner (first low-level with the BG Manager). However, I want the VFM child to be able to scroll if necessary while the BG image is displayed in the background. Here's what I have so far to my constructor:

    public MyMainScreen(){
       super( NO_VERTICAL_SCROLLBAR );
       VerticalFieldManager myVFM = new VerticalFieldManager(
                                    VerticalFieldManager.USE_ALL_WIDTH
                    | VerticalFieldManager.NO_HORIZONTAL_SCROLL
                    | VerticalFieldManager.NO_VERTICAL_SCROLLBAR
                    | VerticalFieldManager.FIELD_TOP
                    | VerticalFieldManager.TOPMOST
                    | VerticalFieldManager.BOTTOMMOST );
       setBanner(myBannerField);
       //fields are added to VFM.....
    
       VerticalFieldManager bgManager = new VerticalFieldManager(
                                    VerticalFieldManager.USE_ALL_WIDTH
                                    | VerticalFieldManager.USE_ALL_HEIGHT
                                    | VerticalFieldManager.NO_VERTICAL_SCROLL){
               public void paint(Graphics g){
                  //my BG gets drawn here...
                  super.paint(g);
               }
       };
       bgManager.add(myVFM);
       add(bgManager);
    }
    

    So, I just need to know if I'm doing something wrong here. Of course, it may be obvious to some, but for some reason that I'm completely stumped. Thanks in advance.

    Tried again without the substitution of sublayout, and he managed to work given my VFM populating routines, because the domain in question (HFM) that is updated is added without all the fields added initially, so my VFM has all the fields, it needs at that point to have himself. You're right, if I wanted to complex me and choose to place the fields of optimization of resources on particular points, it would be wise to replace sublayout and define to what extent, accordingly, but in this case, it works fine without it. Anyway, the people, the answer today is that your screen does not scroll by setting super (NO_VERTICAL_SCROLLBAR |) NO_VERTICAL_SCROLL) in the constructor, however, if you want the custom vertical scrolling on your VOR with BG, you must set to vertically, do scroll down and use the height by passing the following style bits:

    VerticalFieldManager.USE_ALL_WIDTH
    | VerticalFieldManager.NO_HORIZONTAL_SCROLL
    | VerticalFieldManager.VERTICAL_SCROLL
    | VerticalFieldManager.NO_VERTICAL_SCROLLBAR
    | VerticalFieldManager.USE_ALL_HEIGHT

    then you replace paintBackground appeal of this optimization of the resources any desired call paint and that's it.

  • The OFA customizations and customizations are patch safe?

    Hi all

    Can you please let me know customizations OAF are secured or not patch?

    Can you please help me by answering questions under...

    1 if you apply the patch, do I need to import the customizations again?

    2. If you apply the patch, do I need to migrate all of my custom again code?

    3 What substitutions of VO and extensions of the controller?

    It's really urgent. I appreciate your help.


    Thank you

    Palacin

    1. they defined the custom in the standard folder objects. While the extension of controller, instead of taking CO custom in the path of the xxCustom/oracle/apps, they have directly defined in/oracle/apps/path.

    For example Oracle/apps/pa/project/AssignmentsCO - CO Standard

    Oracle/apps/pa/project/xxAssignmentsCO - Custom CO

    It is very good. Patch will not overwrite it as the name of the file begins with XX.

    2. they have changed the Standard AMImpl.xml to add objects to display custom as they want to make certain information in standard page using custom VO followed by extensions of the controller.

    This isn't a good idea. You have two options to do this:

    1. am I Substitution. (Which was a problem for me in 11i. Whenever we do an AM Substitution, the specific feature which we works very well, but something no longer works. ex:-LOVs stop working. Not sure that this problem is corrected in 12 or not because I didn't AM Substitution in R12.)

    2. create dynamic VO in CO extension and use it.

    Having said that, if the Patch is not to change the specific files of AM, then you don't need anything, whether current changes will work without modification.

    I need to move this custom controllers (which are defined in the path standard/oracle) and modified AMImpl.xml every time when they apply the patch?

    Custom controller - No.

    AMImp - depends on whether the patch has modified the standard AM files.

    Tip:-Patch adds / overrides some standard files. It will not remove/update the custom files.

    In your case, the controller extensions are custom files. You have changed the standard AM files

    See you soon

    AJ

  • Substitution variables for the DTS functions in forms of planning


    I would like to use variables of substitution for QTD and last YEAR in a form of planning.  I have active DTS.  I can select them as members, but cannot enter as variables.

    I created a variable containing "Y-T-D (Feb).  I also tried 'YTD (Feb).   And I tried with and without quotes.  The form editor recognizes them as members period but I get an error when you run the preview: variable Substitution or member not found.

    Is someone can confirm that this feature does not exist or explain how to make it work?

    Thank you.

    Here is an example of using a variable of substitution with Q-T-D form

    See you soon

    John

  • Variable substitution in case

    Hello

    I have a variable substitution named curMonth and I put it to "October".

    I want to use it in a case like

    If (& curMonth == "Jan")

    ACC = calc1;

    ElseIf (& curMonth == "February")

    VAC = Calc2;

    ...

    ElseIf (& curMonth == "October")

    ACC = calc10;

    ...

    ElseIf (& curMonth == "Dec")

    ACC = calc12;

    endif;

    When I try this the 1st condition is true then I calc1 as a result.

    I changed it to several fi... endif and I guess all conditions was real because I found the last calc (calc12) resulted in my account (acc).

    Any ideas?

    Thanks in advance

    There was another thread on the comparison of subvars for the names of the members recently:

    How to compare the name of substitution variable to static member names (no data)?

  • Name of substitution for roles

    Hi all

    After checking in the forum, that I understand the concept of the substitution of name and its functioning in the datamodeler, is perhaps not difficult to understand, but I'm not too much hustler.

    It's pretty good, almost great, you can select specific name of an object that you want to replace the name of another expression.

    but, I'm sorry that it's always a but,

    You can choose between "index, tablespaces, tables and users."

    I think that is missing the "roles" in this option,

    as part of the configuration, you can change in different environments, I think this is the main purpose of this function,

    a role is another object may be modified,

    I think might be an improvement for the next releases

    Thanks in advance

    Hello

    I logged a request for improvement.

    Philippe

  • Backup and restore of Essbase DB/App

    Hi guys,.

    This is a new requirement came as we do not have good backup in place system for our Essbase DB/Application. I went through the http://docs.oracle.com/cd/E12825_01/epm.111/epm_backup_recovery/frameset.htm?ch04s01s01s02.html

    backup and recovery of the document and have some doubts, all operational documents on DB backup as dbfiles, otl, .calc, .rul and etc... What about safeguarding Global and the Substitution Variables, Macros and business that have been written Essbase rules? that are created outside of the DB/Application level.

    Thnx,

    Ravi

    It will export all that you have defined in the definition of Migration file, explained in the documentation.

    See you soon

    John

    http://John-Goodwin.blogspot.com/

  • By comparing the dynamic fields of objects using equals and hashCode methods

    To compare the different objects of the same class with their content as jobTitleId, classificationId, deptId & classificationId had to be done and do a few steps later, using Set and the map. I was able to do it by simple substitution of equals and hashCode methods of the object class and was able to read the information (as in the map below).

    Map < LocationData, list < LocationData > >

    The following is the class I used (its been shown you so that it can be called for my problem statement):

    Class LocationData

    package com.astreait.bulkloader;

    public class LocationData {}

    String locId, deptId, jobTitleId, classificationId;

    @Override

    public boolean equals (Object obj) {}

    LocationData ld = (LocationData) obj;

    return this.deptId.equals (ld.deptId) & & this.jobTitleId.equals (ld.jobTitleId) & & this.classificationId.equals (ld.classificationId) & &

    this.locId.equals (ld.locId);

    }

    @Override

    public int hashCode() {}

    return deptId.hashCode () + jobTitleId.hashCode () + classificationId.hashCode () + locId.hashCode ();

    }

    }

    Problem:

    I am already known to which all the fields of this object, I need to make the comparison.

    IE I have to use the variables named classificationId, deptId, jobTitleId & locId etc.

    Need:

    I need to customize this logic such as names (classificationId, deptId, jobTitleId & locId etc.) fields can be learned, dynamically, as well as their values. So, as far as I understand, I've made use of 2 classes (TableClass and ColWithData), such as the list of the ColWithData is there in the TableClass object.

    I think what will happen if I substitute the same two methods "equals() and hashCode();"

    as the same thing is possible.

    TableClass class #1

    Class TableClass {}

    The list < ColWithData > cwdList;

    @Override

    public boolean equals (Object obj) {}

    Return Boolean = false;

    I need to have the logic must be set such that

    all dynamic fields can be compared

    return return;

    }

    @Override

    public int hashCode() {}

    Return int = 0;

    I need to have the logic must be set such that

    All dynamic fields for their individual codes can be found

    return return;

    }

    }

    ColWithData class #2

    Class ColWithData {}

    Pass the string; Here, the jobTitleId, classificationId, deptId, locId or any other information fields more may come.

    String data; The corresponding data or value for each jobTitleId, classificationId, deptId, locId or any other more fields.

    }

    Please let me know if I'm the procedure in the right direction or should I do a different approach. If it is allowed to use the current approach then what should be done to equals and hashCode methods?

    Finally, I need to make the map as: (is not worried how I give you, but may be considered my goal sought this logic)

    Map < TableClass, list < TableClass > > finalMap;

    I'm sorry for that. Although the problem is resolved, on my side.

  • How to put a CustomField on a data store?

    Hi all

    I tried:

    Get-myDS data store | game-customfield-myName-name-value myValue

    but no luck.

    I also note:

    $myDS = get-myDS data store

    $myDS.extensiondata

    There is a field called:

    "CustomValue.

    How to fill this extensiondata. CustomValue field?

    Even if I can't put a customfield via whole-customfield, is there a solution or a hack to store a value for a data store?

    concerning

    marc0

    I'm afraid that the New-CustomField and New-CustomAttribute in the current construction of PowerCLI don't support data warehouses.

    But you can use the CustomFieldManager to manage the fields custom data warehouses.

    First get the CustomFieldManager object.

    $cfMgr = get-view customfieldsmanager

    To create a new field, you can make

    $cfMgr.AddCustomFieldDef ("Test", "Datastore", $null, $null)

    This method returns the CustomField object. It is important to store this somewhere, because you will need the Key property in the following methods.

    You can also get this key by enumerating the fields available for any data store

    PS C:\ > $ds = Get - Datastore - name MyDS

    PS C:\ > $ds. ExtensionData.AvailableField

    Key: 591
    Name: Test
    Type: string
    ManagedObjectType: data store
    FieldDefPrivileges:
    FieldInstancePrivileges:
    DynamicType:

    To assign a value to the new field

    $cfMgr.SetField($ds.) Extensiondata.MoRef, 591, "A value") "

    To retrieve the value of the custom field

    $ds. ExtensionData.CustomValue | where {$_.} Key - eq 591}

    DynamicType DynamicProperty key value
    -----                                          --- -----------              ---------------
    A value                                        591

    Note that these custom fields of the data store are not visible in the vSphere client!

Maybe you are looking for