Exemple #1
0
  /** Adjust the width according to its content. */
  public void adjustWidth() {
    int width = Short.MIN_VALUE;

    for (final TextBox tb : getAllTextBox()) {
      final int tbWidth = tb.getTextDim().width;

      if (tbWidth > width) width = tbWidth; // get the longer content
    }

    // change the width according to the grid
    final Rectangle bounds = getBounds();

    Change.push(new BufferBounds(this));
    setBounds(
        new Rectangle(bounds.x, bounds.y, width + GraphicView.getGridSize() + 15, bounds.height));
    Change.push(new BufferBounds(this));
  }