consume() in MouseEvent

A

asit

I recently came through the following code...

public void mouseReleased( MouseEvent e ) { // called after a button
is released
isButtonPressed = false;
setBackground( Color.black );
repaint();
e.consume();
}


Can anyone tell me what is the task of e.consume() ????
 
M

Mark Space

asit said:
I recently came through the following code...

public void mouseReleased( MouseEvent e ) { // called after a button
is released
isButtonPressed = false;
setBackground( Color.black );
repaint();
e.consume();
}


Can anyone tell me what is the task of e.consume() ????

The docs say:

public void consume()

Consumes this event so that it will not be processed in the default
manner by the source which originated it.


So I assume there's some low-level behavior which was undesired, and the
consume() stops that behavior.
 
A

Albert

Mark Space a écrit :
The docs say:

public void consume()

Consumes this event so that it will not be processed in the default
manner by the source which originated it.


So I assume there's some low-level behavior which was undesired, and the
consume() stops that behavior.

The good question is then, what is this low-level behavior ? Since
listener are called in "addition order", default behavior should have
processed already, don't you think ?
 
A

asit

The good question is then, what is this low-level behavior ? Since
listener are called in "addition order", default behavior should have
processed already, don't you think ?

I think I agree with u !!!!!
 
J

John B. Matthews

asit said:
The good question is then, what is this low-level behavior ? Since
listener are called in "addition order", default behavior should
have processed already, don't you think ?

I think I agree with u !!!!!

Why not try the experiment: elide the call to e.consume() and see how
the program's behavior changes?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top