1

我正在为文本字段使用图像。

当我专注于写一些东西时,我写的文本的第一个字母会被剪掉一半。

如何避免这种情况?

我的代码是:

textbox = new EditField(EditField.NO_NEWLINE) 
    {
     protected void layout(int width, int height) 
     {
         super.layout(1000, 38);
         super.setExtent((Display.getWidth()),30); 
     }
    }

 manager = new VerticalFieldManager(HORIZONTAL_SCROLL)
    {
     protected void paint(Graphics g) 
    {
      int x = this.getHorizontalScroll();
         g.drawBitmap( x, 0,textbox.getWidth(),textboxc.getHeight(),textbox, 0, 0 );
         super.paint(g);
    }
         protected void sublayout(int maxWidth, int maxHeight) 
         {
             Field field = testbox;
             layoutChild(field, Display.getWidth(), Display.getHeight());
             setPositionChild(field, 148, 8);
             super.sublayout(maxWidth, maxHeight);
        }
   }

manager.add(textbox);
4

1 回答 1

1
textbox= new EditField(" ","",500,EditField.NO_NEWLINE | Field.FOCUSABLE) 
         {
             protected void paint(Graphics g)
                {
                    g.setColor(Color.MAROON);
                    super.paint(g);
                }
            protected boolean keyChar(char key, int status, int time) 
             {
                return super.keyChar(key, status, time);
             }
         };


         manager = new VerticalFieldManager(HORIZONTAL_SCROLL )
         {
             protected void paint(Graphics g) 
                {
                 int x = this.getHorizontalScroll();
                 if(textbox.getText().equals(""))
                 {
                     g.drawBitmap( x, 0, textbox_img.getWidth(), textbox_img.getHeight(), textbox_img, 0, 0 );
                 }

                    super.paint(g);
                }
}
manager.add(textbox);
于 2010-02-23T09:29:48.647 回答