简体   繁体   中英

Components in Grid with fixed size

I want to display a lot of component in a grid view, like the normal explorer in windows or other operating systems. Is it possible to obtain this with a default or 3rd Party layout manager?

I tried Gridlayout and Springlayout (according to this article ). Both resize the components relative to the parent dimension but I want fixed cell size and relative row and column numbers. Layoutmanager应该处理这个

尝试GridBagLayoutMigLayout

Both resize the components relative to the parent dimension

Create a panel using a GridLayout and add your components to this panel. Then add this panel to the NORTH of you frame instead of the CENTER . The NORTH will respect the size of the panel and all its components, wherease the CENTER will resize the panel based on the space available. Of course when you add the component to the NORTH it will never resize so you will not see scrollbars if they are needed.

Maybe other options would be to use:

  1. A JList with a horizontal wrap. See How to Use Lists

  2. The Wrap Layout .

these options allow the components to flow to a new row when necessary.

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