java - Eclipse SWT GUI - StyledText control - Equal width for each character -



java - Eclipse SWT GUI - StyledText control - Equal width for each character -

i need create swt styledtext command shows human readable characters equal spacing each character see in "notepad".

but when create text

styledtext outputtext = new styledtext(scrolledcomposite_2, swt.multi | swt.border | swt.h_scroll | swt.v_scroll); scrolledcomposite_2.setcontent(outputtext); scrolledcomposite_2.setminsize(outputtext.computesize(swt.default, swt.default)); outputtext.settext(data.tostring()); outputtext.setstylerange(new stylerange(0, data.tostring().length(), cmfutils.green, cmfutils.white));

when styledtext displayed in displays data, width of each character different. example, width of 'i' or ' ' (space) smaller other characters 's', causes me problems while pointing errored character using '^' in next line. example:

output>>>> blah-blah-blah-sdlfk-blah ................^

as can see, error in above sample string occurs @ "sdlfk" @ 16th character , when seek point putting '^' in next line 16 spaces (note: periods in illustration replaced spaces in original output), points different position in string.

use monospaced swt font.

font font = new font(display, "monospaced", 12, swt.normal); outputtext.setfont(font); // ... // in swt: if created it, dispose it. font.dispose();

java fonts swt spacing

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -