Java Swing: JScrollPane not working

后端 未结 2 1412
情深已故
情深已故 2021-01-14 00:55

I have a JPanel which contains some fields. The height of the JPanel is limited so I have to put a JScrollPane around it so people can scroll down.

As you can see be

2条回答
  •  感情败类
    2021-01-14 01:39

    Your DetailPanel has no layout manager associated with it, which means it doesn't expand when you add children to it, which means the JScrollPane doesn't have anywhere to scroll. Either call setLayout() on your DetailPanel or override getPreferredSize() to add up the heights of its children and return a meaningful value.

提交回复
热议问题