public AuctionCreateScreen(Card card, Bitmap cardthumb) {
    super(null);
    add(new ColorLabelField(""));
    this.card = card;
    SettingsBean _instance = SettingsBean.getSettings();
    _instance.created = false;
    SettingsBean.saveSettings(_instance);
    Font _font = getFont();
    _font = _font.derive(Const.TYPE, Const.FONT);
    setFont(_font);

    bgManager.setStatusHeight(exit.getContentHeight());

    exit.setChangeListener(this);
    auction.setChangeListener(this);

    // cardfield = new CardField(card, cardthumb);
    cardfield = new ThumbnailField(card);
    // add(cardfield);
    add(cardfield);
    add(lblOpeningBid);
    int val = 0;
    try {
      val = Integer.parseInt(card.getValue());
    } catch (Exception e) {
      val = 0;
    }
    openingBid.setText("" + val);
    buyNowPrice.setText("" + (2 * val));
    auctionDuration.setText("5");

    add(openingBid);
    add(lblBuyNowPrice);
    add(buyNowPrice);
    add(lblAuctionDuration);
    add(auctionDuration);

    addButton(auction);
    addButton(empty);
    addButton(exit);

    invalidate();
    setDisplaying(true);
  }
 public boolean valid() {
   if (openingBid.getText().length() == 0) {
     setText("Please enter an opening bid.");
     return false;
   }
   try {
     Integer.parseInt(openingBid.getText());
   } catch (NumberFormatException e) {
     setText("Please enter a valid opening bid.");
     return false;
   }
   if (buyNowPrice.getText().length() == 0) {
     setText("Please enter a buy now price.");
     return false;
   }
   try {
     Integer.parseInt(buyNowPrice.getText());
   } catch (NumberFormatException e) {
     setText("Please enter a valid buy now price.");
     return false;
   }
   if (auctionDuration.getText().length() == 0) {
     setText("Please enter the length of the auction(in days).");
     return false;
   }
   try {
     Integer.parseInt(auctionDuration.getText());
   } catch (NumberFormatException e) {
     setText("Please enter a valid length of the auction(in days).");
     return false;
   }
   try {
     if (Integer.parseInt(auctionDuration.getText()) == 0) {
       setText("Auction must last at least one day.");
       return false;
     }
   } catch (NumberFormatException e) {
   }
   try {
     if (Integer.parseInt(auctionDuration.getText()) > 9) {
       setText("Auctions are not allowed to last longer then 9 days.");
       return false;
     }
   } catch (NumberFormatException e) {
   }
   return true;
 }
  public void fieldChanged(Field f, int i) {
    if (f == exit) {
      screen = null;
      UiApplication.getUiApplication().popScreen(this);
    } else if (f == auction && created == false) {
      if (!confirm) {
        if (valid()) {
          created = false;
          SettingsBean _instance = SettingsBean.getSettings();
          _instance.created = false;
          SettingsBean.saveSettings(_instance);
          confirm = true;

          // when i auction
          /*
           * created = true, instance.created = true
           */
          synchronized (UiApplication.getEventLock()) {
            try {

              this.delete(cardfield);
              this.delete(openingBid);
              this.delete(buyNowPrice);
              this.delete(auctionDuration);

              lblBuyNowPrice.setText("");
              lblAuctionDuration.setText("");
              int val = 0;
              int buynow = 0;
              try {
                buynow = Integer.parseInt(buyNowPrice.getText());
              } catch (Exception e) {
                buynow = 0;
              }
              int bid = 0;
              try {
                bid = Integer.parseInt(openingBid.getText());
              } catch (Exception e) {
                bid = 0;
              }
              val = bid;
              if (buynow > bid) {
                val = buynow;
              }
              val = (int) ((double) val / 10);
              if (val < 5) {
                val = 5;
              }

              lblOpeningBid.setColor(Color.RED);
              lblOpeningBid.setText(
                  "Are you sure you want to auction "
                      + card.getDesc()
                      + "? It will cost you "
                      + val
                      + " credits.");
              // lblOpeningBid.setColor(Const.FONTCOLOR);

              add(
                  new AuctionField(
                      new Auction(
                          -1,
                          card.getId(),
                          1,
                          card.getDesc(),
                          card.getThumburl(),
                          openingBid.getText(),
                          buyNowPrice.getText(),
                          "",
                          "You",
                          auctionDuration.getText() + " days left",
                          ""),
                      cardfield.getThumbnail()));

              // this.removeButton(auction);
              // addButton(new FixedButtonField(""));
            } catch (Exception e) {

            }
          }
          // doConnect(Const.createauction+"&cardid="+card.getId()+"&bid="+openingBid.getText()+"&buynow="+buyNowPrice.getText()+"&days="+auctionDuration.getText());
        }
      } else {
        if (valid()) {
          created = true;
          SettingsBean _instance = SettingsBean.getSettings();
          _instance.created = true;
          SettingsBean.saveSettings(_instance);

          synchronized (UiApplication.getEventLock()) {
            try {
              lblOpeningBid.setColor(Color.RED);
              lblOpeningBid.setText("Attempting to create auction...");

              auction.setChangeListener(null);
              auction.empty = true;
              auction.setLabel("");
              // removeButton(auction);

            } catch (Exception e) {

            }
          }
          doConnect(
              Const.createauction
                  + "&cardid="
                  + card.getId()
                  + "&bid="
                  + openingBid.getText()
                  + "&buynow="
                  + buyNowPrice.getText()
                  + "&days="
                  + auctionDuration.getText());
        }
      }
    }
  }