40 |
|
|
41 |
import java.awt.Point; |
import java.awt.Point; |
42 |
import java.awt.event.ContainerListener; |
import java.awt.event.ContainerListener; |
43 |
|
import java.awt.event.MouseEvent; |
44 |
|
|
45 |
import java.beans.PropertyChangeListener; |
import java.beans.PropertyChangeListener; |
46 |
|
|
47 |
import javax.swing.JComponent; |
import javax.swing.JComponent; |
48 |
import javax.swing.JToolBar; |
import javax.swing.JToolBar; |
49 |
import javax.swing.border.Border; |
import javax.swing.border.Border; |
50 |
|
import javax.swing.event.MouseInputListener; |
51 |
import javax.swing.plaf.ComponentUI; |
import javax.swing.plaf.ComponentUI; |
52 |
import javax.swing.plaf.basic.BasicToolBarUI; |
import javax.swing.plaf.basic.BasicToolBarUI; |
53 |
|
|
172 |
if (dragWindow != null) |
if (dragWindow != null) |
173 |
dragWindow.setOffset(p); |
dragWindow.setOffset(p); |
174 |
} |
} |
175 |
|
|
176 |
|
/** |
177 |
|
* Creates and returns an instance of MetalDockingListener. |
178 |
|
* |
179 |
|
* @return an instance of MetalDockingListener. |
180 |
|
*/ |
181 |
|
protected MouseInputListener createDockingListener() |
182 |
|
{ |
183 |
|
return new MetalDockingListener(toolBar); |
184 |
|
} |
185 |
|
|
186 |
|
/** |
187 |
|
* This is the MouseHandler class that allows the user to drag the JToolBar |
188 |
|
* in and out of the parent and dock it if it can. |
189 |
|
*/ |
190 |
|
protected class MetalDockingListener extends BasicToolBarUI.DockingListener |
191 |
|
{ |
192 |
|
/** |
193 |
|
* Creates a new DockingListener object. |
194 |
|
* |
195 |
|
* @param t The JToolBar this DockingListener is being used for. |
196 |
|
*/ |
197 |
|
public MetalDockingListener(JToolBar t) |
198 |
|
{ |
199 |
|
super(t); |
200 |
|
} |
201 |
|
|
202 |
|
/** |
203 |
|
* This method is called when the mouse is pressed in the JToolBar. If the |
204 |
|
* press doesn't occur in a place where it causes the JToolBar to be |
205 |
|
* dragged, it returns. Otherwise, it starts a drag session. |
206 |
|
* |
207 |
|
* @param e The MouseEvent. |
208 |
|
*/ |
209 |
|
public void mousePressed(MouseEvent e) |
210 |
|
{ |
211 |
|
super.mousePressed(e); |
212 |
|
setDragOffset(new Point(e.getX(), e.getY())); |
213 |
|
} |
214 |
|
|
215 |
|
/** |
216 |
|
* This method is called when the mouse is dragged. It delegates the drag |
217 |
|
* painting to the dragTo method. |
218 |
|
* |
219 |
|
* @param e The MouseEvent. |
220 |
|
*/ |
221 |
|
public void mouseDragged(MouseEvent e) |
222 |
|
{ |
223 |
|
// Does not do anything differently than dragging |
224 |
|
// BasicToolBarUI.DockingListener |
225 |
|
super.mouseDragged(e); |
226 |
|
} |
227 |
|
} |
228 |
} |
} |