make a iterator and put the value & key on a variable, then print them out:

Problem i get only the first a raw and not the whole list ...

1, [ Ben 1]

SECOND try was:

Put the keys and values in array and ... no good idea ... it prints the whole array of values then the keys like:

[[10, 9, 8 ... ] , [Ben 10], [Ben 9] ...]

So far i can see i get the names on the square brackets because they are stored on a array , the curly brackets because i put all the values on a map.
But still have no clue how to change that they are no barckets on my window.

in your FirstTry (you don't list a method name), pass the JTextArea into the method. Each time you get a key and value within your loop that you want to add to the JTextArea, use JTextArea.append() to put that string in it.

It looks like your problem is that you have one string variable for the key and one for the value, and you replace each string's value each time through the loop, so that they never hold one value. If you wanted to put the entire JTextArea text into one string, you would need to add successive values to the result string each time through the loop. But if you let the iterator add values to the text area instead, then you don't need to do that.

I put my two strings in a new String (umwandL_Va3) then try to add it to the JTextarea i get some issue:

---> Cannot make a static reference to the non-static method append(String) from the type JTextArea;

if i put the TextArea in the Loop the user must push "Ok" for each new line that is added to the window, thats why i have tried to print it all at one time.

Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479

posted Feb 06, 2011 07:25:10

1

As I said, you need to pass your JTextArea into this routine; then the routine has a reference to your JTextArea and can add things to it. When I said you should use JTextArea.append(), I only meant to identify the routine, not that it should be called on the class. It needs to be called on your object.

(Incidentally, if you posted the whole routine instead of just the loop, it would be easier to help)

Incidentally, getValue() returns you an ArrayList; calling toString() on an ArrayList may not give you exactly what you want; this loop may have to have an inner loop that goes through that ArrayList, appending whatever you want from it into the JTextArea.