| Author |
Vector
|
Maya Naga
Ranch Hand
Joined: Nov 09, 2009
Posts: 79
|
|
hi am new to java collections...
in my program am doing calculations and adding those string result values to a vector...
i want to display those values one by one when i click the next and previous button..
when i code as follows only the last value is displayed in text field...
by i want to display all values ..
what i want to do..
please help....
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Check out JList.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Pari Nanoti
Greenhorn
Joined: Nov 09, 2009
Posts: 9
|
|
This is where i think the problem is
A) Logic:
1) You don't need MouseListener, you need ActionListener: one for each button (Next and Previous)
2) Don't loop through the collection, get the next or previous result strnig, based on what button was clicked, and set it in the txtresult
B) Optimization
1) No need of s,s1,s2,s3,s4, string and str variables, you can concatenate the result in the argument to v.addElement() itself.
2) There in no need to convert Vector into array, you can use the vector itself.
3) If you are using 1.5 or higher, go for generics, you can avoid the toString() call.
|
Thanks & Regards, Happy to help
Parimal Nanoti (SCJP 6)
|
 |
Maya Naga
Ranch Hand
Joined: Nov 09, 2009
Posts: 79
|
|
thanks pari..
that worked
|
 |
 |
|
|
subject: Vector
|
|
|