bstpierre
bstpierre

Reputation: 31176

How do I make a JList automatically stretch with the window in a netbeans Swing app?

I have a simple java swing app, built in netbeans. There's a JList in the app (inside a JScrollPane -- netbeans automatically creates this). I want the JList to grow and shrink when the user resizes the main window.

What do I have to do in netbeans to tie the horizontal and vertical size of the JList to the main window?

Upvotes: 1

Views: 1684

Answers (2)

Joop Eggen
Joop Eggen

Reputation: 109532

In the GUI editor add a JPanel, set the layout to Free Design. Then you can attach the JList to all siding components (with margin) so the JList is resized.

Upvotes: 3

mKorbel
mKorbel

Reputation: 109815

1) use proper LayoutManager, if I understood correctly BorderLayout.CENTER can do that

2) put JList to the JScrollPane

3) write code by your hands and edit your question with SSCCE that demonstrated your issue(s)

Upvotes: 4

Related Questions