Custom label field - extended definition

Hello

I have a problem defining the scope for a custom field. I replaced the method of layout and setting, the width of the text in a horizontal field Manager.

Custom fields are twice the width of how wide I give in the setExtent methods and layout. Kindly help me to fix it on.

Thanks in advance.

Hi SenthilKumar,

Actuall problem not in the setExtend method. It's in the paint method. For highlighting and displaying the text, you used getLeft() for x position. For your information getLeft() will give the left most pixel of this field. It will not be 0.

In your case:

1st label displayed correctly because the method getLeft returns 0 because it was the first field in the Manager.

2nd label was the real problem. When you call the getLeft method, it returns 65 (since the getLeft method generally returns the fields left in the (parent) Manager position), which you took as position x ie., you try to start the drawing of the 65th pixel not from 0th field of pixel (pixel 65th Manager (parent)). So overall, it seems that the 1st field of list took 130 pixels but it is false. Your painting is not correct, still you have 65 black pixels.

Please use the following code

protected void paint (Graphics graphics) {}
Draw the background
graphics.setColor (isFocus ()? _bgcolorFocus: _bgcolor);
graphics.fillRect (0, 0, getWidth(), getHeight());

Draw text
graphics.setColor (isFocus ()? _fgcolorFocus: _fgcolor);
graphics.drawText (_text, 0, 0);
}
It works perfectly

Tags: BlackBerry Developers

Similar Questions

  • How to disable a custom button field, extending the field 4.5

    Hi all

    I'm working on an application that builds in 4.5, but should work on almost all BlackBerry 4.5 devices from.

    My query is, I need to enable and disable a button custom field that extends the class of the field. I do use if the methods navigationMovement() and moveFocus() for devices not tactile, but on BB 9800 (Tourch) when I touch the button on the screen, it is worn.

    I don't want to use any API touch, can all about suggest me how disabled button on the ground without the help of the Touch API. Please don't suggest also on setEnable(), coz this is not supported in 4.5.

    Thank you

    Let isFocusable return false, for example

  • How to remove the focus from the field of the custom label

    Hello

    I have a question on the subject to focus on fields. I did a registration form and added a label + image and text box on a vertical field Manager. but when I scroll through image and text box get the focus and disappear from my label.
    I took the custom label field and the custom text box.
    Help, please...

    protected void drawFocus(Graphics graphics, boolean on){paint(graphics);}
    
  • Custom text field

    I want to implement a custom text field that displays its label on the leading edge of a line and its part editable on the TRAILING edge of the same way like a ChoiceField. Is there a documentation available to achieve this (maybe it's to say-sample code)? Or even if I could see the source code for ChoiceField. I develop for a Blackberry Pearl 8110 with 4.3.

    I ended up solve this using managers of horizontal inside vertical management. I have to use a label field for the edit field that accompanies it. When lines are added, I followed is the width of the new label. Then in sublayout to align the edit fields according to the maximum width more stored a Variant. Could not align all the way to the right.

    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.text.*;
    
    public class MyLayoutManager extends VerticalFieldManager {
        protected int maxw;
        protected Font font;
        protected int font_height;
        private int size;
    
        public MyLayoutManager() {
            super(Field.USE_ALL_WIDTH);
            this.maxw = 0;
            this.font = Font.getDefault().derive(Font.PLAIN, 12);
            this.font_height = this.font.getHeight();
            this.size = 0;
        }
    
        public void addLine(String label, int initial) {
            MyEditField mef = new MyEditField(label, initial);
            int label_width = this.font.getAdvance(label);
            this.maxw = Math.max(label_width, this.maxw);
            this.add(mef);
            this.size++;
        }
    
        public int getPreferredHeight() {
            return this.size * this.font_height;
        }
    
        public int getPreferredWidth() {
            return 240;
        }
    
        protected void sublayout(int maxwidth, int maxheight) {
            int y = 0;
            for (int i = 0; i < this.size; i++) {
                Field f = this.getField(i);
                this.setPositionChild(f, 0, y);
                this.layoutChild(f, 240, this.getPreferredHeight());
                y += this.font_height;
            }
            this.setExtent(240, this.getPreferredHeight());
        }
    
        protected class MyEditField extends HorizontalFieldManager {
            private LabelField the_label;
            private JunkField the_value;
    
            public MyEditField(String label, int initial) {
                super(Field.USE_ALL_WIDTH);
                this.the_label = new LabelField(label);
                this.the_label.setFont(font);
                this.the_value = new JunkField(initial + "");
                this.the_value.setFont(font);
                this.add(this.the_label);
                this.add(this.the_value);
            }
    
            public int getPreferredHeight() {
                return font_height;
            }
    
            public int getPreferredWidth() {
                return 240;
            }
    
            protected void sublayout(int maxwidth, int maxheight) {
                Field f = this.getField(0);
                this.setPositionChild(f, 0, 0);
                this.layoutChild(f, maxwidth, maxheight);
                f = this.getField(1);
                this.setPositionChild(f, maxw + 20, 0);
                this.layoutChild(f, maxwidth, maxheight);
                this.setExtent(maxwidth, font_height);
            }
    
            private class JunkField extends EditField {
                private boolean firstFocus;
    
                public JunkField(String deflt) {
                    super(Field.EDITABLE | Field.FOCUSABLE);
                    this.setText(deflt);
                    this.setFilter(new NumericTextFilter(TextFilter.NUMERIC));
                    this.firstFocus = false;
                }
    
                protected void onFocus(int direction) {
                    this.firstFocus = true;
                }
    
                protected boolean keyChar(char key, int status, int time) {
                    if (this.firstFocus) {
                        this.setText("");
                        this.firstFocus = false;
                    }
                    return super.keyChar(key, status, time);
                }
            }
    
        }
    }
    
  • view the json data in the custom list field

    Hi, I did analysis json and I created the custom list field. Now, I want to display only the data analyzed in my custom list field. I'll post my analyzed data from json and here is the code for my custom list field
    data analyzed.
    I have THREE channels of json and I want to show content tittle and date in the list filed. I'll post the screenshot of my list.

    JSONArray jsnarry = new JSONArray(responce);
                System.out.println("\n--length----- "+jsnarry.length());
                //System.out.println("....................................................=");
                for (int i = 0; i < jsnarry.length(); i++){
    
                    JSONArray inerarray = jsnarry.getJSONArray(i);
                        //System.out.println("\n-inerarray-values----- "+inerarray.getString(i1));
                        String TITTLE = inerarray.getString(1);
                        String CONTENT = inerarray.getString(2);
                        String DATE = inerarray.getString(3);
                                                           System.out.println("TITTLE= "+TITTLE);
                        System.out.println("CONTENT= "+CONTENT);
                        System.out.println("DATE= "+DATE);
    
    }
    

    output

    [0.0] --length----- 2
    [0.0]
    [0.0] -innerarray-length----- 6
    
    [0.0] TITTLE= BJP State President Sanjay Tandon's visit to Amita Shukla's Home
    [0.0] CONTENT=  BJP President Chandigarh Sanjay Tandon at Amita Shukla's Home
    [0.0] DATE= 2013-01-04
    [0.0] ................................................
    [0.0] TITTLE= Sanjay Tandon at mahasamadhi of Satya Shri Sai baba.
    [0.0] CONTENT= BJP Chandigarh President, Sanjay Tandon mahasmadhi of Sri Satya Sai Baba.(Andhra Pradesh)
    [0.0] DATE= 2013-01-13
    

    and my custom list field

           super(NO_VERTICAL_SCROLL);
    
             String TITTLE="TITTLE";
             String CONTENT = "CONTENT";
             String DATE = "DATE";
    
             v.addElement(new ListRander(listThumb, TITTLE, CONTENT,DATE, navBar));
    
             myListView = new CustomListField(v){
    
                 protected boolean navigationClick(int status, int time) {
                     //Dialog.alert(" time in milisec :" + time);
                     return true;
                 }
             };
    

    CustomListField.java

    public class CustomListField extends ListField implements ListFieldCallback {
    
        private Vector _listData;
        private int _MAX_ROW_HEIGHT = 100;
    
        public CustomListField (Vector data) {
    
            _listData = data;
            setSize(_listData.size());
            setSearchable(true);
            setCallback(this);
            setRowHeight(_MAX_ROW_HEIGHT);
    
        }
    
        public int moveFocus (int amount, int status, int time) {
    
            this.invalidate(this.getSelectedIndex());
            return super.moveFocus(amount, status, time);
    
        }
    
        public void onFocus (int direction) {
    
            super.onFocus(direction);
    
        }
    
        protected void onUnFocus () {
    
            this.invalidate(this.getSelectedIndex());
    
        }
    
        public void refresh () {
    
            this.getManager().invalidate();
    
        }
    
        public void drawListRow (ListField listField, Graphics graphics, int index, int y, int w) {
    
            ListRander listRander = (ListRander)_listData.elementAt(index);
            graphics.setGlobalAlpha(255);
            graphics.setFont(Font.getDefault().getFontFamily().getFont(Font.PLAIN, 24));
            final int margin =5;
    
            final Bitmap thumb= listRander.getListThumb();
            final String listHeading = listRander.getListTitle();
            final String listDesc= listRander.getListDesc();
            final String listDesc2= listRander.getListDesc2();
            final Bitmap nevBar = listRander.getNavBar();
    
            //list border
            graphics.setColor(Color.BLACK);
            graphics.drawRect(0, y, w, _MAX_ROW_HEIGHT);
    
            graphics.drawBitmap(margin, y+margin+10, thumb.getWidth(), thumb.getHeight(), thumb, 0, 0);
    
            graphics.drawText(listHeading, 3*margin+thumb.getWidth(), y+margin);
            graphics.setColor(Color.BLACK);
    
            graphics.drawText(listDesc, 3*margin+thumb.getWidth(), y+ margin+30);
            graphics.drawText(listDesc2, 3*margin+thumb.getWidth(), y+ margin+60);
    
        }
    
        public Object get(ListField listField, int index) {
    
            String rowString = (String) _listData.elementAt(index);
            return rowString;
    
        }
    
        public int indexOfList (ListField listField, String prefix, int start) {
    
            for (Enumeration e = _listData.elements(); e.hasMoreElements(); ) {
    
                String rowString = (String) e.nextElement();
                if (rowString.startsWith(prefix)) {
    
                    return _listData.indexOf(rowString);
    
                }
    
            }
    
            return 0;
    
        }
    
        public int getPreferredWidth(ListField listField) {
    
            return 3 * listField.getRowHeight();
    
        }
    
    }
    

    Listrander.Java

    public class ListRander {}

    private bitmap listThumb = null;
    incognito bar Bitmap = null;
    private String listTitle = null;
    private String listDesc = null;
    private String listDesc2 = null;

    public ListRander (Bitmap listThumb, String listTitle, String listDesc, String listDesc2, Bitmap navBar) {}
    this.listDesc = listDesc;
    this.listDesc2 = listDesc2;
    this.listThumb = listThumb;
    this.listTitle = listTitle;
    this.navBar = bar navigation;
    }
    public getListThumb() {Bitmap image
    Return listThumb;
    }
    {} public void setListThumb (listThumb Bitmap)
    this.listThumb = listThumb;
    }
    public getNavBar() {Bitmap image
    return the navigation bar;
    }
    {} public void setNavBar (navigation bar of the Bitmap)
    this.navBar = bar navigation;
    }
    public String getListTitle() {}
    Return listTitle;
    }
    {} public void setListTitle (String listTitle)
    this.listTitle = listTitle;
    }
    public String getListDesc() {}
    Return listDesc;
    }
    {} public void setListDesc (String listDesc)
    this.listDesc = listDesc;
    }
    public String getListDesc2() {}
    Return listDesc2;
    }
    public void setListDesc2 (String listDesc2) {}
    this.listDesc2 = listDesc2;
    }
    }

    You seem to have two problems here and are confusing them.  You must break the problem into two parts

    (1) extract the data from the entry and create the objects you want to display

    2) display in a list, a set of objects.

    Let's get the sorted first premiera.

    I will suggest what to do here, but in practice, you might actually think about this yourself as part of the design phase of your application.  You should do this, not me, because then you will have all the information available.  At the present time, I have just what you said, which is not much.  So maybe what I'm telling you is not correct for your application.  Only you can decide that.  And be blunt here, you should have decided this before you start coding.  Do you want you could lead down the wrong path.  You must think of your application as a home - as the architect must design all the rooms, and how they will be built, before you start building the House.  You do not, then we are building the rooms on the fly.  Who knows if they will be fit at home?

    In this case, I think you need to create an object that represents each of the elements in the internal array of new data.  call this object

    NewsItem

    This object will have attributes, such as its title, content, date, the linked image and so on, each of whom have will get and set methods.  While you treat each inner element fetch you the associated entry and update the object.

    When you have finished the inner loop of processing, you now have a complete

    NewsItem

    Object, so you will add it to a collection, an array of NewsItem objects, call this _newsItems.  You will create it at the beginning - you know how many entries it takes because it is the number of entries in your outdoor table.

    So before you start to deal with JSON, create your table and the 'index' value of 0.

    Once you have created your Newsitem, add this in the table to the position 'index' and increment "index".

    And once you have analyzed all the JSON, you will have a complete picture.  This is part 1 finished!

    And note in your drawListRow, you are given a clue - that is the index in your tables in _newsItems.  So you can easily find which entry to view and display it correctly.  But it is part 2 and is a separate issue.

  • custom bitmaps field not change image when click on

    I created a custom bitmap field and I change the image on the center of my field of custom bitmaps and unfocus

    but when I implement the method of navigation click to change the image when you click on this image does not change...

    my custom bitmap field filed only to focus or unfocus on the image does not change my field of custom bitmaps.

    Bitmap onfocus = Bitmap.getBitmapResource("111.png");
                    Bitmap onunfocus = Bitmap.getBitmapResource("666.png");
                    mybutton1 = new CustomBitmapField(0,"",onunfocus,onfocus,Field.FOCUSABLE){
                         protected boolean navigationClick(int status, int time) {
    
                             mybutton1.setBitmap(Bitmap.getBitmapResource("favu.png"));
    
                             return true;
    
                         }
    
                    };
    add(mybutton1);
    

    and my class of field customBitmap is

    public class CustomBitmapField extends BitmapField {
    
        Bitmap Unfocus_img, Focus_img, current_pic;
        int width;
        String text;
        Font font; 
    
        public CustomBitmapField(int width, String text, Bitmap onFocus, Bitmap onUnfocus, long style) {
            // TODO Auto-generated constructor stub
            super();
            Unfocus_img = onUnfocus;
            Focus_img = onFocus;
            current_pic = onFocus;
            this.text = text;
            this.width = width;
    
        }
        protected void layout(int width, int height)
        {
            setExtent(current_pic.getWidth(), current_pic.getHeight());
        }
        protected void paint(Graphics graphics)
        {
            /*try
            {
                    FontFamily fntFamily = FontFamily.forName("BBAlpha Sans");
                    font = fntFamily.getFont(Font.BOLD,14);
            }
            catch(Exception e)
            {
                font = Font.getDefault();
    
            }
            graphics.setFont(font);
            graphics.setColor(Color.WHITE); */
            graphics.drawBitmap(0, 0, current_pic.getWidth(), current_pic.getHeight(), current_pic, 0, 0);
    
            //graphics.drawText(text, width, 7);
        }
        protected void onFocus(int direction)
        {
            super.onFocus(direction);
            current_pic = Unfocus_img;
    
            this.invalidate();
        }
      protected void drawFocus(Graphics graphics, boolean on)
      {
    
        }
        protected void onUnfocus()
        {
            super.onUnfocus();
            current_pic = Focus_img;
            invalidate();
        }
        public boolean isFocusable() {
            return true;
        }
        protected boolean navigationClick(int status, int time) {
    
            fieldChangeNotify(0);
            return true;
        }
    
    }
    

    When you debug this code, which of your methods of navigationClick, is actually used?

    When you expect the bitmap change, the code should lead object so that to happen.  Paint running?  This is the correct Bitmap painting?

    If you answer these questions, I think that you figure to yourself what is the problem.

    While you're there, you can also watch the following Threads that you have started or contributed to.  Can you solve or continue to contribute to these?

    http://supportforums.BlackBerry.com/T5/Java-development/gif-animation-not-displaying-properlly/m-p/2...

    http://supportforums.BlackBerry.com/T5/Java-development/timepicker-issue/m-p/2387819

    http://supportforums.BlackBerry.com/T5/Java-development/ListField-focus-color-problem/m-p/2407881#m2...

  • Slider custom text field (Cap) does not appear

    All;

    I created a custom text field based on the standard text field, changes work fine (really just a custom height and width and a border).  The problem is the method of painting which seems to remove the cap of the field when it gets the focus.  To be clear the carret never shown at all.

    public class CustomText extends TextField //cutom text field width
    {
        //Custom Height and Width in Pixels
        final static int textwidth=125;
        final static int textheight=25;
    
         CustomText()
         {
         super(); // Call the default constructor    
    
         //Border for text fields
         XYEdges padding = new XYEdges(5, 5, 5, 5); //space between box and border
         Border theborder = BorderFactory.createSimpleBorder(padding, Border.STYLE_SOLID);
    
         //Assign the border to the object
         this.setBorder(theborder);
         }
    
         public void onFocus( int direction )
         {
            super.onFocus( direction ); //invoke parent procedure
            invalidate(); //mark for redraw
         }
    
         public void onUnfocus()
         {
        super.onUnfocus(); //invoke parent procedure
        invalidate(); //mark for redraw
         }
    
         //Override the layout with the custom Width and Height
         protected void layout(int width, int height)
         {
            super.layout(textwidth,textheight);
            setExtent(textwidth,textheight);
    
         }      
    
        //Override the display message such that no message is displayed when the field is full
        protected void displayFieldFullMessage()
        {
        }
    
        //Override the default paint method to call the super class constructor and then assign the border
        protected void paint(Graphics graphics)
        {
           // int prevColor = graphics.getColor(); //Save Previous Color
            graphics.setBackgroundColor(Color.LIGHTGRAY); // Set to Gray
            graphics.clear(); // Clear for redraw
            super.paint(graphics); //Force Redraw of Object
          //  graphics.setColor(prevColor); //restore for cursor paint
    
        }
    
    };
    

    In the paint in the first and last method lines that are commented out were a soloution that I tried after reading on this subject.  Something along the lines of the restoration of the default color, but unfortunately without success.   Any ideas would be more useful

    Thank you!

    Quick thoughts:

    (a) to remove the requirement to substitute paint by setting the background a Color.LIGHTGRAY using the base class

    (b) you put on the field by using this:

    Super.Layout (TextWidth, TextHeight);

    If you then do the following:

    setExtent (textwidth, textheight);

    you are likely to confuse the field.  If you still want to use the entire height and use the full width and then try to deal with it in the Style, that is, replace this:

    Super(); Call the default constructor

    with this

    Super(TextField.USE_ALL_HEIGHT |) TextField.USE_ALL_WIDTH); Call the default constructor

    (c) why you override onFocus and onUnfocus?  I would like to delete these if you do not have anything specific to these methods.

    Make these changes, and you'll have a more simple TextField.  See if these changes will solve the problem of the caret too.

  • Label field

    Hello

    I need a label field that when clicked should push a new screen. So I wrote a label custo field but am not able to understand how to perform the action.

    I write the code below, please tell me where I'm wrong.

    It's the customlabelField

    / public final class CustomLabelField extends LabelField {}
    public m_cKeyListener KeyListener;
    Private GlideApplication _app.
    String strCheckInURL ="";
    private int horMargin = 8; final int innerMargin = 5; / / Adding dembele January 11 for more details
    private police objBigFont = Font.getDefault () .derive (Font.BOLD, 23); Are subject
    private police objMediumFont = Font.getDefault () .derive (Font.BOLD, 17); Are subject
    private police objSubTitleFont is Font.getDefault (.derive(Font.BOLD,16));.
    private police objSmallFont = Font.getDefault () .derive (Font.BOLD, 13); Are subject
    final int fieldWidth = ((Display.getWidth (-(horMargin*3))) > 1);

    public interface KeyListener {}
    public abstract void PerformAction (CustomLabelField pCustomLabelField);

    }
    Public Sub paintBackground (Graphics g)
    {
    XYRect xyrect = this.getExtent ();
    g.setFont (objSubTitleFont);
    g.setColor (0x0060AAF0);
    g.fillRect (0, 0, xyrect.width + 450, xyrect.height + 450);
    g.setColor (Color.DARKGRAY);
    g.drawLine (0, 0, xyrect.width, 0);
    g.setColor (Color.WHITE);
    g.drawText ("more details", innerMargin, (xyrect.height > 1)-(objSubTitleFont.getHeight () > 1) ');
    g.drawText (' > ', (xyrect.width - objSubTitleFont.getAdvance (">")-innerMargin), (xyrect.height > 1)-(objSubTitleFont.getHeight () > 1));
    }
    Protected Sub layout (int width, int height) {}
    width = fieldWidth;
    Height = objSubTitleFont.GetHeight () + 14;
    Super.Layout (width, height);
    super.setExtent (width, height);
    }

    public void SetKeyListener (KeyListener pKeyListener) {}
    m_cKeyListener = pKeyListener;
    }
    {public boolean trackwheelClick (int status, int time)
    Boolean lRetVal = false;
    If (null! = m_cKeyListener) {}
    TSTC objAirportInfo = new FlightInfo();
    _APP.pushScreen (objAirportInfo);
    m_cKeyListener.PerformAction (this);
    lRetVal = true;
    }
    return lRetVal;
    }
    }

    and this cusomlabel, I add in another page, the code for this is also attached below,

    Please tell me if I am wrong anywhere, I'm new to the blackberry development, for help, it's urgent. Thank you in advance.

    VerticalFieldManager vfmMoreDetails = new VerticalFieldManager();
    CustomLabelField lfAirportInfoMoreDetails = new CustomLabelField();

    HorizontalFieldManager hfmRow2 = new HorizontalFieldManager (Manager.HORIZONTAL_SCROLL);

    hfmRow2.add (lfAirportInfoMoreDetails);

    hfmRow2.setMargin (0,0, 0, 15);

    SF SpacerField = new SpacerField (0.20);

    hfmServices.setMargin ((subTitleFont.getHeight ()) + (bigRowSpace * 3), 0, 0, 0);
    vfmServices.add (hfmServices);
    vfmServices.setMargin (0, 0, 0, 15);
    vLayout.add (vfmServices);
    vLayout.add (sf);
    vLayout.add (hfmRow2); tmp commented
    Add (vLayout);

    My requirement is clicked, the label field, more details, will take you to a new screen flight info.

    Please help me

    Hi, thanks friends, I could implement the listener of the field with the code below, and less when I removed sublayout and changed the layout, he began to work, here are the labour code

    LabelField lfMoreDetails = new LabelField "(more Details", Field.FOCUSABLE)
    {
    protected void paintBackground (Graphics g)
    {
    XYRect xyrect = this.getExtent ();

    g.setColor (0x0060AAF0);
    g.fillRect (0, 0, subTitleFont.getHeight () + 350, subTitleFont.getHeight ());
    g.setColor (0xffffff);
    g.setColor (0xffffff);
    g.setFont (subTitleFont);
    int y = bigRowSpace;
    g.drawText ("more details", 10, y, Graphics.ELLIPSIS, xyrect.width-(10 + 10) ');
    g.drawText (' > ', (xyrect.width - objSubTitleFont.getAdvance (">")-innerMargin), (xyrect.height > 1)-(objSubTitleFont.getHeight () > 1));
    y += (subTitleFont.getHeight ()) + (bigRowSpace * 2);
    }
    protected void layout (int width, int height)
    {
    width = Display.getWidth ()-(10 + 10);
    height = serviceSectionHeight;
    setExtent (width, height);
    }

    protected boolean navigationClick (int final status, time final int) {}
    net.rim.device.api.ui.UiApplication.getUiApplication () .pushScreen (new FlightInfo());

    fieldChangeNotify (0); / / See the difference here.
    Returns true;
    }

    };
    lfMoreDetails.setChangeListener (this);

  • Custom edit field - not drawing while typing of the text

    I created a custom edit field (code below), but there is no slider or text drawn while typing.

    The text appears if you click another field on the screen, but not while typing. I guess it has something to do with my method of painting, but I don't know?

    Tips for making more effective methos painting would be a bonus!

    Thank you!

    import net.rim.device.api.system.Display;
    import net.rim.device.api.ui.Font;
    import net.rim.device.api.ui.FontFamily;
    import net.rim.device.api.ui.Graphics;
    import net.rim.device.api.ui.component.EditField;
    
    public class CustomTextField2 extends EditField {
    
        private int fieldWidth;
        private int fieldHeight;
        private int button_colour = 0xF9F9F9;
        private int text_colour = 0x666666;
        private int border_color = 0xCCCCCC;
        private Graphics graphics = null;
        public CustomTextField2(long arg0) {
            super(arg0);
            fieldWidth = Display.getWidth()-100;
            //int off = 8;
            FontFamily fFam = null;
    
            try {
                fFam = FontFamily.forName("SomeFontHere");
            }
            catch (ClassNotFoundException e) {
                e.printStackTrace();
            }  
    
            Font font = fFam.getFont(Font.PLAIN, 20);
    
            Font defaultFont = font;
            int off = 8;
            fieldHeight = defaultFont.getHeight() + off + 10;
            this.setPadding(5, 20, 5, 20);  }
    
        protected void paint(Graphics graphics) {
    
            graphics.setColor(button_colour);
            graphics.fillRect(0, 0, fieldWidth, fieldHeight);
            graphics.setColor(border_color);
            graphics.drawRect(0, 0, fieldWidth, fieldHeight);
            graphics.setColor(text_colour);
            graphics.drawText(this.getText(),20,10/2);               super.paint(this.graphics);
        }
    
        protected void onFocus(int direction) {
    
            button_colour = 0xF9F9F9;
            text_colour = 0x666666;
            border_color = 0x3598CC;
            this.invalidate();
        }
    
        protected void onUnfocus() {
    
            button_colour = 0xF9F9F9;
            text_colour = 0x666666;
            border_color = 0xCCCCCC;
            this.invalidate();
        }
    
        protected void drawFocus(Graphics graphics, boolean on) {
    
              super.drawFocus(graphics, on);
        }
    
        protected void fieldChangeNotify(int context)
        {
            try {
    
            this.getChangeListener().fieldChanged(this, context);
    
            }
            catch (Exception e){
    
            }
        }
    
        public int getPreferredHeight() {
    
            return fieldHeight;
        }
    
        public int getPreferredWidth() {
    
            return fieldWidth;
        }
    
        protected void layout(int arg0, int arg1) {
    
            setExtent(getPreferredWidth(), getPreferredHeight());
        }
    }
    

    I just posted a code in another thread - he does most, if not all, of what you want. Take a look:

    Custom elegant EditField (textbox)

  • Custom - Date field that is this feature called?

    I need to create a custom date field. It is personalized because it shows, on the one hand, whatever it is related to the dates and then it indicates that one choice at a time.

    Kinda like this feature

    I want to create something like that, but not the dates. I want to add alist like apples, mangoes, peaches, and plums have a scrolling after another, without showing a huge drop; So basically in the above format. Help, or coding sample please.

    I think you can do this with a SpinBoxField, if you extend it to support of Bitmaps rather than the text that is, it supports at the moment.

  • The location of the custom metadata fields

    I'm trying to locate the custom metadata fields. Consider a custom metadata field where his dname = xPracticeWork and dCaption = practical work.

    I am trying to locate it using the old way.

    When to activate the settings regional french user and see this metadata field appears in English.When I turn on the location in the information system Audit, it is said

    unable to find string 'fr.Practice Work'

    So I tried including < @fr. The practice of work =Work practice@ >

    but he throws and error message saying unknown resource definition tag

    If I do the dCaption as PracticeWork and try to < @fr. PracticeWork =Work practice@ > it works absolutely well.

    It seems that the practical work being two letter word definition tag allows no space.

    Can someone please help me on this.


    Thank you

    Vanina

    It's very simple, you write a string that you want to display in the form of legend (I use this trick in the profiles, if I want to rename a metadata custom field exist for the type having a different meaning), or write you a string Id cannot contain spaces, which solved somewhere, usually a custom - component see what thread change location String for details how to create a resource exploitation translations.

  • How can you change the name of the custom form fields?

    I made a form that required me to add a few custom fields.  When the form sends an email, custom fields appear as "Custom".  I need them to say what is the form field.  Can we achieve this by Muse?

    I tried to change the name of the script in DreamWeaver, but it caused the form to fail.

    Any ideas would be great.

    Thank you.

    You are not able to just type the new name in and on "Custom" label above it and see it changed in your email automatically?

  • Label field do not align right

    Hello

    The label field is not aligining to the right. Here is my code

    Container {
                            id:database_search_top_container
                            leftPadding: 20.0
                            rightPadding: 20.0
                            preferredHeight: 110.0
                            preferredWidth: 720//displayInfo.pixelSize.width
                            background: recent_container_bg.imagePaint
                            verticalAlignment: VerticalAlignment.Fill
                            horizontalAlignment: HorizontalAlignment.Fill
    
                            layout: StackLayout {
                                orientation : LayoutOrientation.LeftToRight
                            }
                            Label {
                                verticalAlignment: VerticalAlignment.Center
                                horizontalAlignment: HorizontalAlignment.Right
                                id:recent_label_name
                                objectName:"recent_label_name"
                                preferredWidth: 720//displayInfo.pixelSize.width
                                preferredHeight: 110.0
                                text:"Dummy Data"
                                textStyle.color: Color.White
                                textStyle.fontSize: FontSize.Large
                            }
    
                        }
    

    There is a bug in the API. But you can align it to the right this way.

    Container {
        id:database_search_top_container
        leftPadding: 20.0
        rightPadding: 20.0
        preferredHeight: 110.0
        preferredWidth: 720//displayInfo.pixelSize.width
        background: recent_container_bg.imagePaint
        verticalAlignment: VerticalAlignment.Fill
        horizontalAlignment: HorizontalAlignment.Fill
    
        layout: StackLayout {
            orientation : LayoutOrientation.LeftToRight
        }
        Label {
            verticalAlignment: VerticalAlignment.Center
            horizontalAlignment: HorizontalAlignment.Right
            id:recent_label_name
            objectName:"recent_label_name"
            preferredWidth: 720//displayInfo.pixelSize.width
            preferredHeight: 110.0
            text:"Dummy Data"
            textStyle.color: Color.White
            textStyle.fontSize: FontSize.Large
    
            layoutProperties: StackLayoutProperties {
                spaceQuota: 1.0
            }
            textStyle.textAlign: TextAlign.Right
        }
    }
    
  • Highlight a text of label field

    Hello

    I have a label field that is added inside the VerticalFieldManager I have set the length and height of the label field in which area I want to display the text.

    now, I want my text to scroll inside the labelfield.

    Here is my code please help...

    VerticalFieldManager vf = new VerticalFieldManager (Manager.VERTICAL_SCROLL);

    LabelField history = new LabelField (story_data.elementAt (0) m:System.NET.SocketAddress.ToString (), FIELD_HCENTER |) FOCUSABLE) {}
    {} public void paint (graphics net.rim.device.api.ui.Graphics)
    graphics.setColor (Color.BLACK);
    graphics.setFont (net.rim.device.api.ui.Font.getDefault () .derive (net.rim.device.api.ui.Font.BOLD, 10));
    Super.Paint (Graphics);
    }
    Protected Sub layout (int width, int height) {}
    Super.Layout (width, height);
    this.setExtent ((MyApp.width) - 30, 300);
    }
    };
    story.setBackground (BackgroundFactory.createSolidBackground (Color.WHITE));
    story.setMargin (10, 15, 15, 15);
    story.setPadding (5, 5, 5, 5);
    story.setFont (Resize.getFirstFont ());
    VF. Add (Story);
    VerticalFieldManager temp = new VerticalFieldManager();
    Temp.Add (VF);
    Add (temp);

    Thanx

    Thanks peter... my problem is solved... Here's my code for update... VerticalFieldManager vf = VerticalFieldManager(Manager.VERTICAL_SCROLL | nouveau Manager.VERTICAL_SCROLLBAR |) Manager.VERTICAL_SCROLL_MASK | Manager.VERTICAL_SCROLLBAR_MASK) {' protected void sublayout (int width, int height) {super.sublayout (width, height); this.setExtent ((MyApp.width)-20, (MyApp.height)-(MyApp.height)/4) ;}};}} LabelField history = new LabelField (story_data.elementAt (0) m:System.NET.SocketAddress.ToString (), FIELD_HCENTER) {public void paint (graphics net.rim.device.api.ui.Graphics) {graphics.setColor (Color.BLACK); super.paint (graphics) ;}};} story.setBackground (BackgroundFactory.createSolidBackground (Color.WHITE)); story.setMargin (10, 15, 15, 15); story.setPadding (5, 5, 5, 5); story.setFont (Resize.getSecondFont ()); VF. Add (Story); Add (VF);

  • Highlight a label field.

    I have a label field on a screen that can hold a large amount of text which will disappear from the screen, how can I make cela scrollable?

    I tried to put the label in a VerticalFieldManager, but without success.

    Thank you

    First of all, please learn how to use the search box on the top of the screen.  If you are looking for 'LabelField' returned this thread as the first among others:

    LabelField Scrollable

    The thread gives a solution similar to swati srivastava's.  morpheusghost gives a slightly different resulting in almost the same visual appearance.

    However, none of these solutions is perfect.

    If the text in the field is greater than 2 screens (or the field Heights), jumping from the beginning to the end (that's what happens when divert you attention from the NullField first to the last NullField) never allow see her in the middle of your LabelField.  Consider using a TextField for longer texts.  Make it FOCUSABLE and READONLY and add it to a VerticalFieldManager with VERTICAL_SCROLL (and possibly VERTICAL_SCROLLBAR).  TextField and his descendants may have the focus within the field (the cursor).  That's how you let the user scroll.

    Otherwise, you can have no field focusable and manage the movements of navigation, using setVerticalScroll of the VerticalFieldManager containing your LabelField.  But that would require more code and is less intuitive.

Maybe you are looking for