KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nightlabs > editor2d > viewer > awt > AbstractAWTAutoScrollSupport


1 /* *****************************************************************************
2  * NightLabs Editor2D - Graphical editor framework *
3  * Copyright (C) 2004-2005 NightLabs - http://NightLabs.org *
4  * *
5  * This library is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or (at your option) any later version. *
9  * *
10  * This library is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13  * Lesser General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU Lesser General Public *
16  * License along with this library; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin St, Fifth Floor, *
19  * Boston, MA 02110-1301 USA *
20  * *
21  * Or get it online : *
22  * http://www.gnu.org/copyleft/lesser.html *
23  * *
24  * *
25  ******************************************************************************/

26
27 package org.nightlabs.editor2d.viewer.awt;
28
29 import java.awt.Component JavaDoc;
30 import java.awt.event.ComponentAdapter JavaDoc;
31 import java.awt.event.ComponentEvent JavaDoc;
32 import java.awt.event.ComponentListener JavaDoc;
33 import java.awt.event.MouseAdapter JavaDoc;
34 import java.awt.event.MouseEvent JavaDoc;
35 import java.awt.event.MouseListener JavaDoc;
36 import java.awt.event.MouseMotionAdapter JavaDoc;
37 import java.awt.event.MouseMotionListener JavaDoc;
38
39 import org.nightlabs.editor2d.viewer.AbstractAutoScrollSupport;
40
41 public abstract class AbstractAWTAutoScrollSupport
42 extends AbstractAutoScrollSupport
43 {
44     public AbstractAWTAutoScrollSupport(Component JavaDoc comp)
45     {
46         super();
47         component = comp;
48         init();
49     }
50     
51     protected Component JavaDoc component;
52     public Component JavaDoc getComponent() {
53         return component;
54     }
55     
56     protected void init()
57     {
58         component.addComponentListener(resizeListener);
59         component.addMouseListener(exitListener);
60         component.addMouseMotionListener(moveListener);
61         initAutoScroll(component.getBounds());
62     }
63     
64     protected ComponentListener JavaDoc resizeListener = new ComponentAdapter JavaDoc()
65     {
66         public void componentResized(ComponentEvent JavaDoc evt)
67         {
68             Component JavaDoc c = evt.getComponent();
69             initAutoScroll(c.getBounds());
70         }
71     };
72     
73     protected MouseMotionListener JavaDoc moveListener = new MouseMotionAdapter JavaDoc()
74     {
75         public void mouseMoved(MouseEvent JavaDoc evt) {
76             AbstractAWTAutoScrollSupport.this.mouseMoved(evt.getX(), evt.getY());
77         }
78     };
79     
80     protected MouseListener JavaDoc exitListener = new MouseAdapter JavaDoc()
81     {
82         public void mouseExited(MouseEvent JavaDoc arg0) {
83             AbstractAWTAutoScrollSupport.this.mouseExited();
84         }
85     };
86     
87 }
88
Popular Tags