java - Retrieving data from a map when using a SwingWorker -


I have a class that creates a GUI and there is an item with listener JComboBox I create a worker at an ItemEvent.Selected event and try to read data in a map, but the content is always empty.

My guess is that this is happening due to the thread being executed and leaving ItemListener before the thread is complete.

I have added my related pieces and hope that you can help me decide where the problem is. Private Zero Update UI (String Text) {StringUtilities.invokeLater (New Runnabel) {@Override Public Zero Run ({{.append (text + "\ n");}}} Private class ComboBoxListener ItemListener Expanded {@Override Public Zero Item StateChange (ItemEvent E) {if (e.getStateChange () == ItemEvent.DESELECTED) {return;} if (e .getStateChange () == ItemEvent.SELECTED) {// do stuff Map & Lt; string, string & gt; map = new hashmap & lt; string, string & gt; new) MyWorker (var1, var2) {@Override public update UI (string text) {UpdateMainUI (text);} @ Override public update map ( String name, string value) {Map.put (name, value);}}. Execute (); (map. Entry; string; string; entry: map.entrySet ()) {// Map content There are intangible methods in the MyWorker in something like}}}}

updateUI and updateMap Overriding so that I can send updates to Guy. In short, how can I get it? The data is back to the worker so that I can be done before ?

I wrote most of this out of memory because I do not have the actual code at this time, so please do not pay attention to the small typo and syntax issues.

A doInBackground () method executed asynchronously on other thread Does; The results will be available indefinitely in the future, but you are immediately checking map entries. Instead, published () each map. Entry & lt; String, string & gt; If intermediate results can be displayed in a useful manner in other components, then update the model of that component, such as JLabel . If not, then symbol . > To override done () to use the full result as shown here


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -