Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #2335

Need simple example of how to safely pass data from worker to EDT swing threads.

Received by 10.68.191.97 with SMTP id gx1mr578742pbc.4.1354806450811; Thu, 06 Dec 2012 07:07:30 -0800 (PST)
Received by 10.50.220.231 with SMTP id pz7mr496614igc.8.1354806450742; Thu, 06 Dec 2012 07:07:30 -0800 (PST)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!newsfeed.news.ucla.edu!usenet.stanford.edu!kt20no13219890pbb.1!news-out.google.com!6ni28943pbd.1!nntp.google.com!kt20no13219885pbb.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.java.help
Date Thu, 6 Dec 2012 07:07:30 -0800 (PST)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=129.6.84.222; posting-account=AUICdAoAAACL1WQVvOBDz2PnwQWbTEPK
NNTP-Posting-Host 129.6.84.222
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <118db2e0-86dc-4d6b-aabb-ba68ee8c2f53@googlegroups.com> (permalink)
Subject Need simple example of how to safely pass data from worker to EDT swing threads.
From kwiateks@gmail.com
Injection-Date Thu, 06 Dec 2012 15:07:30 +0000
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Xref csiph.com comp.lang.java.help:2335

Show key headers only | View raw


Hello Kinds Sirs,

I need a simple runnable example of a swing application that has a GUI with a jcombobox filled with a long list of name/value objects (eg 3000 employee names and numbers). There is also a worker process that reads in a record from a file/database, and then updates the gui jcombo box so that the employee item is "selected".

I was able to write something using  java map and employee objects to set the selected item in the jcombo box, but if I invoke setSelectedItem in the worker thread, I get odd results/delays.

See below snippets... how should the worker thread pass the employee object back to the gui for it to setSelectedItem?
....
empBuffer=  new Employee(id, lastName );
map.put(empBuffer.getId()+"",empBuffer ); 
model.addAll(map.values()); 
Collections.sort(model); 
myComboBox1.setModel(new javax.swing.DefaultComboBoxModel(model));
....
emp = (Employee) map.get(myData.getEmployeeNum()); 
myComboBox1.setSelectedItem(emp);

Back to comp.lang.java.help | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Need simple example of how to safely pass data from worker to EDT swing threads. kwiateks@gmail.com - 2012-12-06 07:07 -0800
  Re: Need simple example of how to safely pass data from worker to EDT swing threads. Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-06 10:29 -0500
    Re: Need simple example of how to safely pass data from worker to EDT swing threads. kedward777@gmail.com - 2012-12-06 09:09 -0800
  Re: Need simple example of how to safely pass data from worker to EDT   swing threads. Nigel Wade <nmw@ion.le.ac.uk> - 2012-12-06 17:27 +0000
    Re: Need simple example of how to safely pass data from worker to EDT   swing threads. Lew <lewbloch@gmail.com> - 2012-12-06 11:10 -0800
  Re: Need simple example of how to safely pass data from worker to EDT swing threads. Roedy Green <see_website@mindprod.com.invalid> - 2012-12-06 15:03 -0800

csiph-web