< prev index next >

src/java.desktop/share/classes/javax/swing/SwingUtilities.java

Print this page




 329 
 330     /**
 331      * Returns a MouseEvent similar to <code>sourceEvent</code> except that its x
 332      * and y members have been converted to <code>destination</code>'s coordinate
 333      * system.  If <code>source</code> is {@code null}, <code>sourceEvent</code> x and y members
 334      * are assumed to be into <code>destination</code>'s root component coordinate system.
 335      * If <code>destination</code> is <code>null</code>, the
 336      * returned MouseEvent will be in <code>source</code>'s coordinate system.
 337      * <code>sourceEvent</code> will not be changed. A new event is returned.
 338      * the <code>source</code> field of the returned event will be set
 339      * to <code>destination</code> if destination is non-{@code null}
 340      * use the translateMouseEvent() method to translate a mouse event from
 341      * one component to another without changing the source.
 342      *
 343      * @param source the source component
 344      * @param sourceEvent the source mouse event
 345      * @param destination the destination component
 346      *
 347      * @return the new mouse event
 348      */

 349     public static MouseEvent convertMouseEvent(Component source,
 350                                                MouseEvent sourceEvent,
 351                                                Component destination) {
 352         Point p = convertPoint(source,new Point(sourceEvent.getX(),
 353                                                 sourceEvent.getY()),
 354                                destination);
 355         Component newSource;
 356 
 357         if(destination != null)
 358             newSource = destination;
 359         else
 360             newSource = source;
 361 
 362         MouseEvent newEvent;
 363         if (sourceEvent instanceof MouseWheelEvent) {
 364             MouseWheelEvent sourceWheelEvent = (MouseWheelEvent)sourceEvent;
 365             newEvent = new MouseWheelEvent(newSource,
 366                                            sourceWheelEvent.getID(),
 367                                            sourceWheelEvent.getWhen(),
 368                                            sourceWheelEvent.getModifiers()




 329 
 330     /**
 331      * Returns a MouseEvent similar to <code>sourceEvent</code> except that its x
 332      * and y members have been converted to <code>destination</code>'s coordinate
 333      * system.  If <code>source</code> is {@code null}, <code>sourceEvent</code> x and y members
 334      * are assumed to be into <code>destination</code>'s root component coordinate system.
 335      * If <code>destination</code> is <code>null</code>, the
 336      * returned MouseEvent will be in <code>source</code>'s coordinate system.
 337      * <code>sourceEvent</code> will not be changed. A new event is returned.
 338      * the <code>source</code> field of the returned event will be set
 339      * to <code>destination</code> if destination is non-{@code null}
 340      * use the translateMouseEvent() method to translate a mouse event from
 341      * one component to another without changing the source.
 342      *
 343      * @param source the source component
 344      * @param sourceEvent the source mouse event
 345      * @param destination the destination component
 346      *
 347      * @return the new mouse event
 348      */
 349     @SuppressWarnings("deprecation")
 350     public static MouseEvent convertMouseEvent(Component source,
 351                                                MouseEvent sourceEvent,
 352                                                Component destination) {
 353         Point p = convertPoint(source,new Point(sourceEvent.getX(),
 354                                                 sourceEvent.getY()),
 355                                destination);
 356         Component newSource;
 357 
 358         if(destination != null)
 359             newSource = destination;
 360         else
 361             newSource = source;
 362 
 363         MouseEvent newEvent;
 364         if (sourceEvent instanceof MouseWheelEvent) {
 365             MouseWheelEvent sourceWheelEvent = (MouseWheelEvent)sourceEvent;
 366             newEvent = new MouseWheelEvent(newSource,
 367                                            sourceWheelEvent.getID(),
 368                                            sourceWheelEvent.getWhen(),
 369                                            sourceWheelEvent.getModifiers()


< prev index next >