• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

sending inbetween in observer

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

1 I want to know how to send and integer to the observer,the int is the loop count
2I have notifyobservers in a loop? Is that ok?
EVENT SOURCE

For (int I = 0; I<23;I ++) {


setChanged();
notifyObservers( ??? I ??? );
}

HANDLER
private int resp;
public void update (Observable obj, Object arg)
{
if ( ?? how do I say instance of int so I can check it)
{
System.out.println("\HERE IS THE INTEGER VALUE: "+ resp );
}

 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Wrap the int in an Integer:

2) notifying may take a long time, that's the only problem. And if you are executing your code from a synchronized block / method, you could get possible deadlock problems (read Effective Java to see how this is possible).


Not really Swing related, moving to beginner.
 
Ty Karl
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you very much Rob, I will give it a bash. Sorry for posting on wrong forum
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic