×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    13

    Question Font size in a List Element

    Hai friends,
    In my application i am using List to show the various items stored in the recordstore.When i am displaying a long text as the list items, Nokia 6630 doesn't show the full text in the list item.How to reduce the font size in the List item?.Please help me.

    Thanks in Advance,
    askii

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    8

    Re: Font size in a List Element

    Can I bump this - since I'm having the exact same problem. Some list items are only displaying 8 characters on some nokia handsets.

    The code in use is:
    Code:
          Font fnt = Font.getFont(Font.FACE_SYSTEM,Font.STYLE_PLAIN, Font.SIZE_SMALL);
            for(int i = 0; i < get_Form.size(); i++) {
                Item it = (Item) get_Form.get(i);
                try {
                     if ( it.getClass().getName().endsWith("ChoiceGroup") ) {           
                            ChoiceGroup cg = (ChoiceGroup) it;
                            for ( int j = 0; j < cg.size(); j++) {
                                cg.setFont(j, fnt) ;
                            }
                        }
                        
                } catch (Exception e) {
                        e.printStackTrace();
                }        
            }

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    13

    Re: Font size in a List Element

    hai, The same type of code i'm also using.Is there any other way to reduce the font size inside List?

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    8

    Re: Font size in a List Element

    There are other ways....
    1) Use a custom item to mimic the behaviour of the list
    2) Forget using the high level API and start straight from canvas
    3) Use another library, like J2ME polish

    --
    Of course I am just hoping having been writing my application for the past month that the nokia implementation of MIDP2 supports the setFont method. After all what is the point of writing for the high level UI (as recommended for business apps), if half the text drops off the right hand side of the screen.

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    8

    Re: Font size in a List Element

    There is also an article:
    http://www.forum.nokia.com/html_read...,13144,00.html
    which goes into using fonts - but I can't see anything that I have done that is different from that article!

  6. #6
    Registered User
    Join Date
    Jun 2005
    Posts
    8

    Re: Font size in a List Element

    Well it can't be the choice of font - that works without problems for StringItems on the phone.

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    13

    Re: Font size in a List Element

    Thanks, I wiil let you know if i find the solution.For the time being i'll go for canvas or custom Item in a Form.

  8. #8
    Registered User
    Join Date
    Jun 2005
    Posts
    8

    Re: Font size in a List Element

    Very, very early days with this one - but below you can find the beginings of the customItem (I'm still kind of hoping that someone will be able to shed some light on why it's not happening as standard):

    Code:
    import javax.microedition.lcdui.*;
    import java.util.Vector;
    import java.util.Hashtable;
    /**
     *
     * @author rconyard
     */
    public class NChoiceGroup extends CustomItem  implements ItemCommandListener {
    
        private static final String UNCHECKED = "0";
        private static final String CHECKED = "1";
        private Display display;
        private int iLineHeight = 20;
        private Vector vList;
        private Hashtable hList;
        private int iLineWidth = 128;
        private int iLabelHeight = 20;
        private Font fnt;
        
        int iBoxSize = 10;
        int iHorizontalPadding = 10;
        int iVerticalPadding = 2;
        int iCurrentY = -1;
    
        
        /** Creates a new instance of NChoiceGroup */
        public NChoiceGroup(String title, Display d) {
            super(title);
            display = d;
            hList = new Hashtable();
            vList = new Vector();
            fnt = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);
            iLineHeight = fnt.getHeight();
            iBoxSize = iLineHeight;
        }
        
        protected int getMinContentHeight() {
            return iLabelHeight + iLineHeight * vList.size();
        }
    
        protected int getMinContentWidth() {
           return iLineWidth;
        }
    
        protected int getPrefContentHeight(int width) {
            return iLabelHeight + iLineHeight * vList.size();
        }
    
        protected int getPrefContentWidth(int height) {
            return iLineWidth;
        }
        
        protected void paint(Graphics g, int w, int h) {
            
            for (int i = 0; i < vList.size(); i++) {
                // for every item in the list
    
                if (iCurrentY == i) {
                    // draw the grey box behind the line
                    int iOC = g.getColor();
                    g.setColor(0x00D0D0D0);
                    g.fillRect(0, i * (iLineHeight + iVerticalPadding), iLineWidth, iBoxSize);                
                    g.setColor(iOC);
                }
                
                g.drawRect(0,i * (iLineHeight + iVerticalPadding), iBoxSize, iBoxSize);
                
                if (hList.get(new Integer(i)) == CHECKED) {
                    // draw the tick box
                    g.fillRect(2,(i * (iLineHeight + iVerticalPadding)) + 2, iBoxSize - 3 , iBoxSize - 3);
                }
                
                g.drawString((String) vList.elementAt(i),iBoxSize + iHorizontalPadding, i * (iLineHeight + iVerticalPadding), g.TOP|g.LEFT);
    
            }
        }
        
        
        
        protected boolean traverse(int dir, int viewportWidth, int viewportHeight, 
                                   int[] visRect_inout) {
    
    
            switch (dir) {
    
                case Canvas.DOWN:
                    
                    iCurrentY++;
                    if (iCurrentY > vList.size()) {
                        return false;
                    
                    }
                    break;
    
                case Canvas.UP:
                    iCurrentY--;
                    if (iCurrentY < 0) {
                        return false;
                    
                    }
                    break;
    
                case Canvas.LEFT:
                    break;
    
                case Canvas.RIGHT:                
                    break;
                case Canvas.FIRE:
                    hList.put(new Integer(iCurrentY), CHECKED);
                    break;
            }
            System.out.println(dir);
            this.repaint();
            visRect_inout[0] = 0;
            visRect_inout[1] = iCurrentY;
            visRect_inout[2] = iLineWidth;
            visRect_inout[3] = vList.size() * (iLineHeight + iVerticalPadding);
    
            return true;
        }
        
        
        
        
    
        
        public void keyPressed(int keyCode) {
                if (keyCode == -5) {
                    if ( hList.get(new Integer(iCurrentY)) == UNCHECKED) {
                        hList.put(new Integer(iCurrentY), CHECKED);
                    } else {
                        hList.put(new Integer(iCurrentY), UNCHECKED);                    
                    }
                }
                repaint();
            
        }
        
        public void reDraw(int iWidth) {
            this.iLineWidth =  iWidth;
            invalidate();
        }
        
        
        public void commandAction(Command c, Item i) {
            
        }
        
        
        // list methods and setting
        public void append(String strItem) {
            vList.addElement(strItem);
            hList.put(new Integer(vList.size()-1), UNCHECKED);
        }
        
        public void setFont(Font oFnt) {
            this.fnt = oFnt;
        }
        
    }

Similar Threads

  1. Changing Font Size in FP3 Emulator
    By prabhubalajishankar in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2005-08-16, 10:02
  2. Font size in query
    By samweb in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2004-07-29, 06:59
  3. Contact List Picture Size
    By Tall-Guy in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2004-04-10, 15:52
  4. Series 60: Changing the font in a list box
    By MentalBlank in forum Symbian User Interface
    Replies: 0
    Last Post: 2002-10-01, 08:33
  5. NDS List icon maximum size
    By Nokia_Archive in forum Mobile Java General
    Replies: 1
    Last Post: 2002-05-24, 13:39

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×