抱歉,标题有点混乱。情况如下:
I have a JList in a JScrollPane. Each list item (implemented as a custom ListCellRenderer) contains a JFrame with some labels and most importantly, a JTextArea. The text area contains some text that needs to wrap across many lines so that the user does not need to scroll horizontally in the scroll pane. I do not want the text area to scroll by itself, I just want it to expand to take as much vertical space as it needs.
如果它有助于理解我要实现的目标,请看以下IntelliJ swing UI设计器的屏幕截图:
I would like the body text area (and the panel with it) to expand to as much vertical space as it needs.
The component holding the text does not have to be a text area, I tried a JTextPane and that did not work either. The text does not need to be editable.<