| Reply | « Previous Thread | Next Thread » |
|
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!! |
|
Take a look at this WordWrap utility class from the kobjects.sourceforge.net: http://kobjects.cvs.sourceforge.net/...va?view=markup
|
|
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. |
|
Quote:
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 | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| 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 |