Example #1
0
  @Override
  public void paint(Graphics g, JComponent c) {
    JButton button = (JButton) c;
    String text = button.getText();
    Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon();

    if ((icon == null) && (text == null)) {
      return;
    }

    FontMetrics fm = g.getFontMetrics();
    paintViewInsets = c.getInsets(paintViewInsets);

    paintViewR.x = paintViewInsets.left;
    paintViewR.y = paintViewInsets.top;

    // Use inverted height & width
    paintViewR.height = c.getWidth() - (paintViewInsets.left + paintViewInsets.right);
    paintViewR.width = c.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);

    paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
    paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;

    Graphics2D g2 = (Graphics2D) g;
    AffineTransform tr = g2.getTransform();

    if (angle == 90) {
      g2.rotate(Math.PI / 2);
      g2.translate(0, -c.getWidth());
      paintViewR.x = c.getHeight() / 2 - (int) fm.getStringBounds(text, g).getWidth() / 2;
      paintViewR.y = c.getWidth() / 2 - (int) fm.getStringBounds(text, g).getHeight() / 2;
    } else if (angle == 270) {
      g2.rotate(-Math.PI / 2);
      g2.translate(-c.getHeight(), 0);
      paintViewR.x = c.getHeight() / 2 - (int) fm.getStringBounds(text, g).getWidth() / 2;
      paintViewR.y = c.getWidth() / 2 - (int) fm.getStringBounds(text, g).getHeight() / 2;
    }

    if (icon != null) {
      icon.paintIcon(c, g, paintIconR.x, paintIconR.y);
    }

    if (text != null) {
      int textX = paintTextR.x;
      int textY = paintTextR.y + fm.getAscent();

      if (button.isEnabled()) {
        paintText(g, c, new Rectangle(paintViewR.x, paintViewR.y, textX, textY), text);
      } else {
        paintText(g, c, new Rectangle(paintViewR.x, paintViewR.y, textX, textY), text);
      }
    }

    g2.setTransform(tr);
  }
 /** Go to the next panel, or finish if this is the last panel */
 public void next() {
   if (!nextButton.isEnabled()) return;
   currentPanel.canAdvance = true;
   currentPanel.wizardNext();
   if (!currentPanel.canAdvance) return;
   for (WizardListener listener : listeners) listener.wizardNext(currentPanel);
 }
Example #3
0
 /**
  * ************************************************
  *
  * <pre>
  * Summary: Catch any key pressed.
  *
  * </pre>
  *
  * *************************************************
  */
 public void keyPressed(KeyEvent e) {
   // Have an escape do the same as clicking cancel.
   if (e.getKeyCode() == KeyEvent.VK_ESCAPE) abandonButton.doClick();
   // Return
   else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
     if (closeButton.isEnabled()) {
       closeButton.doClick();
     }
   }
 }
 public void actionPerformed(ActionEvent e) {
   if (button.isEnabled() && button.getModel().isArmed()) {
     int value = boundedRangeModel.getValue();
     if (button == forwardButton) {
       boundedRangeModel.setValue(
           value == boundedRangeModel.getMaximum() ? boundedRangeModel.getMinimum() : value + 1);
     } else {
       boundedRangeModel.setValue(
           value == boundedRangeModel.getMinimum() ? boundedRangeModel.getMaximum() : value - 1);
     }
   }
 }
  protected void updateButtons() {
    if (isLastStep()) {
      if (mySteps.size() > 1) {
        myNextButton.setText(UIUtil.removeMnemonic(IdeBundle.message("button.finish")));
        myNextButton.setMnemonic('F');
      } else {
        myNextButton.setText(IdeBundle.message("button.ok"));
      }
      myNextButton.setEnabled(canFinish());
    } else {
      myNextButton.setText(UIUtil.removeMnemonic(IdeBundle.message("button.wizard.next")));
      myNextButton.setMnemonic('N');
      myNextButton.setEnabled(canGoNext());
    }

    if (myNextButton.isEnabled() && !ApplicationManager.getApplication().isUnitTestMode()) {
      getRootPane().setDefaultButton(myNextButton);
    }

    myPreviousButton.setEnabled(myCurrentStep > 0);
  }
 /** Go to the previous panel */
 public void back() {
   if (!backButton.isEnabled()) return;
   currentPanel.wizardBack();
   for (WizardListener listener : listeners) listener.wizardBack(currentPanel);
 }
Example #7
0
 public boolean isLastButtonEnabled() {
   return lastButton.isEnabled();
 }
Example #8
0
 public boolean isNextButtonEnabled() {
   return nextButton.isEnabled();
 }
Example #9
0
 public boolean isPrevButtonEnabled() {
   return prevButton.isEnabled();
 }
Example #10
0
 public boolean isFirstButtonEnabled() {
   return firstButton.isEnabled();
 }
 public boolean getSelected() {
   return !_button.isEnabled();
 }
Example #12
0
 /**
  * Is secret enabled.
  *
  * @return the boolean
  */
 public boolean isSecretEnabled() {
   return secretButton.isEnabled();
 }
Example #13
0
 /**
  * Is roll enabled.
  *
  * @return the boolean
  */
 public boolean isRollEnabled() {
   return rollButton.isEnabled();
 }
Example #14
0
 /**
  * Is suggest enabled.
  *
  * @return the boolean
  */
 public boolean isSuggestEnabled() {
   return suggButton.isEnabled();
 }
Example #15
0
 /**
  * Is accused enabled.
  *
  * @return the boolean
  */
 public boolean isAccusedEnabled() {
   return accuButton.isEnabled();
 }
    /** Background thread used to receive data from the server. */
    public void run() {
      Long id;
      Integer message_type;
      String target;
      String soap;
      SOAPMonitorData data;
      int selected;
      int row;
      boolean update_needed;
      while (socket != null) {
        try {
          // Get the data from the server
          message_type = (Integer) in.readObject();
          // Process the data depending on its type
          switch (message_type.intValue()) {
            case SOAPMonitorConstants.SOAP_MONITOR_REQUEST:
              // Get the id, target and soap info
              id = (Long) in.readObject();
              target = (String) in.readObject();
              soap = (String) in.readObject();
              // Add new request data to the table
              data = new SOAPMonitorData(id, target, soap);
              model.addData(data);
              // If "most recent" selected then update
              // the details area if needed
              selected = table.getSelectedRow();
              if ((selected == 0) && model.filterMatch(data)) {
                valueChanged(null);
              }
              break;
            case SOAPMonitorConstants.SOAP_MONITOR_RESPONSE:
              // Get the id and soap info
              id = (Long) in.readObject();
              soap = (String) in.readObject();
              data = model.findData(id);
              if (data != null) {
                update_needed = false;
                // Get the selected row
                selected = table.getSelectedRow();
                // If "most recent", then always
                // update details area
                if (selected == 0) {
                  update_needed = true;
                }
                // If the data being updated is
                // selected then update details
                row = model.findRow(data);
                if ((row != -1) && (row == selected)) {
                  update_needed = true;
                }
                // Set the response and update table
                data.setSOAPResponse(soap);
                model.updateData(data);
                // Refresh details area (if needed)
                if (update_needed) {
                  valueChanged(null);
                }
              }
              break;
          }

        } catch (Exception e) {
          // Exceptions are expected here when the
          // server communication has been terminated.
          if (stop_button.isEnabled()) {
            stop();
            setErrorStatus(STATUS_CLOSED);
          }
        }
      }
    }
 /** Cancel the dialog */
 public void cancel() {
   if (!cancelButton.isEnabled()) return;
   currentPanel.wizardCancel();
   for (WizardListener listener : listeners) returnCode = listener.wizardCancel(currentPanel);
   setVisible(false);
 }
Example #18
0
 /**
  * Is end enabled.
  *
  * @return the boolean
  */
 public boolean isEndEnabled() {
   return endButton.isEnabled();
 }
Example #19
0
 public void jButtonExit_actionPerformed(ActionEvent e) {
   if (jButtonStop.isEnabled()) {
     jButtonStop_actionPerformed(e);
   }
   System.exit(0);
 }
