import javax.microedition.lcdui.*; public class App extends Canvas implements Runnable{ public Font font; public String str; public String[] p; public Parsing parsing; int height; int width; int id; int fh; Boolean up; Boolean down; public App(String s){ super(); str = s; setFullScreenMode(false); parsing = new Parsing(); p = parsing.splitString(str,"\n"); Thread thread = new Thread(this); font = Font.getFont(0,0,Font.SIZE_SMALL); fh = font.getHeight(); height = getHeight(); width = getWidth(); id = 0; up = false; down = false; thread.start(); } public void run(){ while(true){ if (up == true) up(); if (down == true) down(); if (down == false) down = false; if (up == false) up = false; try{ Thread.sleep(20); } catch (Exception e){} } } public void paint(Graphics g){ g.setFont(Font.getFont(0,0,Font.SIZE_SMALL)); g.setColor(255,255,255); g.fillRect(0,0,width,height); for (int i=0; i< p.length; i++){ String in = Integer.toString(i); g.setColor(0,0,0); g.drawString(in + " "+p[i], 0, id + i* fh,20); } repaint(); } public void keyPressed(int key){ if (key == Canvas.KEY_NUM2) up= true; if (key == Canvas.KEY_NUM8) down = true; } public void keyRealised(int key){ if (key == Canvas.KEY_NUM2) up = false; if (key == Canvas.KEY_NUM8) down = false; } public void down(){ if (fh * p.length> height){ id = id - fh; if (height - id> p.length* fh) id = height - p.length* fh; } } public void up(){ if (p.length* fh> height){ id = id + fh; if (id > 0) id = 0; } } /* end */ }