コード例 #1
0
 public void setCurrentValue(int i) {
   if (i <= maxValue && (i >= minValue)) {
     currentValue = i;
     tf.setText(Integer.toString((int) currentValue));
     decrementButton.setEnabled(currentValue > minValue);
     incrementButton.setEnabled(currentValue < maxValue);
   }
 }
コード例 #2
0
 public void setCurrentValueLong(long i) {
   if (i <= maxValue && (i >= minValue)) {
     currentValue = i;
     tf.setText(Long.toString(currentValue));
     decrementButton.setEnabled(currentValue > minValue);
     incrementButton.setEnabled(currentValue < maxValue);
   }
 }
コード例 #3
0
 public void setVisible(boolean b) {
   if (b) checkBackground();
   super.setVisible(b);
   tf.setVisible(b);
   decrementButton.setVisible(b);
   incrementButton.setVisible(b);
   enterButton.setVisible(b);
   repaint();
 }
コード例 #4
0
 private boolean checkBackground() {
   if (getParent() != null
       && getBackground() != null
       && !getBackground().equals(getParent().getBackground())) {
     bg = getParent().getBackground();
     setBackground(bg);
     // setBackground(Color.green);
     if (tf != null) tf.setBackground(bg);
     if (decrementButton != null) decrementButton.setBackground(bg);
     if (incrementButton != null) incrementButton.setBackground(bg);
     if (enterButton != null) enterButton.setBackground(bg);
     return true;
   } else return false;
 }
コード例 #5
0
 public void crement(int i) {
   if (MesquiteWindow.getQueryMode(this)) {
     MesquiteWindow.respondToQueryMode("Mini scroll", command, this);
     return;
   }
   if (i <= maxValue && (i >= minValue) && command != null) {
     currentValue = i;
     command.doItMainThread(
         Long.toString(currentValue),
         CommandChecker.getQueryModeString("Mini scroll", command, this),
         this);
     tf.setText(Long.toString(currentValue));
     decrementButton.setEnabled(i > minValue);
     incrementButton.setEnabled(i < maxValue);
   }
 }
コード例 #6
0
 public void decrement() {
   if (MesquiteWindow.getQueryMode(this)) {
     MesquiteWindow.respondToQueryMode("Mini scroll", command, this);
     return;
   }
   if (currentValue > minValue && command != null) {
     currentValue--;
     tf.setText(Long.toString(currentValue));
     command.doItMainThread(
         Long.toString(currentValue),
         CommandChecker.getQueryModeString("Mini scroll", command, this),
         this);
     enterButton.setEnabled(false);
     decrementButton.setEnabled(currentValue > minValue);
     incrementButton.setEnabled(currentValue < maxValue);
   }
 }
コード例 #7
0
 public void
     increment() { // have interface incrementable and pass object to this miniscroll so it can
   // notify object
   if (MesquiteWindow.getQueryMode(this)) {
     MesquiteWindow.respondToQueryMode("Mini scroll", command, this);
     return;
   }
   if (currentValue < maxValue && command != null) {
     currentValue++;
     command.doItMainThread(
         Long.toString(currentValue),
         CommandChecker.getQueryModeString("Mini scroll", command, this),
         this);
     tf.setText(Long.toString(currentValue));
     enterButton.setEnabled(false);
     decrementButton.setEnabled(currentValue > minValue);
     incrementButton.setEnabled(currentValue < maxValue);
   }
 }
コード例 #8
0
  public MiniScroll(
      MesquiteCommand command,
      boolean stacked,
      boolean horizontal,
      long currentValue,
      long minValue,
      long maxValue,
      String itemName) {
    this.currentValue = currentValue;
    this.itemName = itemName;
    this.minValue = minValue;
    this.maxValue = maxValue;
    this.stacked = stacked;
    this.horizontal = horizontal;
    this.command = command;
    if (!horizontal && !stacked) {
      totalWidth = textBoxWidth + 10;
      totalHeight = textBoxHeight + 40 + EnterButton.MIN_DIMENSION + 2;
    } else if (stacked) {
      totalWidth = textBoxWidth + EnterButton.MIN_DIMENSION + 2;
      totalHeight = textBoxHeight + 28;
    } else {
      totalWidth = textBoxWidth + 40 + EnterButton.MIN_DIMENSION + 2;
      totalHeight = textBoxHeight + 2;
    }
    setSize(totalWidth, totalHeight);
    setLayout(null);
    if (this.horizontal) {
      add(decrementButton = new MiniScrollButton(this, MiniScrollButton.LEFT, itemName));
      add(incrementButton = new MiniScrollButton(this, MiniScrollButton.RIGHT, itemName));
    } else {
      add(decrementButton = new MiniScrollButton(this, MiniScrollButton.DOWN, itemName));
      add(incrementButton = new MiniScrollButton(this, MiniScrollButton.UP, itemName));
    }
    add(enterButton = new EnterButton(this, horizontal || stacked));
    add(tf = new ScrollTextField(this, Long.toString(currentValue), 2));
    tf.setVisible(false);
    tf.addActionListener(this);
    tf.addTextListener(this);
    tf.setSize(5, 5);
    tf.setLocation(5, 5);

    add(dummy = new TextField(""));
    dummy.setEditable(false);
    dummy.setSize(0, 0);
    dummy.setBackground(bg);
    dummy.setLocation(0, 0);

    decrementButton.setVisible(false);
    incrementButton.setVisible(false);
    enterButton.setVisible(false);
    if (horizontal) {
      if (stacked) {
        tf.setSize(1, 1);
        decrementButton.setLocation(2, arrowHeight);
        incrementButton.setLocation(totalWidth - 20, arrowHeight);
      } else {
        tf.setSize(1, 1);
        decrementButton.setLocation(0, 2);
        tf.setLocation(decrementButton.getBounds().x + decrementButton.getBounds().width, 2);
        incrementButton.setLocation(
            tf.getBounds().x + tf.getBounds().width + EnterButton.MIN_DIMENSION + 1, 2);
      }
    } else {
      if (stacked) {
        tf.setSize(1, 1);
        decrementButton.setLocation(2, arrowHeight);
        incrementButton.setLocation(totalWidth - 26, arrowHeight);
      } else {
        tf.setSize(1, 1);
        incrementButton.setLocation(0, 0);
        tf.setLocation(0, decrementButton.getBounds().height + 6);
        decrementButton.setLocation(
            0, tf.getBounds().y + tf.getBounds().height + EnterButton.MIN_DIMENSION + 1);
      }
    }

    tf.setBackground(bg);
    setBackground(bg);
    enterButton.setEnabled(false);
    decrementButton.setEnabled(currentValue > minValue);
    incrementButton.setEnabled(currentValue < maxValue);
  }
コード例 #9
0
 public void setMinimumValueLong(long i) {
   if (i != minValue) {
     minValue = i;
     decrementButton.setEnabled(currentValue > minValue);
   }
 }
コード例 #10
0
 public void setMaximumValueLong(long i) {
   if (i != maxValue) {
     maxValue = i;
     incrementButton.setEnabled(currentValue < maxValue);
   }
 }
コード例 #11
0
  private boolean recalcPositions(Graphics g) {
    Font f = g.getFont();
    if (f != oldFont || !(StringUtil.stringsEqual(oldText, text))) {
      FontMetrics fm = g.getFontMetrics(f);
      sw = MesquiteInteger.maximum(fm.stringWidth("888"), fm.stringWidth(tf.getText()));
      sh = fm.getMaxAscent() + fm.getMaxDescent();
    }
    oldText = text;
    oldFont = f;
    if (oldTextBoxWidth < sw + MesquiteModule.textEdgeCompensationWidth - 1
        || oldTextBoxHeight < sh + MesquiteModule.textEdgeCompensationHeight - 1) {
      textBoxWidth = sw + MesquiteModule.textEdgeCompensationWidth; // 34
      textBoxHeight = sh + MesquiteModule.textEdgeCompensationHeight; // 18
      oldTextBoxWidth = textBoxWidth;
      oldTextBoxHeight = textBoxHeight;
      if (horizontal) {
        if (stacked) {
          totalWidth = textBoxWidth + EnterButton.MIN_DIMENSION + 2;
          totalHeight = textBoxHeight + 20;
          setSize(totalWidth, totalHeight);
          tf.setSize(textBoxWidth, textBoxHeight);
          tf.setLocation(0, 0);
          decrementButton.setLocation(2, textBoxHeight + 4);
          incrementButton.setLocation(totalWidth - 20, textBoxHeight + 4);
        } else {
          totalWidth = textBoxWidth + 36 + EnterButton.MIN_DIMENSION + 2;
          totalHeight = textBoxHeight + 4;
          setSize(totalWidth, totalHeight);
          tf.setSize(textBoxWidth, textBoxHeight);
          decrementButton.setLocation(0, 2);
          tf.setLocation(
              decrementButton.getBounds().x + decrementButton.getBounds().width + 1,
              0); // 1 added to x
          incrementButton.setLocation(
              tf.getBounds().x + tf.getBounds().width + EnterButton.MIN_DIMENSION + 2,
              2); // 1 added to x
        }
        enterButton.setLocation(tf.getBounds().x + tf.getBounds().width + 1, 2);
      } else {
        if (stacked) {
          totalWidth = textBoxWidth + EnterButton.MIN_DIMENSION + 2;
          totalHeight = textBoxHeight + 20;
          setSize(totalWidth, totalHeight);
          tf.setSize(textBoxWidth, textBoxHeight);
          tf.setLocation(0, 0);
          decrementButton.setLocation(2, textBoxHeight + 4);
          incrementButton.setLocation(totalWidth - 22, textBoxHeight + 4);
          enterButton.setLocation(tf.getBounds().x + tf.getBounds().width + 1, 2);
        } else {
          totalWidth = textBoxWidth; // should be 0
          totalHeight = textBoxHeight + 36 + EnterButton.MIN_DIMENSION + 2;

          setSize(totalWidth, totalHeight);
          tf.setSize(textBoxWidth, textBoxHeight);
          incrementButton.setLocation(1, 2);
          tf.setLocation(0, incrementButton.getBounds().height + 3);
          decrementButton.setLocation(
              1, tf.getBounds().y + tf.getBounds().height + EnterButton.MIN_DIMENSION + 2);
          enterButton.setLocation(1, tf.getBounds().y + tf.getBounds().height + 1);
        }
      }
      incrementButton.repaint();
      decrementButton.repaint();
      enterButton.repaint();
      repaint();
      getParent().repaint();
      return true;
    }
    if (checkBackground()) {
      repaint();
      return true;
    }
    /*	if (!getBackground().equals(getParent().getBackground())) {
    	bg =getParent().getBackground();
    	setBackground(bg);
    	//setBackground(Color.green);
    	tf.setBackground(bg);
    	decrementButton.setBackground(bg);
    	incrementButton.setBackground(bg);
    	enterButton.setBackground(bg);
    	repaint();
    	return true;
    }*/
    return false;
  }