• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Cannot re-use ActionEvent?

 
Ranch Hand
Posts: 271
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a search screen for e.g. company names.
When I input a company id (coyId) into the textfield and click on the search button, I expect a company name to be displayed in the center of the borderpane.
I want to search different company names multiple times by inputting different id's and clicking on search button.
The problem is, I can only do it once, if I click on it a second time, it crashes my IDE, the SDK, freezes the laptop with many hundreds of error messages in the console... I thought if of consume.event(), nope, that's not it.
searchscreen.JPG
[Thumbnail for searchscreen.JPG]
Search screen for company name
 
Rancher
Posts: 666
10
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Show the error here.
 
Sheriff
Posts: 28329
97
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would say that if you're going to call the event's consume() method then, yes, it would be a bad idea to use it again after doing that.

And I'm dubious about adding a listener to something every time you handle an action event. You're going to end up with a lot of duplicate listeners attached to that thing. Besides, your debugging code leads me to believe that you think adding the listener to the thing actually causes the listener's changed() method to be called.
 
AhFai Chan
Ranch Hand
Posts: 271
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. It works now, after removing Listener.
Yes, That's what I thought, that if I use a Listener, then the changed() method would be called.
 
AhFai Chan
Ranch Hand
Posts: 271
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote: leads me to believe that you think adding the listener to the thing actually causes the listener's changed() method to be called.



Back in 3GL days, I would have instantiated another variable String oldVal = txfCoyId.gettext() and compare the new value with the old value to see if it has changed, but it is not comething I can do inside the body of a method.
Are you suggesting I should use changed() without Listener?
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm confused.  Why couldn't you use the button's onAction event and build a list of company names each time the button is pressed?  You'd need a way to clear the names too.
 
She'll be back. I'm just gonna wait here. With this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic