I'm attempting to create a search result list in my program using a single-column JTable wrapped in a JScrollPane as the "container" and custom TableCellRenderer that creates JPanels (from an IDEA Form) for each result object and adds them as rows to the JTable.
The renderer calls table.setRowHeight(row, resultJPanel.getPreferredSize().height) inside the getTableCellRendererComponent method, which sets the height of the JTable row to the preferred height of the JPanel that contains the result.
For some reason, the height returned by resultJPanel.getPreferredSize().height is always very high, usually around 3000 pixels. The content inside the JPanel should only take up about 150 pixels, and there are no vspacers.
There are 3 components inside the result JPanel: 2 JLabels and 1 JTextArea. The JTextArea's Vertical Size Policy is just Can Grow, and the Vertical Align is Top.
Any ideas? What is the recommended way of implementing this type of visual component within the Form Designer (a scrollable list of JPanels)? Is there some way to set the vertical size policy of the JPanel at the top-level of my form?