Hello!
I work with j2me polish 2.0.7, in eclipse 3.4.2, with wtk2.5.2_01. I create control which draws text: normal, bold, and italic.
The code below is parsing raw text, and search for * and _ symbols, if found than add to draw vector the text and the drawer, and it's just stops after getting second time to the line 58:
String test = new String(raw_text_buff.substring(iter));
it stops in raw_text_buff.substring(iter), ONLY in debug mode..
raw text is: bla bla bla *1000* bla bla
Full code:
private String raw_text = "bla bla bla *1000* bla bla";
Vector draw_items = null;
private void prepareText()
{
char open_char = 0;
int open_pos = 0;
Object []param = null;
StringBuffer sb = new StringBuffer();
String raw_text_buff = new String(raw_text);
int iter = 0;
boolean was_reset = false;
while(true)
{
char c = raw_text_buff.charAt(iter);
if(iter == raw_text_buff.length() || c == '*' || c == '_')
{
if(sb.length() > 0)
{
BmFont viewer = null;
String str = sb.toString();
if(open_char == '*' && null != bm_strong)
{
viewer = bm_strong.getViewer(str);
}else
if(open_char == '_' && null != bm_italic)
{
viewer = bm_italic.getViewer(str);
}else if(null != bm_normal)
{
viewer = bm_normal.getViewer(str);
}else
{
}
param = new Object[2];
param[0] = str;
param[1] = viewer;
if(null == draw_items)
draw_items = new Vector();
draw_items.addElement(param);
sb = new StringBuffer();
if(open_char == 0 && (c == '*' || c=='_'))
open_char = c;
else
open_char = 0;
String test = new String(raw_text_buff.substring(iter)); // stucks here.
raw_text_buff = test;
iter = 0;
was_reset = true;
}else
{
open_char = c;
}
if(iter == raw_text_buff.length())
break;
}else
{
sb.append(c);
}
++iter;
}
}
What I'm doing wrong?