dynamic resizing of a text line

Jin
I want to create my own button with a label, so the width of the button changes depending on the size of the label, up to a certain size (in the past it the text is truncated). because I want to support multilingual optionality in the future, I decided to use the framework instead of the simple textField class textLayout.
in any case, I've created a textline like this (where "cf" is an object of format characters):
TextLineFactory.createTextLinesFromString (callback, "abcdefghijkl", new Rectangle (0,0,NaN,NaN), cf);

and then on the callback function-
private void callBack(textLine:TextLine):void
{
var w: Number = Math.min (textLine.width, 60); Let's say 60 is the maximum width of the button
var h:Number = textLine.height;
var shape: Shape = ShapeDraw.drawSimpleRect (w + 4 h + 4); my own method to create simple forms black
var sprite: Sprite = new Sprite();
sprite.addChild (shape);
Shape.x = shape.y = - 2;
sprite.addChild (textLine);
addChild (sprite);
}
How to change the width of the textLine after creating and cropped it? or y at - it a way to bake the textline width and put in this size?
see you soon,
eRez

theErez,

It is best to set the scrollRect on the parent of the line of text (sprite). Sorry for not clarifying that.

-Abhishek
(Adobe Systems Inc.)

Tags: Adobe Open Source

Similar Questions

  • dynamic resizing of columns too wide (javascript, CS5)

    Hey. I'm just starting to writing scripts for InDesign (and realize how I've been losing in recent years too much time). So far I managed to solve the minor issues myself, but this one I don't know enough to make round. I appreciate that what is needed for the solution is probably a pretty great piece of code, so I'm grateful for any advice you can give, just did he hint or nudge in the right direction.

    What I have is this little piece of code that comes if applies a style of cell for all tables in the selected block of text:

    var myTextFrame = app.selection [0];

    var myTables = myTextFrame.parentStory.tables.everyItem ();
    var myTableCells = myTextFrame.parentStory.tables.everyItem ().cells.everyItem ();

    myTableCells.appliedCellStyle = "NameOfCellStyle";

    What I have to do here is looking for one of the tables of myTables which:

    (1) are wider than myTextFrame (i.e., wider than the text block, they are in)

    (2) have exactly two columns

    (3) have a first column wider than the second column

    In these tables, the first column should be resized so that the table fits exactly inside myTextFrame.

    The best solution would be a dynamic resizing is not dependent on the specific numbers, because the size of myTextFrame may vary, but right now I'll settle for what it is, even if it means the creation of several scripts for text different widths of chassis.

    So there. After too many attempts failed, resulting in large part of me having very little evidence of what I'm doing, I'm about to give up. Any help or advice is greatly appreciated.

    Thank you

    Let's go top a step at a time.

    for (s=0; s
    

    If your tables have lines on the outer edge, zoom in! The right side of the resized table is inside the text frame, but his race is on the outside. If this is a problem, you probably have to subtract the thickness of the line of the available width as well. (I don't usually have this problem, because most of the time, my paintings is outline.)

  • Dynamic resize TextArea without scrollbars

    There is an example of a text box dynamic resizing without scrollbars on the link below, but it does not work with htmlText, only normal text.

    Any suggestions on what are the changes to the code to make it work with htmlText?

    It's link with the example:

    http://www.Adobe.com/cfusion/CommunityEngine/index.cfm?event=ShowDetails & postId = 13628 & Prod = 2 uctId

    Thank you.

    Maybe this:
    package components {}
    import flash.events.Event;
    Import mx.controls.TextArea;
     
    SerializableAttribute public class DynamicTextArea extends TextArea {}
    public void DynamicTextArea() {}
    Super();
    super.horizontalScrollPolicy = 'off ';
    super.verticalScrollPolicy = 'off ';
    this.addEventListener (Event.CHANGE, adjustHeightHandler);
    }
    private void adjustHeightHandler(event:Event):void {}
    trace ("textField.getLineMetrics (0) .height:" + textField.getLineMetrics (0) .height);
    If (height<= textfield.textheight="" +="">
    height = textField.textHeight;
    validateNow();
    }
    }
    override public function set htmlText(val:String):void {}
    textField.text = val;
    validateNow();
    height = textField.textHeight;
    validateNow();
    }
    override public function set height(value:Number):void {}
    if(TextField == null) {}
    If (height<=>
    Super.Height = value;
    }
    } else {}
    var currentHeight:uint = textField.textHeight + textField.getLineMetrics (0) .height;
    If (currentHeight<=>
    If (textField.textHeight! = textField.getLineMetrics (0) .height) {}
    Super.Height = currentHeight;
    }
    } else {}
    Super.Height = super.maxHeight;
    }
    }
    }
    override public function get htmlText (): String {}
    return textField.text;
    }
    override public function set maxHeight(value:Number):void {}
    super.maxHeight = value;
    }
    }
    }
  • Dynamically resize images on a webApp list page

    Hello world

    I used the following code to dynamically resize images for a webApp event list page:

    < img src = "{tag_image list_value}? Action = thumbnail & width = 384 & height = 253 & algorithm proportional ="/ >

    It works perfectly but when I click on the image, it is not a link to the event details page.

    Adding dynamic code I got the following only:

    list {tag_image}

    This made the image and when you click on it it went to the detail page, then is it possible to revise the dynamic code so that it renders an image which, when clicked, navigates to the page of detail?

    Would be very grateful for any advice.

    Thanks in advance.

    You encapsulate your image in an html anchor where the attribute href has the tag url for this layout in it.

  • When I change the thickness (in points) of text/lines/etc by using the arrow icons the thickness of the line jumps instantly to 1000 pts. Why?

    ILLUSTRATOR - when I change the thickness (outline/stroke) (in points) of text/lines/etc by using the icons of arrow (upwards or downwards), the thickness of the line jumps instantly to 1000 pts. How can I adjust the settings to make this feature work, because I really need in many situations. Thanks in advance!

    1.JPG

    3.png

    koenk,

    The current pastor of the corrupt file bug/preferences units seems to be:

    (1) delete your preferences HERE (close HAVE and press Ctrl + Alt + Shift / Cmd + Option + shift during startup).

    (2) ensure that the parameters English (United States) system locale and the decimal point is. (dot/full stop, no, (comma) when the machine is restarted,)

    (3) launch HAVE again and see if the subject is cured.

    You can see a long discussion here:

    https://forums.Adobe.com/thread/1871389?q=units%20bug

  • How can I align two different text lines in the same table in two different directions (centered on one and one on the left)?

    Hello

    I want to focus the two different text lines that are in the same table, but one on the Center and the other on the left. I put a < span > tag in the hope that he was overwhelmed the family of police .bottomsel table class properties and the. Police-family Cig84 and color but the text-align only: they are both on the left.

    Here is my source and CSS codes:

    Source:

    < table width = "600" border = "0" >

    < b >

    < class td = "bottomref" > < p > < span class = "bottomsel" > | < a href = "index.html" target = "_self" > Main < /a > | " < a href = "about.html" target = "_self" > on < /a > | " < a href = "clients.html" target = "_self" > customers < /a > | " < a href = "contact.html" target = "_self" > Contact < /a > | " </span > < br / >

    < span class = 'credits' > credits: < span class = "Cig84" > Cig84 </span > < / span > < /p > < table >

    < /tr >

    < /table >

    CSS:

    {.bottomsel}

    text-align: center;

    do-family: Georgia, "Times New Roman", Times, serif;

    }

    {.credits}

    text-align: left;

    }

    . {Cig84}

    Color: #F00;

    do-family: "Comic Sans MS", cursive;

    }

    Use tags to paragraph with CSS classes.

    CSS:

    . Center {text-align: center}

    .the {text-align: left}

    HTML:

    This text is centered

    This text is left-aligned

    Nancy O.

  • Script error: operator expected text = pDataMember.text.line [pQuestionNum] &amp; lt; Vacuum &amp; gt;

    Text

    You asked this question here and on the forums of DOUG.
    Part of the reason why you have not had it solved for you (or could
    Fix it yourself) is because you have not provided enough information.
    Do you get this error when you compile the script (the lightning for)
    at the top of all windows script) or when you run the file containing this
    script?
    Do you get it the first time that the script is running, or after asking a
    couple of questions?

    If you run the file in the programming environment, when an error occurs
    You should be presented with a "Debug" button which will open the
    current script and see the local, property and global variables in one of
    the flaps on the left. I suspect that the error is due to pQuestionNum
    being EMPTY or pDataMember being EMPTY or of the wrong type.
    Try adding the following two lines to the Manager "on askQuestion.
    and look for the exit in your message window:
    --
    on askQuestion me
    put "question number:", pQuestionNum
    put pDataMember, pDataMember.type
    put pDataMember.text
    -get the data
    text = pDataMember.text.line [pQuestionNum]
    -... etc.

  • Resizing of height of line after text rotation

    I really hope someone can help here.

    I have just today installed life cycle designer and I'm trying to produce my first form.

    Ive inserted a few tables, in fact all of the bases.  The problem is I want a table of 6 columns with 2 lines.  Row of the top horizontal text includes normal and the bottom row has vertically oriented text.  I can get the exact text, but the bottom line does not allow me to resize smartly, I can do what I want in excel which looks like this:

    EG1.JPG

    But in the cycle of life I just can't drag the bottom border to resize the cell.  (I can if I have not rotated text) and is the best I can get:

    EG2.JPG

    All I want is the line 2 at the same height as the text vertically aligned... Please help... crazy here... just impossible to find an agreement on this issue!

    Thank you

    Daryl

    Drag the TextObject outside the table and resize it to the desired height. Do it now in the cell and the line must be resized. That worked?

    Paul

  • Automatic resizing of the text boxes to adapt new lines

    I work with a 300 page document and I need automatic resizing all the new margin text boxes.  I can't afford to start a new document with the new settings, because it has become too complex to start.   I'm a newbie so forgive my ignorance. Any help will be appreciated.

    Select all pages that need to be adjusted in the pages (better Panel

    always - if they have a master that are applied, select the

    master pages).

    Then click on layout > margins and columns and check the box that says:

    "The page layout setting" to enable the setting of the page layout.

    Then change the margins you wish and all text blocks that are on the

    margins will adjust as well as margins (However, of text frames)

    which are not lie on the margins will remain where they are).

  • Dynamic resizing script UI

    Hello

    I wrote a dialog where the user can choose beetwen one of two global options, or several standard options. When one of the 2 global options are selected, the other standard options are hidden.

    When the standard options panel is hidden, the rest in the same dialog box size and it is simply an empty space. I tried dynamicaly resize the dialog box with the line "myWindow.layout.layout (true)"; which works, but then I lose orientation and alignment of the sub-panels values.

    I would like to know if there is a way with the layout() method does not update the whole hierarchy.

    Here is my code, you can consider and reuse it for yourself.

    To check the negative effects you can uncomment the 2 lines: / / myWindow.layout.layout (true);

    But then you have to replace the battery 'guidance values' by 'a line', and the alignment values "fill" with "left".

    Thank you

    Roman

    myWindow = new window ('dialogue', "Screen Option");

    var myPanelGlobal = myWindow.add ("panel", undefined, "Global Options", {borderStyle: "slurs"});

    myPanelGlobal.orientation = "column";

    myPanelGlobal.alignment = 'top';

    var myGroupABC = myPanelGlobal.add ("panel");

    myGroupABC.preferredSize = [260, -1];

    myGroupABC.orientation = "stack";

    myGroupABC.alignement = "fill".

    var myGroup1ABC = myGroupABC.add ('group');

    myGroup1ABC.orientation = "row";

    myGroup1ABC.alignment = 'left ';

    myGroup1ABC.add ("staticText", undefined, "Project 1");

    var myGroup2ABC = myGroupABC.add ('group');

    myGroup2ABC.orientation = "row";

    myGroup2ABC.alignment = 'right ';

    var checkboxABC = myGroup2ABC.add ("checkbox");

    checkboxABC.value = false;

    var myGroupXYZ = myPanelGlobal.add ("panel");

    myGroupXYZ.preferredSize = [260, -1];

    myGroupXYZ.orientation = "stack";

    myGroupXYZ.alignement = "fill".

    var myGroup1XYZ = myGroupXYZ.add ('group');

    myGroup1XYZ.orientation = "row";

    myGroup1XYZ.alignment = 'left ';

    myGroup1XYZ.add ("staticText", undefined, "Project 2");

    var myGroup2XYZ = myGroupXYZ.add ('group');

    myGroup2XYZ.orientation = "row";

    myGroup2XYZ.alignment = 'right ';

    var checkboxXYZ = myGroup2XYZ.add ("checkbox");

    checkboxXYZ.value = false;

    var myPanelStandard = myWindow.add ("panel", undefined, "of the Standard options", {borderStyle: "slurs"});

    myPanelStandard.orientation = "column";

    myPanelStandard.alignment = 'top';

    var myGroupA = myPanelStandard.add ("panel");

    myGroupA.preferredSize = [260, -1];

    myGroupA.orientation = "column";

    myGroupA.alignment = 'top';

    var mySubgroupA1 = myGroupA.add ('group');

    mySubgroupA1.orientation = "row";

    mySubgroupA1.alignment = 'left ';

    mySubgroupA1.add ("staticText", undefined, "Option 1");

    var mySubgroupA2 = myGroupA.add ('group');

    mySubgroupA2.orientation = "stack";

    mySubgroupA2.alignment = "fill".

    var radioA1 = mySubgroupA2.add ("radiobutton", undefined, 'Yes');

    radioA1.alignment = 'left ';

    var radioA2 = mySubgroupA2.add ("radiobutton", undefined, 'No');

    radioA2.alignment = 'right ';

    radioA1.value = true;

    var myGroupB = myPanelStandard.add ("panel");

    myGroupB.preferredSize = [260, -1];

    myGroupB.orientation = "column";

    myGroupB.alignment = 'top';

    var mySubgroupB1 = myGroupB.add ('group');

    mySubgroupB1.orientation = "row";

    mySubgroupB1.alignment = 'left ';

    mySubgroupB1.add ("staticText", undefined, "Option 2");

    var mySubgroupB2 = myGroupB.add ('group');

    mySubgroupB2.orientation = "stack";

    mySubgroupB2.alignment = "fill".

    var radioB1 = mySubgroupB2.add ("radiobutton", undefined, 'Yes');

    radioB1.alignment = 'left ';

    var radioB2 = mySubgroupB2.add ("radiobutton", undefined, 'No');

    radioB2.alignment = 'right ';

    radioB1.value = true;

    var myGroupC = myPanelStandard.add ("panel");

    myGroupC.preferredSize = [260, -1];

    myGroupC.orientation = "column";

    myGroupC.alignment = 'top';

    var mySubgroupC1 = myGroupC.add ('group');

    mySubgroupC1.orientation = "row";

    mySubgroupC1.alignment = 'left ';

    mySubgroupC1.add ("staticText", undefined, "Options 3");

    var mySubgroupC2 = myGroupC.add ('group');

    mySubgroupC2.orientation = "stack";

    mySubgroupC2.alignment = "fill".

    var radioC1 = mySubgroupC2.add ("radiobutton", undefined, 'Yes');

    radioC1.alignment = 'left ';

    var radioC2 = mySubgroupC2.add ("radiobutton", undefined, 'No');

    radioC2.alignment = 'right ';

    radioC1.value = true;

    var myButtonGroup = myWindow.add ('group');

    myButtonGroup.orientation = "row";

    myButtonGroup.alignment = 'top';

    myButtonGroup.add ('button', undefined, 'OK');

    myButtonGroup.add ('button', undefined, 'Cancel');

    checkboxABC.onClick = function()

    {

    If (checkboxABC.value == true) {}

    myGroupXYZ.visible = false;

    checkboxXYZ.value = false;

    myPanelStandard.visible = false;

    } else {}

    myGroupXYZ.visible = true;

    myPanelStandard.visible = true;

    }

    If (myPanelStandard.visible == true) {}

    myPanelStandard.maximumSize = [10000,10000];

    } else {}

    myPanelStandard.maximumSize = [0,0];

    }

    myWindow.layout.layout (true);

    };

    checkboxXYZ.onClick = function()

    {

    If (checkboxXYZ.value == true) {}

    myGroupABC.visible = false;

    checkboxABC.value = false;

    myPanelStandard.visible = false;

    } else {}

    myGroupABC.visible = true;

    myPanelStandard.visible = true;

    }

    If (myPanelStandard.visible == true) {}

    myPanelStandard.maximumSize = [10000,10000];

    } else {}

    myPanelStandard.maximumSize = [0,0];

    }

    myWindow.layout.layout (true);

    };

    var myResultOptions = myWindow.show ();

    Hi Roman,.

    The problem is that preferredSize is a "volatile" ScriptUI widgets property, she lost on the first layout. So I think you have to play with minimumSize instead. In addition, the "stack" orientation can create problems of presentation the. Luckily, it does not seem that you really need in your user interface.

    This is an approach that could help you:

    var PN_SETTINGS = {borderStyle: "sunken"},
        PN_MINSIZE = [260,0],
        PN_SPACING = 12,
        PN_GLOB_NB = 3,
        PN_STD_NB = 4,
        NULL_SIZE = [0,0],
        MAX_SIZE = [1000,1000];
    
    var u,
        w = new Window('dialog', "Option screen"),
        onCheckboxClick = function()
            {
            var v = this.value,
                idx = this.parent.parent.properties.idx,
                i = pGlobal.children.length,
                g;
    
            while( i-- )
                {
                g = pGlobal.children[i];
    
                g.visible = v ? (idx===g.properties.idx) : true;
                g.maximumSize = g.visible ? MAX_SIZE : NULL_SIZE;
    
                pStandard.visible = !v;
                pStandard.maximumSize = v ? NULL_SIZE : MAX_SIZE;
                }
            this.window.layout.layout(1);
            },
        pGlobal = (function(p,i)
            {
            with( p )
                {
                orientation = 'column';
                alignment = 'top';
                spacing = 0; // IMPORTANT
                }
    
            for( i=1 ; i <= PN_GLOB_NB ; ++i )
            with( p.add('group',u,{idx:i}).add('panel') )
                {
                // Emulate vertical spacing
                parent.margins = [0,PN_SPACING,0,0];
                minimumSize = PN_MINSIZE;
                orientation = 'row';
                alignment = ['fill','top'];
                with( add('statictext') )
                    {
                    text = "Project "+i;
                    alignment = ['left','center'];
                    }
                with( add('checkbox') )
                    {
                    value = false;
                    alignment = ['right','center'];
                    }
                children[1].onClick = onCheckboxClick;
                }
            return p;
            })(w.add('panel', u, "Global", PN_SETTINGS)),
        pStandard = (function(p,i)
            {
            with( p )
                {
                orientation = 'column';
                alignment = 'top';
                spacing = PN_SPACING;
                }
    
            for( i=1 ; i <= PN_STD_NB ; ++i )
            with( p.add('panel') )
                {
                minimumSize = PN_MINSIZE;
                orientation = 'column';
                alignment = ['fill','top'];
                with( add('group') )
                    {
                    orientation = 'row';
                    alignment = ['fill','top'];
                    alignChildren = ['right', 'center'];
    
                    add('statictext', u, "Option "+i).alignment = ['left','center'];
                    add('radiobutton', u, "Yes").value = true;
                    add('radiobutton', u, "No").value = false;
                    }
                }
            return p;
            })(w.add('panel', u, "Standard", PN_SETTINGS)),
        gButtons = (function(g)
            {
            with( g )
                {
                orientation = 'row';
                alignment = 'top';
                add('button', u, "OK");
                add('button', u, "Cancel");
                }
            })(w.add('group'));
    
    w.show();
    

    @+

    Marc

  • Dynamically resize Flex Layout

    I use flex inside a coldfusion page and would like to know how dynamically my swf in height to fit my request.

    I have a search application and the details text to cut. now, I could scroll but would like to be able to extend the height of the swf to my page of browser can scroll. Is this possible?

    I thought about Application.application.height but nothing. I don't know that the code is up to the page that resizes, but if I put this at 100% can not I put the variable within my application?

    Help, please!

    LinkMc,
    If you use the standard model it has css which says:
    Body {margin: 0px;} { overflow: hidden }<- take="" out="" the="" overflow:hidden.="" that="" is="" the="" first="" step.="" there="" is="" also="" a="">". I pulled the scrolling = 'no' just to be sure. I found myself by wrapping javascript code in the page in a

    . Then I put the height to the size of the app. When the application is shrinking and develop, I adjust the height so the footer is not all simply sit at the end of a lot of scrolling.
    AS3--> flash.external.ExternalInterface.call ("adjustDivHeight", "950");

    Also, a few issues I've seen with IE. The list never ends.

    If we've detected an acceptable version
    embed the Flash content SWF when all tests are passed
    AC_FL_RunContent)
    'src', 'acuminderFX ',.
    "width", "762."
    "height", "100%."
    "align", "middle",
    'id', 'acuminderFX ',.
    'quality', 'high ',.
    'bgcolor', '#ffffff ',.
    'name', 'acuminderFX ',.
    "flashvars", "base = https://www.jnjvision.com/',"
    "allowScriptAccess", "sameDomain",.
    'type', "application/x-shockwave-flash"
    "pluginspage", "https://www.adobe.com/go/getflashplayer."
    "wmode", "transparent".<-- get="" rid="" of="" ie="" black="">
    );

    In IE the swf appears as a black square until de on it with the mouse.
    This emphasizes the swf so that IE will take control.
    var acuFxObj = document.getElementById ("acuminderFX");
    If (acuFxObj! = null) {}
    acuFxObj.focus ();
    }

    If you look at https://www.acuminder.com/ you can see what I did to make it work. Also because obviously I had to make a few changes to the history.js. IE does not load if you does not solve the history.js

    This should be a good start.

  • using 3.1 the text line/window - change of placement?

    I'm getting used to 3.1 number compared to numbers 1.0.3, which I have worked for years. Why most upgrades of Apple want to damage?

    In the earlier version, as you type in a cell, what you type appears in a sort of window/line of text just above your worksheet. A great advantage in that, in addition to visibility, is that you have the choice of your data of the edition cell by typing either in the cell or in the window/line of text. My databases are more text than the numbers; the enormous advantage of the text window is you do not need mouse around the actual cell to add or change, and you can see the content on a single line.

    In point 3.1, the same "window" appears, but it's at the bottom of the worksheet. This course, it is much less visible, and there doesn't seem to be changed somehow. This forces you to work every bit of change within the cell.

    Issues related to the:

    1 can you change the placement of this window of text to point 3.1, so that it is at the top?

    2. is there a way to add or modify data without work inside the cell? I can't believe that apple gave to the functionality of this editing window. But then again, it was an 'upgrade '.

    Thank you!

    (1) NO.

    (2) NO.

    Motivation of apples was more likely to make the numbers on Mac OS X and numbers on iOS have a common interface.  I'm not justify whatever it is just assuming that.  That said, you can post your comments to Apple using the menu item "numbers > provide Feedback numbers" AND you can use the 2.x version number (unless you have uninstalled it).

    Numbers of 2.x is located in the folder "/ Applications/iWork ' 09.

  • Dynamic resizing of the cluster

    Is is possible to resize the cluster with buttons dynamically? I mean during run mode? If it's possible could you give me some suggestions?

    Kind regards

    Izabela

    Oh... Sorry... you may need to enable scripting.

    See here: http://decibel.ni.com/content/docs/DOC-4973

  • Is there a button auto double text line spacing?

    Hello!  I am writing a manuscript which is to be presented with text double-spaced.  While I have not physically go through all 40,000 words and insert another space is a button or function I can use to do this for me?
    Your help is much appreciated, thank you!
    TAM

    Hi Tam,

    Writing a manuscript is identical to any work published, the extra space is required between the 'lines' no letters.

    You don't say which application processing, you use to type your manuscript in. If you use Microsoft Word then, Yes, there is a button that will double space your lines for you.

    If you use Word 2007 I suggest you open your manuscript, and then press CTRL + A (that is, hold CTRL on your keyboard down and press A. This will select 'all' your text. Then go to the Ribbon of the toolbar (make sure that the Home tab is selected) and click the button that has lines on it and one up and down (this is located next to the button text justification and the trainer of paint (paint can)). Click on it and select 2.0 your lines will be double spaced throughout your manuscript now.

    If you use Word 97 or 2003, then you will find the key to line spacing on the formatting toolbar (it is the one with the police, the font size, bold, italic, thereon). Once again, the button is right next to the Justification button. The procedure of double spacing is the same as Word 2007.

    John Barnett MVP: Windows XP Expert associated with: Windows Desktop Experience: Web: http://www.winuser.co.uk; Web: http://xphelpandsupport.mvps.org; Web: http://vistasupport.mvps.org;

  • Automatically resize the custom text - TextBox

    Hi all, I have a box of text customized with gratitude of this site. I like the idea of having the text resize automatically when it reaches the length of the text for the full text box will always be in view, limiting the amount of characters, of course.

    Could someone help me what do I do?

    package com.google.zxing.client.rim;
    import net.rim.device.api.ui.Font;
    import net.rim.device.api.ui.Graphics;
    import net.rim.device.api.ui.Manager;
    
    import net.rim.device.api.ui.component.EditField;
    
    import net.rim.device.api.ui.container.VerticalFieldManager;
    public class MyTextBoxField extends VerticalFieldManager {
    
      //define some variables to be used
      //in the class
      private int managerWidth;
      private int managerHeight;
      private EditField editField;
    
       public MyTextBoxField(int width, int height) {
        super(Manager.NO_VERTICAL_SCROLL);
        managerWidth = width + 5;
        managerHeight = height + 5;
    VerticalFieldManager vfm =
          new VerticalFieldManager
            (Manager.VERTICAL_SCROLL);
    
        editField = new EditField(){
          public void paint(Graphics g) {
          getManager().invalidate();
          g.setColor(0x999999);
          Font font = this.getFont().derive(Font.PLAIN, 35);
         g.setFont(font);
    //Log.info("B get WIDTH " + b.getWidth());
    
          super.paint(g);
        }
      };
        Font font = this.getFont().derive(Font.PLAIN, 35);
         editField.setFont(font);
      vfm.add(editField);
      add(vfm);
    }
    
    public void paint(Graphics g) {
    //Log.info("This is button size " + textButton.getHeight());
      super.paint(g);
      g.setColor(0x999999);
      Font font = this.getFont().derive(Font.PLAIN, 35);
      g.setColor(0x999999);
         g.setFont(font);
      g.drawRect(0, 0, getWidth(), getHeight());
    }
    
    public void sublayout(int width, int height) {
      if (managerWidth == 0) {
        managerWidth = width;
      }
      if (managerHeight == 0) {
        managerHeight = height;
      }
      super.sublayout(managerWidth, managerHeight);
      setExtent(managerWidth,managerHeight);
    }
    
    public String getText() {
        return editField.getText();
      }
      public void setText(String text) {
        editField.setText(text);
      }
    }
    

    Try changing the method object with below:

    public void paint(Graphics g)
    {
        super.paint(g);
        g.drawRect(0, 0, getWidth(), getHeight());
    
        Font font = editField.getFont();
        g.setColor(0x999999);
        String text = editField.getText();
    
        int totalWidth = this.getWidth() - 10;
        int fontHeight  = font.getHeight();
        for(int fontSize = fontHeight; fontSize >= 5; --fontSize)
        {
            //length of the text
            int length = Font.getDefault().derive(Font.PLAIN,
                         fontSize).getAdvance(text);
            if(length > totalWidth)
            {
                //derived font for the fontSize
                font = Font.getDefault().derive(Font.PLAIN, fontSize);
                continue;
            }
        }
    
        editField.setText(text);
        editField.setFont(font);
    }
    

    Concerning

    Bika

Maybe you are looking for

  • battery after 9.3.4 problems updating iPhone 5s

    Hi all! I'm having a serious problem of battery since the last update, I did it on my iPhone 5 s 32GB. I'm not on the device and drains the battery in just a few hours! It's also very hot most of the time. Does anyone else know this? I tried to kill

  • Can not connect to iMessage. MAC OS

    Could not sign. Please check your network connection and try again. I tried to change the DNS to 8.8.8.8 etc. I deleted the .plist files I tried to use different ID, my connection is good I have a serial number I checked the date & time, place of cur

  • Ready NAS 4220 command terminal to disabled checkbox "allow instant access."

    I have a temp 4220 readynas as a file server, joined an ad. 6.2.4 current firmware There is also a file indexing on-site 24/7 running. It indexes action 4. I have a junior administrator who will recover the files deleted using the "snapshot" function

  • Hide update does not

    Windows 7 Pro 32 bit, clean install. Update Windows guard offering two optional updates, even after I chose to hide.  One is an update to support SD cards > 32 GB (that I don't need), and the other is an Office Live add-in (which I don't).  I hid the

  • How to save email in a file on my hard drive outside Windows Live Mail

    I want to save some emails in my documents, separated from my Windows Live Mail program folder.  How do I do that?