Code example for JScrollPane

Methods: getPreferredSizerevalidatesetPreferredSize

0
            throw new IllegalArgumentException("rows must be greater than 0.");
        } 
 
        int hdr_height = (int)table.getTableHeader().getHeaderRect(0).getHeight();
        int height     = table.getRowHeight() * (rows + 1) + hdr_height;
        Dimension dim  = new Dimension(scrollpane.getPreferredSize().width,
                                       height);
 
        scrollpane.setPreferredSize(dim);
        scrollpane.revalidate();
    } 
 
    /** 
     * Removes all of the rows of events in the event viewer. 
     * @since TCT 1.0 
     */ 
    public void clear() { 
        int count = model.getRowCount() - 1;
        for ( int i = count; i >= 0; i-- ) {
            model.removeRow(i);