After trying 3 days of try and error, i know that the first time when i asked for help, i put the wrong questions.
My second try: (sorry guys and ladys ...)
I have a TreeMap it does what it supposed to do perfectly, give out a list with Key, and Value.
Problem, i want print this list on a pop-up window and want to get the two tipes of bracket away
Now it looks like this:
Want looking like this, without brackets:
Number of the correct Answers
10 Fragen: Ben 10
9 Fragen: Ben 9
what i can put in the JTextArea so no barkets are there ?
FIRST try was:
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.
Joined: May 29, 2005
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)
It might be something like this:
Now the JTextArea will have all the text it needs.
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.