简体   繁体   中英

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?

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)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM