Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

J2ME - How to implement vertical text scroll using Canvas

 
soni KL
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am using Canvas in my Midlet and have a long string which I have parsed and stored in a Vector. I need to display this text on the screen which gives an effect of vertical scrolling. The horizontal word wrap works fine but I am unsuccesful in scrolling vertically.

Any hints/sample codes/ links in this direction is much appreciated.

thanks
 
Nidheesh Puthalath
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There r many ways to do it.
here is one among them.
first u have to identify the screen width and findout how many characters u can display in a line with ur selected font.
create a string array of 'size' (where size = total string size / total char's in a line) and store each line of string in that array.
then,
create two variables 'first' and 'last' such that
first = 0;
last = n (where n is the total lines a screen can show.)
in the paint method show the strings from 'first' to 'last'
initially, just call repaint().
then, when user selects DOWN increment both 'first' and 'last' and call repaint()
when user selects UP decrement both 'first' and 'last' and call repaint()
give the condition for 'first' to not go below zero and 'last' to not go above size-1.

hope this will help u

Nidheesh
 
Fred Grott
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there is anice article on hwo to do it at sun's mobility subsection of the java.sun.com site..June or JUly
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic