aspose file tools
The moose likes Beginning Java and the fly likes sending inbetween in observer Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "sending inbetween in observer" Watch "sending inbetween in observer" New topic
Author

sending inbetween in observer

Ty Karl
Greenhorn

Joined: Jun 11, 2009
Posts: 22
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 );
}

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19214

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.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Ty Karl
Greenhorn

Joined: Jun 11, 2009
Posts: 22
thank you very much Rob, I will give it a bash. Sorry for posting on wrong forum
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: sending inbetween in observer
 
Similar Threads
"Static reference to non-static method"
Listen to changes to an integer variable to update JLabel
Refreshable List (really tough question)
Observable and Observer - Send class object with notifyObservers() and use the object atthe Observer
ArrayList.get(int index)