java me - GridFieldManager Blackberry align fields -


i have gridfieldmanager whith 3 columns , want align content this:

     |title left | title center | title right| 

the problem i'm using richtextfield instead of labelfield because want text of each title grap this:

     |title left | title center   | title right  |     |is wrapped | wrapped | wrapped | 

if use richtextfield instead of labelfield, then, the alignment ignored. code:

public class customgridfieldextends gridfieldmanager {      private int numcolumns = 3;     private int margin = 5;      public customgridfield(string lefttext, string centertext, string righttext) {           super(1, 3, gridfieldmanager.use_all_width);         setpadding(0, margin, 0, margin);          int columnwidth = (display.getwidth() / numcolumns);         (int = 0; < numcolumns; i++) {             setcolumnproperty(i, gridfieldmanager.fixed_size, columnwidth);         }          // leftmost text         richtextfield leftlabel = new richtextfield(lefttext){             protected void paint(graphics g) {                 g.setcolor(color.white);                 g.setfont(getfont().derive(font.bold));                 super.paint(g);             }         };         leftlabel.setfont(getfont().derive(font.bold));         add(leftlabel, field.field_left);          // center text         richtextfield centerlabel = new richtextfield(centertext){             protected void paint(graphics g) {                 g.setfont(getfont().derive(font.bold));                 g.setcolor(color.white);                 super.paint(g);             }         };         centerlabel.setfont(getfont().derive(font.bold));         add(centerlabel, field.field_hcenter);           // rightmost text         richtextfield rightlabel = new richtextfield(righttext) {             protected void paint(graphics g) {                 g.setfont(getfont().derive(font.bold));                 g.setcolor(color.white);                 super.paint(g);             }         };         rightlabel.setfont(getfont().derive(font.bold));         add(rightlabel, field.field_right);     }       protected void paintbackground(graphics g) {         // draw nice background...     } } 

found answer, turns out had use styles when creating richtextfields:

new richtextfield("text on left",richtextfield.text_align_left); new richtextfield("text on center",richtextfield.text_align_hcenter); new richtextfield("text on right",richtextfield.text_align_right); 

now i'm working on grapping...

pd: found here: http://v4ks1n.wordpress.com/2009/04/16/richtextfield-alignment/


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -