简体   繁体   中英

Efficient way to add Components to Java Swing panel

I have a pre-constructed java panel that has about 30000 labels already added to it. I need to efficiently add this to a scrollpane on my Jframe. However if I call the add method it can take about 30 seconds to add to the scrollpane. Is there another way I can do this more efficiently? I need the UI to update quickly and if I re-add the labels to the panel everytime I need to display them I think this will be more expensive than simply loading the already rendered panel.

I think you should rethink your design. 30000 labels looks like way too much.

Look at JTable or rethink idea if you can't decrease amount of labels.

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