• 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:
  • Devaka Cooray
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

update() method problem in Observer interface

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,
This is one of the most strange problems that I'm experiencing right now. I have designed a gui based app made in swing with MVC pattern. To implement mvc practices, I have used Observer and Observable combination. Just for the ease of UI designing, I made use of jbuilder 7 and then with the passage of time I started coding its model and controller components in normal editors (like textpad). Problem is that when i invoke my application from command-line, my update() method (that i have been override for Observer interface) didn't get called !!! Yes, it happened with me and when I invoke my application from jbuilder IDE, it worked fine. I checked all the classpaths, compiled my sources from cmdline, did complete of all static resources that I am using in it; but of no use. It should be noted here that methods defined in my model class (child of Observable class) get called properly but when methods and called from model, my method didn't get call in my UI class, which is implementing Observer interface). This problem only appears when I launch my application from command line.
Plz HLEP me as I am totally stuck to it now.
Thanks.
 
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Update () should probably start with lower case u. But if that is just a typo, try to simplify your code so it still shows the problem and we can try it out for you. Often you fix the problem by yourself through the process of simplification.
 
Raheel rancher
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Eddie n thanks. First of all it was a typo in my post but not in my actual coding. Secondly, I solved the problem. How I solve it, i really want to share it with you and other people out there. Actually, it was due to event dispatching mechanism employed in jfc/swing components. I just put part of my code responsible for showing the jframe inside a separate class which is implementing runnable interface and then i throw the instance of that class to EventQue. Below is what I changed:

And it solved my problem. Now I can get called my [BOLD]update()[/BOLD] method from command line as well.
I hope this description will help others as well. To understand the event dispatching in a more detailed way, you & others can view a nice JDC Tech-Tip from Sun. Its link is:
Multithreading in Swing
Thanks.
 
I guess I've been abducted by space aliens. So unprofessional. They tried to probe me with this tiny ad:
Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders
https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing
reply
    Bookmark Topic Watch Topic
  • New Topic