Exemplo n.º 1
0
  private void adjustSize() {
    int newHeight = mTextArea.getPreferredSize().height;
    int maxHeight = mChatView.getHeight() / 3;

    mScrollPane.setPreferredSize(
        new Dimension(
            mScrollPane.getWidth(),
            newHeight < maxHeight
                ?
                // grow
                newHeight + 1
                : // +1 for border
                // fixed height
                maxHeight));

    // swing does not figure this out itself
    mChatView.revalidate();
  }