Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Action Source

Status
Not open for further replies.

fatcodeguy

Programmer
Feb 25, 2002
281
CA
Hi, I have two buttons that change the contents of a vector. How do I find out which entry originated from which button click? Thanks
 
Hey Hey someguy32 - how goes it ??

The easiest way that I know would be to have a public variable whcih returns 1/0 , or true/false - and is driven from the ActionListener when the certain button is pressed - then your Vectors could listen for the return value from the said variable to detemine whcih button was pressed ...

Ben
 
Hey sedj! Things are pretty good, yourself?

Your way works great! I started using it, but decided to use two move vectors instead. When a button is pressed, it adds the appropriate components to its respective vector and to the main vector. Then if I want to find the source, I just compare entries int he main vector to the two additional. Very easy to implement, and is not a problem unless we are talking about a few thousand clicks !! Thanks!
 
Remember though, the problem with Vectors is (I dont know if you know C/C++ at all) that they are in effect linked lists, which can take up more memory than arrays...which can make java run slower - marginally - but hey Swing is bastad slow anyway !!!

Hace a good bank holiday weekend (if you are in the UK!!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top