| Reply | « Previous Thread | Next Thread » |
|
Hi,
I see that the screen width reported by Nokia 3650 device (canvas.getWidth()) is much wider than that of the actual screen width. Is there a way to know the acurate screen width in Pixels on Nokia series 60 device? -Nachiket |
|
The only thing I can think of is are you creating an off screen buffer?
Otherwise it works fine for me. |
|
What do you mean by off screen buffer?
Code Fragment: ------------- Please note: RequestScreen is a Canvas type opject which is used to getWidth() of the screen. private String[] screenFit(String[] rows) { RequestScreen req = new RequestScreen("",""); Font fnt = Font.getDefaultFont(); int screenWidth = req.getWidth(); for(int index = 0; index < rows.length ;index++) { int stringWidth = 0; int lastWhiteSpaceIndex = 0; for(int sindex = 0; sindex < rows[index].length(); sindex++) { if(rows[index].charAt(sindex) == ' ') lastWhiteSpaceIndex = sindex; stringWidth += fnt.charWidth(rows[index].charAt(sindex)); if(stringWidth > screenWidth - 5) /*If the string width greater than Screen width, move the text from last white space to the next line*/ { if(lastWhiteSpaceIndex!=0) { String[] newRows = new String[rows.length + 1]; for(int newIndex = 0; newIndex <= index; newIndex++) newRows[newIndex] = rows[newIndex]; for(int newIndex = rows.length; newIndex > index; newIndex--) newRows[newIndex] = rows[newIndex-1]; newRows[index+1] = rows[index].substring(lastWhiteSpaceIndex+1, rows[index].length()); newRows[index] = rows[index].substring(0, lastWhiteSpaceIndex) ; rows = newRows; break; } } } } return rows; } --------------- The result of the code is some characters (5-9 characters depending on the width of the characters) appear outside the screen and do not wrap around. I am trying to wrap string at the end of the screen width. Your help is greatly appreciated, Thanks. -Nachiket |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|