开发者

Reduce height and width of BlackBerry BasicEditField

I am trying to change the width and height of a BlackBerry BasicEditField. But its not displaying the BasicEditField as i mention.

  HorizontalFieldManager HFMreg = 
      new HorizontalFieldManager(
           HorizontalFieldManager.USE_ALL_WIDTH 
         | HorizontalFieldManager.USE_ALL_HEIGHT) {
      //Override the paint method to draw the background image.
      public void paint(Graphics graphics) { 
       开发者_StackOverflow社区   //Draw the registration background image
          graphics.drawBitmap(0,0,Display.getWidth(),Display.getHeight(),BMregbg, 0, 0);
          super.paint(graphics);
      }
  };

  BEFfirstname = new BasicEditField("","",5,EditField.NO_NEWLINE) {
      protected void paint(Graphics graphics) {
          graphics.fillRect(0,0,80,25);
          graphics.setBackgroundColor(Color.WHITE);
          graphics.clear();
          super.paint(graphics); 
      }

      protected void layout() {
          super.layout(getPreferredWidth(),getPreferredHeight());
          setExtent(80,25); //width,height
      }

      public int getPreferredWidth() {
          int fieldWidth = 80; //required width
          return fieldWidth;
      }

      public int getPreferredHeight() {
          int fieldHeight = 25; // required height
          return fieldHeight;
      }
  };
  //BEFfirstname.setMargin(200,0,0,60);

  HFMreg.add(LFfirstname);
  HFMreg.add(BEFfirstname);

  add(HFMreg);


just an other way round:

BasicEditField BEFfirstname = new BasicEditField("","",5,EditField.NO_NEWLINE);
 MyManager obj = new MyManger();
 obj.add(BEFfirstname);
 add(obj);




class MyManager extends Manager
     {
       MyManager()
        {
           super(Manager.USE_ALL_WIDTH | Manager.USE_ALL_HEIGHT);
         }

        protected void sublayout(int width, int height)
        {
            Field f = getField(0);
              layoutChild(f,80,25);
              setPositionChild(f, 10, 10);      
        }
     }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