Reputation: 17
I've got a problem with the size of some object, for example a JList. If I add a element, the size of the list will grow. Well that is good, but if I add alot of elements, the JList will be out of the window of my app and I can't see the bottom of it(Sorry for bad grammar). How can I can I make the size static, that it will not go 'under' my window size.
Mathijs
Upvotes: 0
Views: 204
Reputation: 4029
You can add your list to JScrollPane
then scroll pane to your panel as follows:
JScrollPane scroll = new JScrollPane(yourJList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
yourPanel.add(scrollPane);
Upvotes: 5