private void updateSize() { // look for a parent ScrollPane and revalidate its container // otherwise revalidate the text area's container Container parent = getParentScrollPane(); if (parent != null && parent.getParent() instanceof JComponent) { JComponent component = (JComponent) parent.getParent(); component.revalidate(); } }
/** * Called when the number of rows is updated. By default, it will get the parent scroll pane and call revalidate. * Subclass can override it to customize the behavior when number of rows is updated. * * @param oldRow the previous row count. * @param newRow the new row count. */ protected void numberOfRowsUpdated(int oldRow, int newRow) { // look for a parent ScrollPane and revalidate its container // otherwise revalidate the text area's container JScrollPane scroll = getParentScrollPane(); if (scroll != null) { Container parent = scroll.getParent(); if (parent != null && parent instanceof JComponent) { JComponent component = (JComponent) parent; component.revalidate(); } } }