Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to associate JTextArea and Object? How to know which object belongs to which jtextArea?
    primarykey
    data
    text
    <p>I am writing a program that allows the user to provide the URL to RSS feeds, downloads and parses the information, and then displays it to <code>JTextArea</code>s.</p> <ul> <li>The user can add as many feed categories as he/she wants. (each category is represented in a separate pane)</li> <li>The user can add as many feeds in a category as he/she wants.</li> <li>The user can either add a new feed or a new category. </li> </ul> <p>I have an ArrayList(ArrayList) = categoryList. Each of it's items are category = ArrayList. And the Feed objects contain a getContents() method which returns ArrayList.</p> <p>I want to associate every Feed with a JTextArea. Then I want to iterate through the FeedItems, while displaying them in the corresponding JTextArea.</p> <p>I am really stuck on finding a way to associate a one to one map between Feed &lt;=> JTextArea.</p> <p>Here is my attempt:</p> <pre><code>if (category_list.size() &gt; 0) { final java.util.Iterator&lt;ArrayList&lt;Feed&gt;&gt; categoryListIterator = category_list.iterator(); final ArrayList&lt;Feed&gt; currCategory; final java.util.Iterator&lt;Feed&gt; currFeedIterator; while (categoryListIterator.hasNext()) { currCategory = categoryListIterator.next(); while (((java.util.Iterator&lt;ArrayList&lt;Feed&gt;&gt;) currCategory).hasNext()) { ArrayList&lt;Feed&gt; currFeed = ((java.util.Iterator&lt;ArrayList&lt;Feed&gt;&gt;) currCategory).next(); currFeedIterator = currFeed.iterator(); while (currFeedIterator.hasNext()) { Feed feed = currFeedIterator.next(); final java.util.Iterator&lt;FeedItem&gt; feedIterator = feed.getContents().iterator(); while (feedIterator.hasNext()) { // find the appropriate JTextArea // iterate through the articles. correspondingJtextArea.setText(feedIterator.next().toString()); } } } } } </code></pre> <p>Please let me know, what would be the best way of keeping track in which <code>JTextArea</code> I should change the text.</p> <p>Am I iterating through all the Feeds here correctly? A short example that illustrates my situation would be very very helpful.</p> <p><strong>UPDATE</strong>: </p> <p>Okay, so now I'm okay iterating through all the feeds. I only need to find a way to write a HashMap which associates a Feed with a JTextArea.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload