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

Tags: BlackBerry Developers

Similar Questions

  • Muse Business Catalyst and the customer text edition

    Can Muse Web sites cause editability of the customer text if published and hosted with catalyst for business?

    At the present time there is no client mount support Muse published sites. If you do not enable client Business Catalyst editing features, all changes are not compatible with the Muse. They will not appear in Muse and they can be replaced by future publishing operations of Muse.

    We will work to enable the functionality of the client update in future updates of Muse, but he will not be part of the next quarterly update.

    Currently, the box in British Colombia that allows you to activate the client editing feature is useful if the workflow should be only a means. A site is created and republished in Muse, then never updated day/re-published Muse (as this could therefore overwrite any changes have been made using the client edition feature).

  • CS4 automatically resize the height of the text frame to the baseline of the last line of text

    Hello

    Does anyone know of a script that automatically resizes all the heights of text frame in a document so that the bottom of each text block falls on the baseline of the last line of text in the text block? The image height must be determined by the text appearing and does not effect excess or stories of threads.

    Thank you!!

    Chung

    As text blocks have a property 'lines', lines have a property 'base' and executives have a 'geometricBounds' property, this quickly written javascript should do the trick for a block of selected text:

    app.selection[0].geometricBounds = [app.selection[0].geometricBounds[0],app.selection[0].geometricBounds[1],app.selection[0].lines[app.selection[0].lines.length-1].baseline,app.selection[0].geometricBounds[3]];
    

    (Whaddoyouknow: it can be done in one line)

    So let's loop over all the text blocks in your current document:

    allf = app.activeDocument.textFrames;
    for (f=0; f		   
  • Automatically resize the borders of text to the other bars

    I have another script action puzzle im trying to figure out.

    My program has two lines of text, stacked one on the other.

    they adjust to another, depending when the text is entered so that it remains a pretty square.

    the problem is that I can't get the text on the top bars to resize the text on the bottom bar.

    Note, it works the other way around, the background text resizes the text at the top of the page.

    any help would be apperciated.

    Here is my code

    addEventListener (Event.ENTER_FRAME, strehrows, false, 0, true);

    function strehrows(event:Event)

    {

    If (MovieClip (parent.parent) .textSelect == textArray100 ["pair1"], false, 0, true)

    {

    textArray100 ["pair1"] .autoSize = TextFieldAutoSize.LEFT;

    textArray100 ["pair13"] .autoSize = TextFieldAutoSize.NONE;

    textArray100 ['pair13'] .width = textArray100 ["pair1'] .width;

    } else

    If (MovieClip (parent.parent) .textSelect == textArray100 ["pair13"], false, 0, true)

    {

    textArray100 ["pair13"] .autoSize = TextFieldAutoSize.RIGHT;

    textArray100 ["pair1"] .autoSize = TextFieldAutoSize.NONE;

    textArray100 ["pair1'] .width = textArray100 ["pair13"] .width;

    }

    }

    Copy and paste the code that you use.  I can't debug code which is related but not the same as the code you are using.

    In addition, use the trace() function to check the values that you have control and copy and paste the output too.

    for example,.

    addEventListener (Event.ENTER_FRAME, strehrows, false, 0, true);

    function strehrows(event:Event)

    {

    trace (MovieClip (parent.parent).textSelect.name, textArray100 ["pair1'] .name, textArray100 ["pa ir13"] .name);

    If (MovieClip (parent.parent) .textSelect is textArray100 ["pair1"])

    {

    textArray100 ["pair1"] .autoSize = TextFieldAutoSize.LEFT;

    textArray100 ["pair13"] .autoSize = TextFieldAutoSize.NONE;

    textArray100 ['pair13'] .width = textArray100 ["pair1'] .width;

    } else

    If (MovieClip (parent.parent) .textSelect == textArray100 ["pair13"], false, 0, true)

    {

    textArray100 ["pair13"] .autoSize = TextFieldAutoSize.RIGHT;

    textArray100 ["pair1"] .autoSize = TextFieldAutoSize.NONE;

    textArray100 ["pair1'] .width = textArray100 ["pair13"] .width;

    }

    }

  • automatically resize the array of strings

    How to resize the string table automatically by extracting the maximum length of the string in the table? I could extract the length of the string and set the maximum length for the nodes of the array size, width and size of the array element width property and does not change. Would be a help on this?

    Just a minor tweak to the code RF to take account of the strangeness of this Text.Width property refers to the external dimension of the surrounding décor.

    Without adding the 'g' in 'Missing' is missing.   All this looks like "Just a touch" overkill select style display "Visible Elements" after the execution of the vi as

  • Set and get the custom text Sceen Reader

    Hi all

    I know not how to get and set the legend, the name & tool tip a field but I was wondering is there a way to set and or get whats in the custom screen reader text.

    I want to do this javascript example for the ToolTip his

    fieldname.assist.toolTip.value

    Thank you

    Brad

    Hi Apemancity,

    You can use fieldname.assist.speak.value

    Thank you

    Rous

  • How to resize the object + text lighting

    Hello

    1 lately, I can't resize an object.

    The surrounding border of the object is with filled rectanglers and

    not with rectangler hollow. So, I can't resize objects - how can I solve this problem?

    2. when I try to mark the text, there score perfectly but I do not see the location eventhough I choose what he.

    How can I mark the text and display the marked text (marked selected text)

    Kind regards

    Koko Fiko

    Koko Fiko,

    You can open the view drop-down list and check out the edges and Bounding Box (both must hide, indicating the possible action, implying that are displayed).

    According the description I'm not sure who can apply.

  • Automatically resize the font size?

    Does anyone have an idea how auto made in excess of text in a text block fixed?

    I import a lot of languages in fixed text blocks and it's a pain to keep the resizing or scaling manually.

    Still, I was supplying any javascript or applescript which can do. The closest was "JET_AutoFitVertical.jsx", but this resizes the text blocks

    Cheers for any help

    I think I'd write better answer here. Because us write, post to Lionel. Maybe he won't receive that kind of...

    If you want to stop stop HrizontalScaling to 70% and scale of size, below...

    While (cntsLength! = visibleChar) {}
    If (vscale > 0.7) {}
    scalingWidth (TPCV, [vscale, 1]);
    } else {}
    scalingSize (slct);
    }
    visibleChar = getVisible (slct);
    vscale = stepNum vscale;
    }

    function scalingSize (txObj) {}
    for (var i = 0; i)<>
    txObj.paragraphs [i] .size = txObj.paragraphs [i] .size - 0.5;
    txObj.paragraphs [i] = txObj.paragraphs [i] .leading .leading - 0.25;
    Redraw();
    }
    }

    change the while loop. And to add a function. It provides leadership and size of sizing.
    But if contain different sizes in paragraphs, we add loop and set the properties of each characters.

    for example.
    function scalingSize (txObj) {}
    for (var i = 0; i)<>
    for (var j = 0; j)
    txObj.paragraphs [i] [j] .characters .size = txObj.paragraphs [i] [j] .characters .size-0.5
    txObj.paragraphs [i] [j] .characters .leading = txObj.paragraphs [i] [j] .characters .leading-0.5
    rerdraw();
    }
    }
    }

    and... You want to color.

    myColor = new CMYKColor;
    myColor .cyan = 0;
    myColor .magenta = 100;
    myColor .yellow = 60;
    .black myColor = 0;

    app.activeDocument.selection [0] .fillColor = myColor;

    Its very simple example of code to apply CMYK colors.
    I'm so busy and you will yourself.

    Ten wrote... Sorry for the bad English.

  • The custom text highlighting

    Hello

    I'm looking for a way to highlight specific text elements.  From what I've seen, that the closest thing would be a RichTextField, but there is no highlight options.  There is the background color, but this highlights the section of the whole text.  My next thought was to put them up right next to each other, but each element is added with a line break, which will not work.  Any thoughts?

    Thank you!

    ActiveRichTextField lets you put in the foreground and the background of the attributes of color of a specific text box. The attributes are defined in a table, the index in the array is the index of the region.

  • Please help me with the custom text field FormCalc

    There is someone online has done a very good thing for me - they helped me create a text field that would be of type 'this document has been printed on _' and include some day the pdf was printed on the employer's intranet site.

    I had a shortcut in my favorites and would click on it and place it on each new document that I needed on.

    Because the computer I was using suddenly fell down, can't get the details of how to set it up again. I have a pdf form that includes the box, but when I open it in LiveCycle, it's just empty.

    That's what I saved:

    < field h = mm "8,4935" name = "PrintedOn" w = "141,0398 mm" x = "-0,0001 mm" y = "0 mm" xmlns ="http://www.xfa.org/schema/xfa-template/2.5/" > ""
    < ui >
    < textEdit >
    < border hand = 'right' presence = "hidden" >
    <? templateDesigner styleId aped0? > < / border >
    < margin / >
    < / textEdit >
    < /UI >
    < police size = cast "18pt" = "Tahoma" weight = "bold" >
    < filling >
    < color value = "221,221,221" / >
    < / filling >
    < / make >
    < para hAlign = "center" vAlign = "middle" / >
    < link match = "none" / >
    < activity = "prePrint" ref = "$host" >
    < script >$ .rawValue = concat ("this document has been printed on:", num2date (date (), DateFmt (1))); < /script >
    < / event >
    < / field >

    I don't remember what to do to get this working.

    I use this text box "print on" ALL the time, and I need to know what to do to get back to work quickly.

    If there is someone who could help me, I could also send you a sample of a form which includes it - so you can see exactly what I mean.

    If someone could remember how to program this kind of thing in once again and save it in LiveCycle, then explain how I can put it on another computer so I'd really, REALLY appreciate it.

    ~ Chris

    PS - this one as I had put in place only prints print message per day on the first page. If she could somehow print on EACH page of the PDF file without me having to click and add it to each page individually, it would be better... but let's first!

    Hello

    The script is here. If you place a new textfield in the Master Page and put the following script in the event of pre-publication of the field:

    $ = concat("This document was printed on: ", num2date(date(), DateFmt(1)))
    

    The language is FormCalc.

    Please note that you don't need to go to the XML Source for this. Simply select the textfield object and open the Script Editor (in the Windows menu). Drag the bottom of the editor bar so that you can see a few lines, and then set the FormCalc language.

    Should work,

    Niall

  • I want my text box to resize the web page when you add lines of text

    Hi all

    I'm new to Muse, I am quite familiar with illustrator and photoshop. My question:

    I downloaded a model, and it allows me to learn and practice the muse a bit. I want to know how I can add a text box that automatically resizes the Web page when text lines are added. Currently my text box just go to the footer when I type. Which setting I have to look?

    Thanks to you all!

    Don't forget your footer items are marked as a footer element and that your text box is not.

    Right-click on the components and check or uncheck the footer element

  • Dialog box options Type does not allow me to resize the text box, please help!

    Hello - I use the latest version of Adobe Illustrator CC on Windows 7. I need to make a text box with columns to 32.875 w x 20 h. I use the text tool, draw the box at that size and then open the "type area options" dialog box to specify the column number, gutter width etc. and it automatically resizes the text to 13.888 box w x 13,889 h without fault. I try to type the right width and height in the appropriate space and I hear the windows "error". When I click on 'Preview' show me the box of text resized to 13.888x13.999 so I don't see what I'm doing. It's infuriating, please, someone else had this problem?

    I checked the window of 'transformation' - and the 'blocking' to constrain the proportion of width and height is "unlocked."

    I has a limit to the width of the columns that you have found. For the size that you want, you will need to do it manually.

  • Automatic resizing of the pop-ups of sizing does not correctly after you convert the project RH9 RH10 until.  Any ideas?

    We went just at RH10 (upgrade came with the Adobe Technical Communication Suite 4 upgrade).  We have successfully converted four projects that had come from RH9 to RH10.  I think my only problem is that all my popups that have been configured to open it in the topic as "display in the sizing Auto popup" are open as if they were under "default page" (see image map screen below):

    Popups_Not_Autosizing_RH10.gif

    We run IE9 and Windows 7 ops system browser.  These pop-up windows worked well and is size so that we can click out of them and go back to the main topic before we converted the project.  ANY IDEAS?

    P.S. I tried already to remove the option of automatic resizing of popup display, then by saving the topic, then change back and nothing happened.  I do not change my css or the master page that popups were assigned and that worked before the conversion.

    Thank you!!  I wonder if I'll have to redo any mapping of the image to each of the popups in order to get the autosizing popups to work.  Please notify.

    Post edited by: DNCopeland I discovered another employee who has already climbed to the RH10 could open the same project and see the pop-ups that open as automatically resized for her, not as a page by default the entire window because they are for me.

    Sorry to barge here, but I wanted to pass along my experience with this bug.

    I found this automatic resizing (or custom also) pop-ups in image maps have been works well in Rh9 and broken in Rh10 in the Topic Previewer (glasses icon) BUT NOT in the real WebHelp output.

    Yes, DHCopeland, are statement that you see in the viewer section, or have tried to generate and display in actual production?

    I always test if there is no improvement after installing 10.0.1 HR patch. So far, it seems that the patch does not address this bug. I'll try another machine.

    John Daigle

    Adobe Certified RoboHelp and Captivate instructor

    Evergreen, Colorado

    www.showmethedemo.com

  • How resize the frame of existing text and also to place a different setting different page?

    I need to resize the existing text frame and also to place another different page frame.

    The one you suggest soluction for problem.

    Try kSetBoundingBoxCmdBoss.

  • 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);}
    

Maybe you are looking for

  • Satellite P845t-107 - Linux kernel does not start

    Hello! Recently, I bought my first laptop from Toshiba-> Satellite P845t-107.Unfortunately, I have a very big problem with him: none of my emergency tools work. So I will have no chance to save the HD data when Windows is broken and I can't find a cl

  • DVD region of Mat * a UJ - 820 s!

    HelloCan someone help me solve my problem on my DVD-ROM DVD region? I tried several free software DVD region, but none of them worked. Therefore, I must only watch DVDs with region 2. The strange thing is that these software worked on the laptop from

  • Recovery error - loading RAMDISK image

    Hello Please help me!I need to recover my OS, but when I put the my original recovery portable disk and restart my system when the system check the command "loading RAMDISK image", cannot go to the next step for loading menu root of recovery. Please

  • Can someone tell me what the steps are to ensure that my system works best?

    I feel the wheel that rotates a lot. I have a powerful system, so I thought that he must perform well.  I am running Yosemite 10.10.5, 3.4 Ghz, 32 GB of memory. I know that my internet is often slow and explains that some of my problems.  However, so

  • Compaq CQ58: Nothing works

    Hi guys I have a laptop Compaq CQ58 and I tried all the links but nothing works. -no Ethernet controllerNo network controllerNo pci devicesno controller communication simple pciNo sm bus controller Please help its urgent PCI\VEN_8086 & DEV_1E3A & SUB