Example #20
0
  // Handles all the buttons and crap
  public void actionPerformed(ActionEvent e) {
    for (int i = 0; i < pages.length; i++) {
      if (e.getSource() == pages[i]) {
        page = i + 1;
      }
    }
    if (e.getSource() == pockets[0]) {
      page = 1;
      changeSelection(Item.Pocket.ITEM);
    }
    if (e.getSource() == pockets[1]) {
      page = 1;
      changeSelection(Item.Pocket.MEDICINE);
    }
    if (e.getSource() == pockets[2]) {
      page = 1;
      changeSelection(Item.Pocket.POKEBALL);
    }
    if (e.getSource() == pockets[3]) {
      page = 1;
      changeSelection(Item.Pocket.TMHM);
    }
    if (e.getSource() == pockets[4]) {
      page = 1;
      changeSelection(Item.Pocket.BATTLE);
    }
    if (e.getSource() == closeButton) {
      closeWindow();
    }
    if (e.getSource() == information) {
      infoB = !infoB;
    }
    if (e.getSource() == buySellButton) {
      if (state == State.BUY) {
        state = State.SELL;
        buySellButton.setText("Selling");
        changeSelection(Item.Pocket.ITEM);
      } else {
        state = State.BUY;
        buySellButton.setText("Buying");
        changeSelection(Item.Pocket.ITEM);
      }
    }
    int num = (page - 1) * 10;
    for (int i = 0; i < display.length; i++) {
      if (e.getSource() == display[i] && !itemSelected) {
        itemSelected = true;
        selectedItemId = num + i;
      } else if (e.getSource() == display[i]) {
        totalAmount.setText("Enter Amount");
        itemSelected = false;
        buyButton.setEnabled(false);
        sellButton.setEnabled(false);
      }
    }
    if (e.getSource() == amountField && itemSelected) {
      try {
        amount = Integer.parseInt(amountField.getText());
        amount *= currentDisplay.get(selectedItemId).storeCost;
        if (amount < 0
            || (state == State.SELL
                    && amount / currentDisplay.get(selectedItemId).storeCost
                        > currentDisplay.get(selectedItemId).amount)
                && (state != State.SELL && !currentDisplay.get(selectedItemId).reUsable)) {
          totalAmount.setText("Error");
        } else if (state == State.SELL
            && Inventory.getItemInfo(currentDisplay.get(selectedItemId)).amount
                < amount / currentDisplay.get(selectedItemId).storeCost) {
          totalAmount.setText("Error");
        } else {
          if (state == State.BUY) totalAmount.setText("Total of $" + amount);
          else totalAmount.setText("Total of $" + amount / 2);
        }
        updateBuyButton();
        updateSellButton();
      } catch (Exception ee) {
        totalAmount.setText("Error");
      }
    }
    if (e.getSource() == buyButton) {
      Inventory.money -= amount;

      if (currentDisplay.get(selectedItemId).type != Item.Type.TM
          || currentDisplay.get(selectedItemId).type != Item.Type.HM)
        Inventory.addItem(
            new Item(
                currentDisplay.get(selectedItemId).type,
                amount / currentDisplay.get(selectedItemId).storeCost));
      else
        Inventory.addItem(
            new Item(
                currentDisplay.get(selectedItemId).type,
                amount / currentDisplay.get(selectedItemId).storeCost,
                currentDisplay.get(selectedItemId).mNo));

      itemSelected = false;
      totalAmount.setText("Enter Amount");
      buyButton.setEnabled(false);
    }
    if (e.getSource() == sellButton) {
      updateSellButton();

      if (!sellButton.isEnabled()) return;
      Inventory.money += amount / 2;
      amount = amount / currentDisplay.get(selectedItemId).storeCost;
      while (amount > 0) {
        Inventory.decrementItem(currentDisplay.get(selectedItemId), true);
        amount--;
      }
      totalAmount.setText("Enter Amount");
      sellButton.setEnabled(false);
      itemSelected = false;
      changeSelection(pocket);
    }

    updateGui();
  }