/*-------------------------------------------------------------------------*/
 public void processKeyPressed(KeyEvent e) {
   switch (e.getKeyCode()) {
     case KeyEvent.VK_ENTER:
       amountEntered();
       break;
     case KeyEvent.VK_ESCAPE:
       exit();
       break;
     default:
       amountField.processKeyPressed(e);
   }
 }
  /*-------------------------------------------------------------------------*/
  public GetAmountDialog(PlayerCharacter pc, final int max, TextDialogCallback textDialogCallback) {
    super();
    this.textDialogCallback = textDialogCallback;

    int startX = DiyGuiUserInterface.SCREEN_WIDTH / 2 - DIALOG_WIDTH / 2;
    int startY = DiyGuiUserInterface.SCREEN_HEIGHT / 2 - DIALOG_HEIGHT / 2;

    Rectangle dialogBounds = new Rectangle(startX, startY, DIALOG_WIDTH, DIALOG_HEIGHT);

    this.setBounds(dialogBounds);

    DIYPane labelPane = new DIYPane(new DIYFlowLayout(0, 0, DIYToolkit.Align.CENTER));
    int buttonPaneHeight = 20;
    labelPane.setBounds(x, y + inset, width, buttonPaneHeight);
    labelPane.add(new DIYLabel("How Much (max " + max + ")?"));

    amountField =
        new DIYTextField() {
          public void processKeyPressed(KeyEvent e) {
            super.processKeyPressed(e);
            try {
              int amount = Integer.parseInt(amountField.getText());
              okButton.setEnabled(amount <= max);
            } catch (NumberFormatException x) {
              okButton.setEnabled(false);
            }
          }
        };
    amountField.setBounds(
        x + inset, y + inset + buttonPaneHeight, width - inset * 2, buttonPaneHeight);

    DIYPane buttonPane = new DIYPane(new DIYFlowLayout(10, 0, DIYToolkit.Align.CENTER));
    int inset = 10;
    buttonPane.setBounds(x, y + height - buttonPaneHeight - inset, width, buttonPaneHeight);
    okButton = new DIYButton("OK");
    okButton.addActionListener(this);

    cancel = new DIYButton("Cancel");
    cancel.addActionListener(this);
    buttonPane.add(okButton);
    buttonPane.add(cancel);

    okButton.setEnabled(false);

    setBackground();

    this.add(labelPane);
    this.add(amountField);
    this.add(buttonPane);
    this.doLayout();
  }
 /*-------------------------------------------------------------------------*/
 private void amountEntered() {
   if (okButton.isEnabled()) {
     exit();
     textDialogCallback.textEntered(amountField.getText());
   }
 }