Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Using multiple threads to add components to a JPanel.  RSS feed

 
Claude Moore
Ranch Hand
Posts: 862
8
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm just wondering if it's possible to add components to a JPanel using multiple threads.
I have a quite big list of components (10K !!) - no more than rectangles representing boxes to be placed in a storage - to add to a panel, and I would like to split the main list in sublists, and use a MT approach to add concurrently to the panel to save time.
The problem is that I cannot use paging

Any suggestion ?
 
Campbell Ritchie
Sheriff
Posts: 53747
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, of course you can. But since Swing is non‑thread‑safe, expect things to go horribly wrong
 
Claude Moore
Ranch Hand
Posts: 862
8
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is "The whole thing must work correctly" a too strong requisite, then ?
 
Rob Camick
Ranch Hand
Posts: 2752
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a quite big list of components (10K !!) - no more than rectangles representing boxes to be placed in a storage


Then you would probably do custom painting and paint the rectangles. Using 10K components would eat up your resources. Also how would a user every be able to access components individually.
 
Claude Moore
Ranch Hand
Posts: 862
8
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:

Then you would probably do custom painting and paint the rectangles. Using 10K components would eat up your resources. Also how would a user every be able to access components individually.


Already done that. But I feel that the problem is in the design. it's simply crazy to want a lot of items around your screen. Yeah, you have the whole vision... together with a big mess. For free.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!