You Are Here:

Community: Developer Discussion Boards

#1 Old Canvas vs String len - 2007-06-23, 09:30

Join Date: Aug 2006
Posts: 78
saifulhq
Offline
Regular Contributor
how is the manner when I wrote string it isn't exceed the canvas size and when is to long automatically write down

help me please!!
Reply With Quote

#2 Old Re: Canvas vs String len - 2007-06-23, 11:33

Join Date: Aug 2006
Posts: 307
axs
Offline
Regular Contributor
Take a look at this WordWrap utility class from the kobjects.sourceforge.net: http://kobjects.cvs.sourceforge.net/...va?view=markup
Reply With Quote

#3 Old Re: Canvas vs String len - 2007-06-25, 08:11

Join Date: Mar 2003
Posts: 85
Location: Hyderabad.
Send a message via MSN to Basu Send a message via Yahoo to Basu
Basu
Offline
Regular Contributor
hi,
i am also facing the same problem i saw the link given by you for wordwrap.
can you please help me in knowing how the next() method in wordwrap class which returns int for displaying the text which is longer than width of the canvas.

regards,
basu.
Reply With Quote

#4 Old Re: Canvas vs String len - 2007-06-25, 10:29

Join Date: Aug 2006
Posts: 307
axs
Offline
Regular Contributor
Quote:
Originally Posted by Basu
hi,
i am also facing the same problem i saw the link given by you for wordwrap.
can you please help me in knowing how the next() method in wordwrap class which returns int for displaying the text which is longer than width of the canvas.

regards,
basu.
Well, it's quite simple:

Code:
String text = "long text";
Font font = ... // font you're using for displaying the text
int width = ... // the desired width for text on the screen

WordWrap wrap = new WordWrap(font, text, width);

// now call the next() method until it return -1
// the -1 means no more breaks in text

boolean printing = true;
int nextBreak = -1;
int previousBreak = 0;
String currentLine = "";


while (printing) {

    nextBreak = wrap.next();


    if (nextBreak != -1) {

        currentLine = text.substring(previousBreak, nextBreak);

        // draw currentLine here...

        previousBreak = nextBreak;

    }
    else { // no more breaks

        currentLine = text.substring(previousBreak);

        // draw currentLine here...

        printing = false;

    } // end if no more breaks

} // end while printing
Reply With Quote

#5 Old Re: Canvas vs String len - 2008-02-27, 00:36

Join Date: Dec 2007
Posts: 7
JJAAZZZ
Offline
Registered User
Hey,
have a look at this as well
http://jajahdevblog.com/jasmine/?p=13
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Execute a Canvas in one file from def in a nother?? Christian V Petersen Mobile Java General 0 2005-03-10 13:25
Painting a string on a canvas gerrykilleen Mobile Java General 1 2004-02-11 17:50
Major problem with delegation to Canvas bartekn Mobile Java Media (Graphics & Sounds) 8 2003-10-08 18:46
Personal JSmith77 PersonalJava 4 2003-07-30 13:52
D211 new linux driver 1.04 not working !! franz_meyer Multimodecards 1 2002-12-12 09:31

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia