01: /*
02: * @(#)DelegateMouseListener.java 1/30/2007
03: *
04: * Copyright 2002 - 2007 JIDE Software Inc. All rights reserved.
05: */
06:
07: package com.jidesoft.swing;
08:
09: import java.awt.event.MouseEvent;
10: import java.awt.event.MouseListener;
11:
12: /**
13: * This mouse listener can delegate the mouse events to another mouse listener.
14: * It can be used when you need to do something extra steps when there is a mouse event but you still
15: * want the original mouse listener to be called under certain condition.
16: */
17: public class DelegateMouseListener implements MouseListener {
18: private MouseListener _listener;
19:
20: public DelegateMouseListener(MouseListener listener) {
21: _listener = listener;
22: }
23:
24: public void mouseClicked(MouseEvent e) {
25: if (_listener != null) {
26: _listener.mouseClicked(e);
27: }
28: }
29:
30: public void mousePressed(MouseEvent e) {
31: if (_listener != null) {
32: _listener.mousePressed(e);
33: }
34: }
35:
36: public void mouseReleased(MouseEvent e) {
37: if (_listener != null) {
38: _listener.mouseReleased(e);
39: }
40: }
41:
42: public void mouseEntered(MouseEvent e) {
43: if (_listener != null) {
44: _listener.mouseEntered(e);
45: }
46: }
47:
48: public void mouseExited(MouseEvent e) {
49: if (_listener != null) {
50: _listener.mouseExited(e);
51: }
52: }
53: }
|