The java.awt.event.MouseEvent.consume() method is used to consume this event so that it will not be processed in the default manner by the source which originated it.
Example 1: Suppose there is a button in a GUI application that generates a MouseEvent when pressed. When the user clicks on the button, the MouseEvent is triggered and the consume() method is invoked to prevent default processing of the MouseEvent.
Button btn = new Button("Click Me"); btn.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { e.consume(); } });
Example 2: Another example where a mouse event is consumed is when resizing a frame. When the user resizes the window, a MouseEvent is generated. By consuming the event, the default behavior of the event is stopped and the event is handled in a custom manner.
The java.awt.event.MouseEvent.consume() method is in the java.awt.event package which is a part of the Java AWT (Abstract Window Toolkit) library.
Java MouseEvent.consume - 30 examples found. These are the top rated real world Java examples of java.awt.Event.MouseEvent.consume extracted from open source projects. You can rate examples to help us improve the quality of examples.