Hi my friends
I am trying to write text editor in j2me
I need to draw line sign on the char and move the line by pressing
key right and left
This some code to draw line in main class
Code:e = new LineEnumeration(inputFont,currentString,inputWidth-50,g); if(caretBlinkOn && goToNextChar) { g.drawLine(e.pr(),e.ca,e.pr(),e.ca+inputFont.getHeight()); }
And this cpde of class for warping text
Code:public class LineEnumeration implements Enumeration { private Font font; private String text1; private int width; private int position=0; private int length; int ff; private int start = 0; int ca=10; boolean b=false; int c1; int caretLef=0; String s[]= {"","","","","","","","","","","","","","","","","","","","","","" ,"","","","","","","","","","","","","","","","",""}; String ss; String sss=""; int d=-1; public LineEnumeration(Font font, String text, int width,Graphics h) { this.font = font; this.text1 = text; h.setFont(font); this.width = width; this.length = text.length(); } public boolean hasMoreElements() { return (position < (length)); } public Object nextElement() throws NoSuchElementException { try { d++; if(d!=0) { ca=ca+font.getHeight(); } s[d]=text1.substring(start,start = next()); return s[d]; } catch ( IndexOutOfBoundsException e ) { throw new NoSuchElementException(e.getMessage ()); } catch ( Exception e ) { throw new NoSuchElementException(e.getMessage()); } } public void proky(int a) { if(c1>s[d].length()) {d--; ca=ca-font.getHeight(); } caretLef=font.substringWidth(s[d],0,a); } public int pr(){ return caretLef; } }
And this code to process keypress
Code:if(keyName.equals("Right") ) { c++; e.proky(c); //System.out.println("else"+e.pr()); }
But not work correctly
Please any one edit on my code or hint on code to solve my problem

Reply With Quote

