How to prevent the text to be cropped when drawing

Hello

I draw a long text in an area of limited width (say half the width of the screen)... when I draw using the graphics.drawText () method, it gets cropped. It draws a lot more text only pertaining to this width. I want my text to draw in its entirety. text is expected to come online in the next (the width is always the same) and so on... How can I implement it?

Thank you and best regards.

Hi all

Thank you very much Simon.

I found a source code very good for this... I'm posting this code for other users help...

public static Vector wrapText (String text, int width)
    {
        Vector result = new Vector ();
        String remaining = text;
        while (remaining.length()>=0)
        {
            int index = getSplitIndex(remaining, width);
            if (index == -1)
                break;
            result.addElement(remaining.substring(0,index));
            remaining = remaining.substring(index);
            if (index == 0)
                break;
        }
        return result;
    }

    public static int getSplitIndex(String bigString, int width)
    {
        int index = -1;
        int lastSpace = -1;
        String smallString="";
        boolean spaceEncountered = false;
        boolean maxWidthFound = false;
        for (int i=0; iwidth)
            {
                if (spaceEncountered)
                    index = lastSpace+1;
                else
                    index = i;
                maxWidthFound = true;
                break;
            }
        }
        if (!maxWidthFound)
            index = bigString.length();
        return index;
    }

You can replace the try/catch block with the commented line (obviously after getting it without comment)... I did it because I added this code in my project in a separate service file. If you write in your screen itself you can use this line instead of the try/catch block commented code...

Copy the following code returns a vector composed of substrings based on the width of the area that you will provide. You can then draw these channels...

Best regards.

Tags: BlackBerry Developers

Similar Questions

  • How to prevent the Text Edit launch when I start my Mac? I am on OS 10.11.6

    Text Edit starts automatically when I turn on my Mac Book Pro. It brings up a plist file. I'm on OS 10.11.6. Does anyone have a suggestion?

    This is part of all things "Let's turn Mac OS in an iPad ' Apple tried to do from Lion, 10.7.x. In other words, applications start where you finally left on each start or restart. Many users hated. Apple then placed functions in Mountain Lion and before killing this behavior.

    (1) of the Apple at the top left of the screen, choose restart or shut down. Any one. Clear the check box, and then click Cancel.

    The OS will definitely remember this choice.

    (2) open system preferences. On the general tab, enable the checkboxes to request to keep the changes when closing documentsand Close windows when you exit an application.

    This should stop not only TextEdit, but any application to open on starts or restarts. Unless you have them in your login items to your user account. Then they'll start in any case each time. Preferences system again. Click users and groups. Click your left user account name, and then click the login items tab on the right. If there are applications in the list that you don't want to run each time your Mac starts or restarts, highlight each one and click on the button "-" to remove it.

  • How to clear the text < tr:inputText component when you click on

    Hello

    I have a component inputText in my page with the default "search for" and when I click on it to enter something, it should be cleared.

    Please suggest me a way to do this. That am using components of tr I can't use clientListener for that I guess.

    Help, please.

    Thank you
    Hari

    You can use trh:script
    http://MyFaces.Apache.org/Trinidad/Trinidad-API/tagdoc/trh_script.html

  • How to prevent the scrambling of text as you type

    How to prevent the scrambling of text as you type

    Hello

    1. What do you exactly mean by interference?

    2 does this happen on all applications such as word, Notepad?

    I suggest you to follow these steps and check if that helps:

    Method 1:
    Start the computer in safe mode and check if the same problem occurs:
    http://Windows.Microsoft.com/en-us/Windows-Vista/start-your-computer-in-safe-mode

    Method 2:
    Try to perform the clean boot and check if it helps:
    http://support.Microsoft.com/kb/929135

    NOTE: When you are finished troubleshooting, make sure that restore you the computer mode normal startup such as suggested in step 7 of the above article.

    Check if that helps.

  • How can I prevent the text fields and drop downs changed after the form has been signed using a digital certificate? Thank you.

    Hi all

    How can I prevent the text fields and drop downs changed after the form has been signed using a digital certificate? Thank you.

    There is also a checkbox on the dialog box 'Sign' to lock document after signing.

  • How to prevent the squishing text stacked mode smartphone

    Hello

    How to prevent the squishing of text stacked for smartphone. Not sure if I use the right termonology. In any case, when my < Hello > menu resizes to view smartphone, my menu link throws up in the rest of my text on that line. I am at a loss on what to do about it. Any CSS help would be appreciated.

    http://cupcakemary.skeeterz71.com/_cm_mockup/

    menu-stack.png

    Give your position more line height.  Adjust as required.

    H1 {line-height: 55px}

    Nancy O.

  • How to prevent the OSB 11g to change original prefixes xmlns?

    Hello


    Could someone tell me how to prevent the modification of the xml namespace that I have carefully specified in the WSDL and XSD OSB file?

    By example, if I deploy wsdl file beginning with

    <soap:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/"> ...

    Then I get to the BSO for the same wsdl wsdl file is something like

    <WL5G3N0:definitions xmlns:WL5G3N0="http://schemas.xmlsoap.org/wsdl/"/>


    He renames "SOAP" to "WL5G3N0".  This name change similar to most of the other namespace in the WSDL and XSD files xml prefixes.  This OSB causing to use for a purpose limited in our environment.  We simply turn this renaming feature off (or find different technologies of accommodation... ).


    So I hope it's possible to disable and someone knows how, in the community of Oracle users.  Could someone tell me if it is possible and how to disable the prefix renaming in OSB?


    Thank you

    or at least there is no known way to get that off, right?

    I'm not an employee of the Oracle, so I can't say with 100% confidence. I don't know a way, and I'm sure that the path does not exist.

    thinking of using 'engine for stateful service' Oracle SOA for this is very bad...

    It's not so bad. If you do not service calls in the Middle, then BPEL is not to dehydrate State, making it more or less stateless.

    DataContractSerializer seems to be picky and all pending schema corresponding to certain prefix text

    It's weird, but the code generators are a common source of bugs in SOA :-)

    Good luck!

    Vlad @ genericparallel.com

  • Text tool will not work: something prevents the text initializing engine

    My text tool will not work, there is an error that says that something is preventing the text initializing engine.

    Troubleshoot fonts | Photoshop CS6 2014 CC, CC, CS5

    I have already tried to use the methods of this link, delete the photoshop cs6 hiding from police, off preview fonts, reinstalled photoshop cs6, but nothing works.

    I really need help with this problem, I think it could be a damaged or corrupted font, but I don't know how to find corrupt fonts.

    Hi ay,.

    Please go into Photoshop preferences and then go to the tab Type.

    In it please change the text engine to Asia to the Middle East.

    Restart Photoshop and then see if it works.

    Kind regards

    Tanuj

  • How to get the text have the same effect as the video?

    Hello

    For the first time post here, but I wonder how to get the text of the titles have the same effect as the video behind her.

    For my video, I use 'bad tv' and other effects such as Gaussian that obviously changes the appearance of video, creating the look of VHS. However, I then inserted text via the title, but it normally appears. How can I make this text have the same effects as the video behind it?

    A friend told me I might need to add text to the video first, then do the effects, I have not tried, but wonder if there is an easier way, as this would require me to restart.

    EDIT: That's what I'm looking for. https://youtu.be/7_2PHQI89dI?t=24s The text has the same effect as the video.

    Thank you

    One way is to create a clip made up based on the title and the original clip. Then apply the effect.

    Another way is to use an adjustment layer.

    Good luck.

    Russ

  • How to prevent the creation of 15000 files for 300 MB each day Firefox

    Firefox creates files of 'file' in C:\Users\LeRicain\AppData\Local\Mozilla\Firefox\Profiles\dnm04rk5.default\cache2
    There are about 10,000 and 20,000 files I have to remove to get about 300 MB of space each day

    How to prevent the creation of these files in Firefox

    Here are the files from cache. Basically, it takes Web sites that access you a lot and records bits of them so they'll load faster the next time you visit them. FOR EXAMPLE if you visit Google.com much, Firefox will save some elements of this page in the cache so that the next time visit you Google.com, it will not have to re - download.

  • How to prevent the add-on compatibility checking whenever he opens Firefox?

    How to prevent the add-on compatibility checking whenever he opens Firefox?

    Which can be a problem with the compatibility.ini file in the Firefox profile folder.
    Try to rename (or delete) the file compatibility.ini in the profile folder of Firefox to see if that helps.

    You can use this button to go to the Firefox profile folder currently in use:

    Alternatively, you can check for problems with preferences.

    Delete possible user.js and files numbered prefs-# .js and rename (or delete) the file prefs.js to reset all the prefs by default, including the prefs set via user.js and pref which is no longer supported in the current version of Firefox.

  • How to make the text bigger in youtube! Cubs in youtube!

    I made the largest text where google search arrives! But when I go on youtube the text is much tinier and I 65 to cataract and I can't read the text at right! How to make the text bigger in youtube? Thank you very much! I tried everything, but nothing changes the size!

    When you view this page hit {Ctrl + 0} < is a zero number -to reset the zoom level for this area.

    https://support.Mozilla.com/en-us/KB/page+zoom

    If you move the scroll wheel, and are now the CTRL key, you can change the zoom level of the page that is viewed - both in & out.

  • lovely better does not work with windows vista home Premium what another program removes LSO and HOW to prevent the trackers?

    Question
    better privacy does not work with windows vista home Premium that another program removes LSO and HOW to prevent the trackers? Edit
    Details

    In current versions of Flash you can also do this via the control panel.

    • Control Panel > Flash Player, click on remove and erase data
  • How to make the text darker or bolder

    How to make the text darker or bolder in safari

    shutterbox-

    I'm with you.  Cataract surgery, it will take longer, and the thin, plugged in my humble OPINION, typeface they chose is really for less than 40 eyes.

    The same "BOLD" of the police system capacity would be so appreciated.

    There are 3rd party apps that can change system fonts, and I saw messages claiming success, but I'm a purist to try.

    Small fonts (to us) make it very painful to be here.  I just hope they realize that our needs must be met, as well.

  • How to Flash the text Message text in CVI

    Hi, anyone know how to Flash the text in a text control in CVI.

    Thanks for any help

    Unfortunately, there is no such simple method for flashing text.

    You must code explicitly.

Maybe you are looking for