< prev index next >

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

Print this page




  27 import sun.reflect.misc.ReflectUtil;
  28 import sun.swing.SwingUtilities2;
  29 import sun.swing.UIAction;
  30 
  31 import java.applet.*;
  32 
  33 import java.awt.*;
  34 import java.awt.event.*;
  35 import java.awt.dnd.DropTarget;
  36 
  37 import java.lang.reflect.*;
  38 
  39 import javax.accessibility.*;
  40 import javax.swing.event.MenuDragMouseEvent;
  41 import javax.swing.plaf.UIResource;
  42 import javax.swing.text.View;
  43 import java.security.AccessController;
  44 import sun.security.action.GetPropertyAction;
  45 
  46 import sun.awt.AppContext;


  47 
  48 /**
  49  * A collection of utility methods for Swing.
  50  *
  51  * @author unknown
  52  */
  53 public class SwingUtilities implements SwingConstants
  54 {
  55     // These states are system-wide, rather than AppContext wide.
  56     private static boolean canAccessEventQueue = false;
  57     private static boolean eventQueueTested = false;
  58 
  59     /**
  60      * Indicates if we should change the drop target when a
  61      * {@code TransferHandler} is set.
  62      */
  63     private static boolean suppressDropSupport;
  64 
  65     /**
  66      * Indiciates if we've checked the system property for suppressing


 338                                               p.x,p.y,
 339                                               sourceMenuDragEvent.getXOnScreen(),
 340                                               sourceMenuDragEvent.getYOnScreen(),
 341                                               sourceMenuDragEvent.getClickCount(),
 342                                               sourceMenuDragEvent.isPopupTrigger(),
 343                                               sourceMenuDragEvent.getPath(),
 344                                               sourceMenuDragEvent.getMenuSelectionManager());
 345         }
 346         else {
 347             newEvent = new MouseEvent(newSource,
 348                                       sourceEvent.getID(),
 349                                       sourceEvent.getWhen(),
 350                                       sourceEvent.getModifiers()
 351                                               | sourceEvent.getModifiersEx(),
 352                                       p.x,p.y,
 353                                       sourceEvent.getXOnScreen(),
 354                                       sourceEvent.getYOnScreen(),
 355                                       sourceEvent.getClickCount(),
 356                                       sourceEvent.isPopupTrigger(),
 357                                       sourceEvent.getButton());



 358         }
 359         return newEvent;
 360     }
 361 
 362 
 363     /**
 364      * Convert a point from a component's coordinate system to
 365      * screen coordinates.
 366      *
 367      * @param p  a Point object (converted to the new coordinate system)
 368      * @param c  a Component object
 369      */
 370     public static void convertPointToScreen(Point p,Component c) {
 371             Rectangle b;
 372             int x,y;
 373 
 374             do {
 375                 if(c instanceof JComponent) {
 376                     x = c.getX();
 377                     y = c.getY();




  27 import sun.reflect.misc.ReflectUtil;
  28 import sun.swing.SwingUtilities2;
  29 import sun.swing.UIAction;
  30 
  31 import java.applet.*;
  32 
  33 import java.awt.*;
  34 import java.awt.event.*;
  35 import java.awt.dnd.DropTarget;
  36 
  37 import java.lang.reflect.*;
  38 
  39 import javax.accessibility.*;
  40 import javax.swing.event.MenuDragMouseEvent;
  41 import javax.swing.plaf.UIResource;
  42 import javax.swing.text.View;
  43 import java.security.AccessController;
  44 import sun.security.action.GetPropertyAction;
  45 
  46 import sun.awt.AppContext;
  47 import sun.awt.AWTAccessor;
  48 import sun.awt.AWTAccessor.MouseEventAccessor;
  49 
  50 /**
  51  * A collection of utility methods for Swing.
  52  *
  53  * @author unknown
  54  */
  55 public class SwingUtilities implements SwingConstants
  56 {
  57     // These states are system-wide, rather than AppContext wide.
  58     private static boolean canAccessEventQueue = false;
  59     private static boolean eventQueueTested = false;
  60 
  61     /**
  62      * Indicates if we should change the drop target when a
  63      * {@code TransferHandler} is set.
  64      */
  65     private static boolean suppressDropSupport;
  66 
  67     /**
  68      * Indiciates if we've checked the system property for suppressing


 340                                               p.x,p.y,
 341                                               sourceMenuDragEvent.getXOnScreen(),
 342                                               sourceMenuDragEvent.getYOnScreen(),
 343                                               sourceMenuDragEvent.getClickCount(),
 344                                               sourceMenuDragEvent.isPopupTrigger(),
 345                                               sourceMenuDragEvent.getPath(),
 346                                               sourceMenuDragEvent.getMenuSelectionManager());
 347         }
 348         else {
 349             newEvent = new MouseEvent(newSource,
 350                                       sourceEvent.getID(),
 351                                       sourceEvent.getWhen(),
 352                                       sourceEvent.getModifiers()
 353                                               | sourceEvent.getModifiersEx(),
 354                                       p.x,p.y,
 355                                       sourceEvent.getXOnScreen(),
 356                                       sourceEvent.getYOnScreen(),
 357                                       sourceEvent.getClickCount(),
 358                                       sourceEvent.isPopupTrigger(),
 359                                       sourceEvent.getButton());
 360             MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor();
 361             meAccessor.setCausedByTouchEvent(newEvent,
 362                 meAccessor.isCausedByTouchEvent(sourceEvent));
 363         }
 364         return newEvent;
 365     }
 366 
 367 
 368     /**
 369      * Convert a point from a component's coordinate system to
 370      * screen coordinates.
 371      *
 372      * @param p  a Point object (converted to the new coordinate system)
 373      * @param c  a Component object
 374      */
 375     public static void convertPointToScreen(Point p,Component c) {
 376             Rectangle b;
 377             int x,y;
 378 
 379             do {
 380                 if(c instanceof JComponent) {
 381                     x = c.getX();
 382                     y = c.getY();


< prev index next >